Define entity attributes as entity class variables (#50925)
* Define entity attributes as entity class variables * Example coronavirus integration * Example verisure * Cleanup/typing fixes * Fix Coronavirus * Revert "Fix Coronavirus" This reverts commit060843860f
. * Revert "Cleanup/typing fixes" This reverts commit659b79e75a
. * Define entity attributes as entity class variables (attr alternative) * Example coronavirus * Example nut * Example verisure * Mark private * Cleanup after all reverting/cherrypicking/merging * Implement all entity properties * Update coronavirus example * Update nut example * Update verisure example * Lets not talk about this one... * Fix multiple class attribute
This commit is contained in:
parent
b9a0fb93eb
commit
38d095aa18
9 changed files with 80 additions and 173 deletions
|
@ -37,20 +37,14 @@ class VerisureSmartplug(CoordinatorEntity, SwitchEntity):
|
|||
) -> None:
|
||||
"""Initialize the Verisure device."""
|
||||
super().__init__(coordinator)
|
||||
|
||||
self._attr_name = coordinator.data["smart_plugs"][serial_number]["area"]
|
||||
self._attr_unique_id = serial_number
|
||||
|
||||
self.serial_number = serial_number
|
||||
self._change_timestamp = 0
|
||||
self._state = False
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of this entity."""
|
||||
return self.coordinator.data["smart_plugs"][self.serial_number]["area"]
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return the unique ID for this entity."""
|
||||
return self.serial_number
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information about this entity."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue