From dd03fcbeb37af0f3a70638a3acf5c2f6949894bb Mon Sep 17 00:00:00 2001 From: Fredrik Erlandsson Date: Wed, 22 Apr 2020 10:10:59 +0200 Subject: [PATCH] Improve volvooncall (#34495) * Add write_ha_state to switch * Add unique_id to voc --- homeassistant/components/volvooncall/__init__.py | 5 +++++ homeassistant/components/volvooncall/switch.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/homeassistant/components/volvooncall/__init__.py b/homeassistant/components/volvooncall/__init__.py index c408080524e..232ecf477f7 100644 --- a/homeassistant/components/volvooncall/__init__.py +++ b/homeassistant/components/volvooncall/__init__.py @@ -281,3 +281,8 @@ class VolvoEntity(Entity): self.instrument.attributes, model=f"{self.vehicle.vehicle_type}/{self.vehicle.model_year}", ) + + @property + def unique_id(self) -> str: + """Return a unique ID.""" + return f"{self.vin}-{self.component}-{self.attribute}" diff --git a/homeassistant/components/volvooncall/switch.py b/homeassistant/components/volvooncall/switch.py index 5beea91c7e3..da0f61c1d8f 100644 --- a/homeassistant/components/volvooncall/switch.py +++ b/homeassistant/components/volvooncall/switch.py @@ -26,7 +26,9 @@ class VolvoSwitch(VolvoEntity, ToggleEntity): async def async_turn_on(self, **kwargs): """Turn the switch on.""" await self.instrument.turn_on() + self.async_write_ha_state() async def async_turn_off(self, **kwargs): """Turn the switch off.""" await self.instrument.turn_off() + self.async_write_ha_state()