Use shorthand attributes in Rainforest eagle (#99825)

This commit is contained in:
Joost Lekkerkerker 2023-09-07 19:52:12 +02:00 committed by GitHub
parent 02e077daab
commit 66d16108be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,11 +75,13 @@ class EagleSensor(CoordinatorEntity[EagleDataCoordinator], SensorEntity):
"""Initialize the sensor."""
super().__init__(coordinator)
self.entity_description = entity_description
@property
def unique_id(self) -> str | None:
"""Return unique ID of entity."""
return f"{self.coordinator.cloud_id}-${self.coordinator.hardware_address}-{self.entity_description.key}"
self._attr_unique_id = f"{coordinator.cloud_id}-${coordinator.hardware_address}-{entity_description.key}"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, coordinator.cloud_id)},
manufacturer="Rainforest Automation",
model=coordinator.model,
name=coordinator.model,
)
@property
def available(self) -> bool:
@ -90,13 +92,3 @@ class EagleSensor(CoordinatorEntity[EagleDataCoordinator], SensorEntity):
def native_value(self) -> StateType:
"""Return native value of the sensor."""
return self.coordinator.data.get(self.entity_description.key)
@property
def device_info(self) -> DeviceInfo:
"""Return device info."""
return DeviceInfo(
identifiers={(DOMAIN, self.coordinator.cloud_id)},
manufacturer="Rainforest Automation",
model=self.coordinator.model,
name=self.coordinator.model,
)