Skip to content

Commit

Permalink
Fix startup (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewturner authored Feb 25, 2024
1 parent 43d7c2f commit c0518e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 2 additions & 4 deletions salusfy/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
vol.Required(CONF_PASSWORD): cv.string,
vol.Required(CONF_ID): cv.string,
vol.Optional(CONF_SIMULATOR, default=False): cv.boolean,
vol.Optional(CONF_ENABLE_TEMPERATURE_CLIENT, default=True): cv.boolean,
vol.Optional(CONF_ENABLE_TEMPERATURE_CLIENT, default=False): cv.boolean,
vol.Required(CONF_ENTITY_ID): cv.string,
vol.Required(CONF_ACCESS_TOKEN): cv.string,
vol.Optional(CONF_HOST, default='localhost'): cv.string
Expand All @@ -57,11 +57,9 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

client = create_client_from(config)

await client.get_state()

name = config.get(CONF_NAME)
await async_add_entities(
async_add_entities(
[ThermostatEntity(name, client)]
)

Expand Down
12 changes: 11 additions & 1 deletion salusfy/thermostat_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
MIN_TEMP
)

from .state import State

from homeassistant.components.climate.const import (
HVACAction,
HVACMode,
Expand All @@ -32,7 +34,7 @@ def __init__(self, name, client):
"""Initialize the thermostat."""
self._name = name
self._client = client
self._state = None
self._state = State()


@property
Expand Down Expand Up @@ -144,6 +146,14 @@ async def set_hvac_mode(self, hvac_mode):
self._state.current_operation_mode = STATE_ON
self._state.status = STATE_ON


async def turn_off(self) -> None:
await self.set_hvac_mode(HVACAction.OFF)


async def turn_on(self) -> None:
await self.set_hvac_mode(HVACAction.HEATING)


async def async_update(self):
"""Retrieve latest state data."""
Expand Down
2 changes: 1 addition & 1 deletion tests/entity_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class EntityRegistry:
def __init__(self):
self._entities = []

async def register(self, list):
def register(self, list):
self._entities.extend(list)

@property
Expand Down

0 comments on commit c0518e5

Please sign in to comment.