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 commit 060843860f.

* Revert "Cleanup/typing fixes"

This reverts commit 659b79e75a.

* 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:
Franck Nijhof 2021-05-22 18:13:50 +02:00 committed by GitHub
parent b9a0fb93eb
commit 38d095aa18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 80 additions and 173 deletions

View file

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