Add entity categorisation to AVM Fritz!Smarthome devices (#59287)

This commit is contained in:
Michael 2021-11-14 17:05:18 +01:00 committed by GitHub
parent 5ec4a502b0
commit d5f85f393d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,6 +21,7 @@ from homeassistant.const import (
DEVICE_CLASS_POWER, DEVICE_CLASS_POWER,
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TEMPERATURE,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
ENTITY_CATEGORY_DIAGNOSTIC,
PERCENTAGE, PERCENTAGE,
POWER_WATT, POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
@ -54,6 +55,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT, state_class=STATE_CLASS_MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
suitable=lambda device: ( suitable=lambda device: (
device.has_temperature_sensor and not device.has_thermostat device.has_temperature_sensor and not device.has_thermostat
), ),
@ -73,6 +75,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
name="Battery", name="Battery",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
device_class=DEVICE_CLASS_BATTERY, device_class=DEVICE_CLASS_BATTERY,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
suitable=lambda device: device.battery_level is not None, suitable=lambda device: device.battery_level is not None,
native_value=lambda device: device.battery_level, # type: ignore[no-any-return] native_value=lambda device: device.battery_level, # type: ignore[no-any-return]
), ),