Use shorthand attributes for Picnic (#99633)

pull/99651/head
Joost Lekkerkerker 2023-09-05 02:59:44 +02:00 committed by GitHub
parent fed1cab847
commit 49bd7e6251
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 12 deletions

View File

@ -256,9 +256,15 @@ class PicnicSensor(SensorEntity, CoordinatorEntity):
self.entity_description = description
self.entity_id = f"sensor.picnic_{description.key}"
self._service_unique_id = config_entry.unique_id
self._attr_unique_id = f"{config_entry.unique_id}.{description.key}"
self._attr_device_info = DeviceInfo(
entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, cast(str, config_entry.unique_id))},
manufacturer="Picnic",
model=config_entry.unique_id,
name=f"Picnic: {coordinator.data[ADDRESS]}",
)
@property
def native_value(self) -> StateType | datetime:
@ -269,14 +275,3 @@ class PicnicSensor(SensorEntity, CoordinatorEntity):
else {}
)
return self.entity_description.value_fn(data_set)
@property
def device_info(self) -> DeviceInfo:
"""Return device info."""
return DeviceInfo(
entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, cast(str, self._service_unique_id))},
manufacturer="Picnic",
model=self._service_unique_id,
name=f"Picnic: {self.coordinator.data[ADDRESS]}",
)