Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update folder structure for hacs #32

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions salusfy/__init__.py → custom_components/salusfy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""The Salus component."""
from .state import State
from .web_client import WebClient
from .thermostat_entity import ThermostatEntity
from .ha_temperature_client import HaTemperatureClient
from .client import Client
"""The Salus component."""

from .state import State
from .web_client import WebClient
from .thermostat_entity import ThermostatEntity
from .ha_temperature_client import HaTemperatureClient
from .client import Client
166 changes: 83 additions & 83 deletions salusfy/client.py → custom_components/salusfy/client.py
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
"""
Client which wraps the web client but handles
the retrieval of current temperature by calling
a specialized client.
"""
import logging
from homeassistant.components.climate.const import (
HVACMode,
HVACAction,
)
from . import (
WebClient,
HaTemperatureClient,
State,
)
_LOGGER = logging.getLogger(__name__)
class Client:
"""Mocks requests to Salus web application"""
def __init__(
self,
web_client: WebClient,
temperature_client: HaTemperatureClient):
"""Initialize the client."""
self._state = None
self._web_client = web_client
self._temperature_client = temperature_client
async def set_temperature(self, temperature: float) -> None:
"""Set new target temperature."""
_LOGGER.info("Delegating set_temperature to web client...")
await self._web_client.set_temperature(temperature)
self._state.target_temperature = temperature
self.assume_hvac_action()
async def set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set HVAC mode, via URL commands."""
_LOGGER.info("Delegating set_hvac_mode to web client...")
await self._web_client.set_hvac_mode(hvac_mode)
self._state.mode = hvac_mode
self.assume_hvac_action()
def assume_hvac_action(self) -> None:
"""Assumes what the hvac action is based on
the mode and current/target temperatures"""
if self._state.mode == HVACMode.OFF:
_LOGGER.info("Assuming action is IDLE...")
self._state.action = HVACAction.IDLE
return
if self._state.target_temperature > self._state.current_temperature:
_LOGGER.info(
"Assuming action is HEATING based on target temperature...")
self._state.action = HVACAction.HEATING
return
_LOGGER.info("Assuming action is IDLE based on target temperature...")
self._state.action = HVACAction.IDLE
async def get_state(self) -> State:
"""Retrieves the status"""
if self._state is None:
_LOGGER.info("Delegating get_state to web client...")
self._state = await self._web_client.get_state()
_LOGGER.info("Updating current temperature from temperature client...")
self._state.current_temperature = await self._temperature_client.current_temperature()
return self._state
"""
Client which wraps the web client but handles
the retrieval of current temperature by calling
a specialized client.
"""
import logging

from homeassistant.components.climate.const import (
HVACMode,
HVACAction,
)

from . import (
WebClient,
HaTemperatureClient,
State,
)

_LOGGER = logging.getLogger(__name__)


class Client:
"""Mocks requests to Salus web application"""

def __init__(
self,
web_client: WebClient,
temperature_client: HaTemperatureClient):
"""Initialize the client."""
self._state = None
self._web_client = web_client
self._temperature_client = temperature_client

async def set_temperature(self, temperature: float) -> None:
"""Set new target temperature."""

_LOGGER.info("Delegating set_temperature to web client...")

await self._web_client.set_temperature(temperature)

self._state.target_temperature = temperature

self.assume_hvac_action()

async def set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set HVAC mode, via URL commands."""

_LOGGER.info("Delegating set_hvac_mode to web client...")

await self._web_client.set_hvac_mode(hvac_mode)

self._state.mode = hvac_mode

self.assume_hvac_action()

def assume_hvac_action(self) -> None:
"""Assumes what the hvac action is based on
the mode and current/target temperatures"""
if self._state.mode == HVACMode.OFF:
_LOGGER.info("Assuming action is IDLE...")
self._state.action = HVACAction.IDLE
return

if self._state.target_temperature > self._state.current_temperature:
_LOGGER.info(
"Assuming action is HEATING based on target temperature...")
self._state.action = HVACAction.HEATING
return

_LOGGER.info("Assuming action is IDLE based on target temperature...")
self._state.action = HVACAction.IDLE

async def get_state(self) -> State:
"""Retrieves the status"""

if self._state is None:
_LOGGER.info("Delegating get_state to web client...")
self._state = await self._web_client.get_state()

_LOGGER.info("Updating current temperature from temperature client...")
self._state.current_temperature = await self._temperature_client.current_temperature()

return self._state
Loading
Loading