Improve volvooncall (#34495)

* Add write_ha_state to switch

* Add unique_id to voc
pull/34532/head
Fredrik Erlandsson 2020-04-22 10:10:59 +02:00 committed by GitHub
parent 6dd836589c
commit dd03fcbeb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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}"

View File

@ -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()