From e307e1315a958b330aac9e8681744ef66237b21e Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Mon, 30 Nov 2020 00:57:32 -0800 Subject: [PATCH] Fix updating of Tesla switches after command (#43754) closes #43454 --- homeassistant/components/tesla/switch.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/homeassistant/components/tesla/switch.py b/homeassistant/components/tesla/switch.py index 9fcdbae0c1c..efcb955ebf8 100644 --- a/homeassistant/components/tesla/switch.py +++ b/homeassistant/components/tesla/switch.py @@ -30,11 +30,13 @@ class ChargerSwitch(TeslaDevice, SwitchEntity): """Send the on command.""" _LOGGER.debug("Enable charging: %s", self.name) await self.tesla_device.start_charge() + self.async_write_ha_state() async def async_turn_off(self, **kwargs): """Send the off command.""" _LOGGER.debug("Disable charging for: %s", self.name) await self.tesla_device.stop_charge() + self.async_write_ha_state() @property def is_on(self): @@ -51,11 +53,13 @@ class RangeSwitch(TeslaDevice, SwitchEntity): """Send the on command.""" _LOGGER.debug("Enable max range charging: %s", self.name) await self.tesla_device.set_max() + self.async_write_ha_state() async def async_turn_off(self, **kwargs): """Send the off command.""" _LOGGER.debug("Disable max range charging: %s", self.name) await self.tesla_device.set_standard() + self.async_write_ha_state() @property def is_on(self): @@ -87,11 +91,13 @@ class UpdateSwitch(TeslaDevice, SwitchEntity): """Send the on command.""" _LOGGER.debug("Enable updates: %s %s", self.name, self.tesla_device.id()) self.controller.set_updates(self.tesla_device.id(), True) + self.async_write_ha_state() async def async_turn_off(self, **kwargs): """Send the off command.""" _LOGGER.debug("Disable updates: %s %s", self.name, self.tesla_device.id()) self.controller.set_updates(self.tesla_device.id(), False) + self.async_write_ha_state() @property def is_on(self): @@ -108,11 +114,13 @@ class SentryModeSwitch(TeslaDevice, SwitchEntity): """Send the on command.""" _LOGGER.debug("Enable sentry mode: %s", self.name) await self.tesla_device.enable_sentry_mode() + self.async_write_ha_state() async def async_turn_off(self, **kwargs): """Send the off command.""" _LOGGER.debug("Disable sentry mode: %s", self.name) await self.tesla_device.disable_sentry_mode() + self.async_write_ha_state() @property def is_on(self):