Skip to content

Commit

Permalink
[TASK] change start event to maybe fix #25
Browse files Browse the repository at this point in the history
  • Loading branch information
KartoffelToby committed Nov 21, 2021
1 parent 9256878 commit 9fd62b9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/ai_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
ATTR_TEMPERATURE,
CONF_NAME,
CONF_UNIQUE_ID,
EVENT_HOMEASSISTANT_START,
EVENT_HOMEASSISTANT_STARTED,
STATE_UNAVAILABLE,
STATE_UNKNOWN,
)
Expand Down Expand Up @@ -209,13 +209,13 @@ async def async_added_to_hass(self):
def _async_startup(*_):
"""Init on startup."""
sensor_state = self.hass.states.get(self.sensor_entity_id)
if self.startup and self.hass.states.get(self.heater_entity_id).attributes is not None:
if self.startup and self.hass.states.get(self.heater_entity_id) is not None:
self.startup = False
mqtt_calibration = {"local_temperature_calibration": 0}
payload = json.dumps(mqtt_calibration, cls=JSONEncoder)
self.mqtt.async_publish('zigbee2mqtt/'+self.hass.states.get(self.heater_entity_id).attributes.get('friendly_name')+'/set', payload, 0, False)
_LOGGER.debug(
"Register ai_thermostat: %s v0.6.0",
"Register ai_thermostat: %s v0.5.1",
self.hass.states.get(self.heater_entity_id).attributes.get('friendly_name'),
)
self._async_update_temp(sensor_state)
Expand All @@ -224,7 +224,7 @@ def _async_startup(*_):
if self.hass.state == CoreState.running:
_async_startup()
else:
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, _async_startup)
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, _async_startup)

# Check If we have an old state
old_state = await self.async_get_last_state()
Expand Down

0 comments on commit 9fd62b9

Please sign in to comment.