Collection of changing entity properties to class attributes (#51248)

* Collection of changing entity properties to class attributes

* Apply suggestions from code review

Co-authored-by: Erik Montnemery <erik@montnemery.com>

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Franck Nijhof
2021-05-31 10:50:11 +02:00
committed by GitHub
parent 5acc3a1083
commit 258b388f41
32 changed files with 106 additions and 305 deletions

View File

@@ -240,6 +240,8 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
class UpCloudServerEntity(CoordinatorEntity):
"""Entity class for UpCloud servers."""
_attr_device_class = DEFAULT_COMPONENT_DEVICE_CLASS
def __init__(
self,
coordinator: DataUpdateCoordinator[dict[str, upcloud_api.Server]],
@@ -284,11 +286,6 @@ class UpCloudServerEntity(CoordinatorEntity):
"""Return true if the server is on."""
return self.state == STATE_ON
@property
def device_class(self) -> str:
"""Return the class of this server."""
return DEFAULT_COMPONENT_DEVICE_CLASS
@property
def extra_state_attributes(self) -> dict[str, Any]:
"""Return the state attributes of the UpCloud server."""