mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Use shorthand attributes in Kostal Plenticore (#99581)
This commit is contained in:
parent
447a9f4aad
commit
1f648feaef
@ -745,16 +745,16 @@ class PlenticoreDataSensor(
|
|||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self.entry_id = entry_id
|
self.entry_id = entry_id
|
||||||
self.platform_name = platform_name
|
|
||||||
self.module_id = description.module_id
|
self.module_id = description.module_id
|
||||||
self.data_id = description.key
|
self.data_id = description.key
|
||||||
|
|
||||||
self._sensor_name = description.name
|
|
||||||
self._formatter: Callable[[str], Any] = PlenticoreDataFormatter.get_method(
|
self._formatter: Callable[[str], Any] = PlenticoreDataFormatter.get_method(
|
||||||
description.formatter
|
description.formatter
|
||||||
)
|
)
|
||||||
|
|
||||||
self._device_info = device_info
|
self._attr_device_info = device_info
|
||||||
|
self._attr_unique_id = f"{entry_id}_{self.module_id}_{self.data_id}"
|
||||||
|
self._attr_name = f"{platform_name} {description.name}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
@ -778,21 +778,6 @@ class PlenticoreDataSensor(
|
|||||||
self.coordinator.stop_fetch_data(self.module_id, self.data_id)
|
self.coordinator.stop_fetch_data(self.module_id, self.data_id)
|
||||||
await super().async_will_remove_from_hass()
|
await super().async_will_remove_from_hass()
|
||||||
|
|
||||||
@property
|
|
||||||
def device_info(self) -> DeviceInfo:
|
|
||||||
"""Return the device info."""
|
|
||||||
return self._device_info
|
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self) -> str:
|
|
||||||
"""Return the unique id of this Sensor Entity."""
|
|
||||||
return f"{self.entry_id}_{self.module_id}_{self.data_id}"
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self) -> str:
|
|
||||||
"""Return the name of this Sensor Entity."""
|
|
||||||
return f"{self.platform_name} {self._sensor_name}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> StateType:
|
def native_value(self) -> StateType:
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
|
@ -116,7 +116,6 @@ class PlenticoreDataSwitch(
|
|||||||
"""Create a new Switch Entity for Plenticore process data."""
|
"""Create a new Switch Entity for Plenticore process data."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self.entry_id = entry_id
|
|
||||||
self.platform_name = platform_name
|
self.platform_name = platform_name
|
||||||
self.module_id = description.module_id
|
self.module_id = description.module_id
|
||||||
self.data_id = description.key
|
self.data_id = description.key
|
||||||
@ -129,7 +128,7 @@ class PlenticoreDataSwitch(
|
|||||||
self.off_label = description.off_label
|
self.off_label = description.off_label
|
||||||
self._attr_unique_id = f"{entry_id}_{description.module_id}_{description.key}"
|
self._attr_unique_id = f"{entry_id}_{description.module_id}_{description.key}"
|
||||||
|
|
||||||
self._device_info = device_info
|
self._attr_device_info = device_info
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
@ -171,11 +170,6 @@ class PlenticoreDataSwitch(
|
|||||||
)
|
)
|
||||||
await self.coordinator.async_request_refresh()
|
await self.coordinator.async_request_refresh()
|
||||||
|
|
||||||
@property
|
|
||||||
def device_info(self) -> DeviceInfo:
|
|
||||||
"""Return the device info."""
|
|
||||||
return self._device_info
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return true if device is on."""
|
"""Return true if device is on."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user