Add new sensors to Mill (#130896)

* Mill sensors

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>

* Update homeassistant/components/mill/sensor.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Update homeassistant/components/mill/sensor.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Update const.py

* Update sensor.py

---------

Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
Daniel Hjelseth Høyer 2024-11-19 08:30:41 +01:00 committed by GitHub
parent 4836f4af2b
commit f9a0cc5c31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -57,6 +57,19 @@ HEATER_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
SensorEntityDescription(
key="current_power",
translation_key="current_power",
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="control_signal",
translation_key="control_signal",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
) )
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
@ -118,6 +131,16 @@ LOCAL_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
), ),
) )
SOCKET_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key=HUMIDITY,
device_class=SensorDeviceClass.HUMIDITY,
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
*HEATER_SENSOR_TYPES,
)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
@ -145,7 +168,9 @@ async def async_setup_entry(
) )
for mill_device in mill_data_coordinator.data.values() for mill_device in mill_data_coordinator.data.values()
for entity_description in ( for entity_description in (
HEATER_SENSOR_TYPES SOCKET_SENSOR_TYPES
if isinstance(mill_device, mill.Socket)
else HEATER_SENSOR_TYPES
if isinstance(mill_device, mill.Heater) if isinstance(mill_device, mill.Heater)
else SENSOR_TYPES else SENSOR_TYPES
) )