Skip to content

Commit

Permalink
fix: update ha state on command success
Browse files Browse the repository at this point in the history
closes #102
  • Loading branch information
alandtse committed Dec 6, 2021
1 parent 3a3c0fb commit 6ede864
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions custom_components/tesla_custom/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ async def async_set_temperature(self, **kwargs):
if temperature:
_LOGGER.debug("%s: Setting temperature to %s", self.name, temperature)
await self.tesla_device.set_temperature(temperature)
self.async_write_ha_state()


@TeslaDevice.Decorators.check_for_reauth
async def async_set_hvac_mode(self, hvac_mode):
Expand All @@ -96,13 +98,15 @@ async def async_set_hvac_mode(self, hvac_mode):
await self.tesla_device.set_status(False)
elif hvac_mode == HVAC_MODE_HEAT_COOL:
await self.tesla_device.set_status(True)
self.async_write_ha_state()

@TeslaDevice.Decorators.check_for_reauth
async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode."""
_LOGGER.debug("%s: Setting preset_mode to: %s", self.name, preset_mode)
try:
await self.tesla_device.set_preset_mode(preset_mode)
self.async_write_ha_state()
except UnknownPresetMode as ex:
_LOGGER.error("%s", ex.message)

Expand Down
2 changes: 2 additions & 0 deletions custom_components/tesla_custom/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ async def async_lock(self, **kwargs):
"""Send the lock command."""
_LOGGER.debug("Locking doors for: %s", self.name)
await self.tesla_device.lock()
self.async_write_ha_state()

@TeslaDevice.Decorators.check_for_reauth
async def async_unlock(self, **kwargs):
"""Send the unlock command."""
_LOGGER.debug("Unlocking doors for: %s", self.name)
await self.tesla_device.unlock()
self.async_write_ha_state()

@property
def is_locked(self):
Expand Down

0 comments on commit 6ede864

Please sign in to comment.