Migrate Xiaomi Miio to new entity naming style - part 1 (#75350)
This commit is contained in:
parent
cd223d91bb
commit
503b31fb15
10 changed files with 103 additions and 125 deletions
|
@ -172,13 +172,13 @@ SENSOR_TYPES = {
|
|||
),
|
||||
ATTR_LOAD_POWER: XiaomiMiioSensorDescription(
|
||||
key=ATTR_LOAD_POWER,
|
||||
name="Load Power",
|
||||
name="Load power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
),
|
||||
ATTR_WATER_LEVEL: XiaomiMiioSensorDescription(
|
||||
key=ATTR_WATER_LEVEL,
|
||||
name="Water Level",
|
||||
name="Water level",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
icon="mdi:water-check",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -186,7 +186,7 @@ SENSOR_TYPES = {
|
|||
),
|
||||
ATTR_ACTUAL_SPEED: XiaomiMiioSensorDescription(
|
||||
key=ATTR_ACTUAL_SPEED,
|
||||
name="Actual Speed",
|
||||
name="Actual speed",
|
||||
native_unit_of_measurement="rpm",
|
||||
icon="mdi:fast-forward",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -194,7 +194,7 @@ SENSOR_TYPES = {
|
|||
),
|
||||
ATTR_CONTROL_SPEED: XiaomiMiioSensorDescription(
|
||||
key=ATTR_CONTROL_SPEED,
|
||||
name="Control Speed",
|
||||
name="Control speed",
|
||||
native_unit_of_measurement="rpm",
|
||||
icon="mdi:fast-forward",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -202,7 +202,7 @@ SENSOR_TYPES = {
|
|||
),
|
||||
ATTR_FAVORITE_SPEED: XiaomiMiioSensorDescription(
|
||||
key=ATTR_FAVORITE_SPEED,
|
||||
name="Favorite Speed",
|
||||
name="Favorite speed",
|
||||
native_unit_of_measurement="rpm",
|
||||
icon="mdi:fast-forward",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -210,7 +210,7 @@ SENSOR_TYPES = {
|
|||
),
|
||||
ATTR_MOTOR_SPEED: XiaomiMiioSensorDescription(
|
||||
key=ATTR_MOTOR_SPEED,
|
||||
name="Motor Speed",
|
||||
name="Motor speed",
|
||||
native_unit_of_measurement="rpm",
|
||||
icon="mdi:fast-forward",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -218,7 +218,7 @@ SENSOR_TYPES = {
|
|||
),
|
||||
ATTR_MOTOR2_SPEED: XiaomiMiioSensorDescription(
|
||||
key=ATTR_MOTOR2_SPEED,
|
||||
name="Second Motor Speed",
|
||||
name="Second motor speed",
|
||||
native_unit_of_measurement="rpm",
|
||||
icon="mdi:fast-forward",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -226,7 +226,7 @@ SENSOR_TYPES = {
|
|||
),
|
||||
ATTR_USE_TIME: XiaomiMiioSensorDescription(
|
||||
key=ATTR_USE_TIME,
|
||||
name="Use Time",
|
||||
name="Use time",
|
||||
native_unit_of_measurement=TIME_SECONDS,
|
||||
icon="mdi:progress-clock",
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -269,7 +269,7 @@ SENSOR_TYPES = {
|
|||
),
|
||||
ATTR_FILTER_LIFE_REMAINING: XiaomiMiioSensorDescription(
|
||||
key=ATTR_FILTER_LIFE_REMAINING,
|
||||
name="Filter Life Remaining",
|
||||
name="Filter life remaining",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
icon="mdi:air-filter",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -278,7 +278,7 @@ SENSOR_TYPES = {
|
|||
),
|
||||
ATTR_FILTER_USE: XiaomiMiioSensorDescription(
|
||||
key=ATTR_FILTER_HOURS_USED,
|
||||
name="Filter Use",
|
||||
name="Filter use",
|
||||
native_unit_of_measurement=TIME_HOURS,
|
||||
icon="mdi:clock-outline",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -320,14 +320,14 @@ SENSOR_TYPES = {
|
|||
),
|
||||
ATTR_CARBON_DIOXIDE: XiaomiMiioSensorDescription(
|
||||
key=ATTR_CARBON_DIOXIDE,
|
||||
name="Carbon Dioxide",
|
||||
name="Carbon dioxide",
|
||||
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
|
||||
device_class=SensorDeviceClass.CO2,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
ATTR_PURIFY_VOLUME: XiaomiMiioSensorDescription(
|
||||
key=ATTR_PURIFY_VOLUME,
|
||||
name="Purify Volume",
|
||||
name="Purify volume",
|
||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
||||
device_class=SensorDeviceClass.GAS,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -491,7 +491,7 @@ VACUUM_SENSORS = {
|
|||
f"dnd_{ATTR_DND_START}": XiaomiMiioSensorDescription(
|
||||
key=ATTR_DND_START,
|
||||
icon="mdi:minus-circle-off",
|
||||
name="DnD Start",
|
||||
name="DnD start",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
parent_key=VacuumCoordinatorDataAttributes.dnd_status,
|
||||
entity_registry_enabled_default=False,
|
||||
|
@ -500,7 +500,7 @@ VACUUM_SENSORS = {
|
|||
f"dnd_{ATTR_DND_END}": XiaomiMiioSensorDescription(
|
||||
key=ATTR_DND_END,
|
||||
icon="mdi:minus-circle-off",
|
||||
name="DnD End",
|
||||
name="DnD end",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
parent_key=VacuumCoordinatorDataAttributes.dnd_status,
|
||||
entity_registry_enabled_default=False,
|
||||
|
@ -509,7 +509,7 @@ VACUUM_SENSORS = {
|
|||
f"last_clean_{ATTR_LAST_CLEAN_START}": XiaomiMiioSensorDescription(
|
||||
key=ATTR_LAST_CLEAN_START,
|
||||
icon="mdi:clock-time-twelve",
|
||||
name="Last Clean Start",
|
||||
name="Last clean start",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
parent_key=VacuumCoordinatorDataAttributes.last_clean_details,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
|
@ -519,7 +519,7 @@ VACUUM_SENSORS = {
|
|||
icon="mdi:clock-time-twelve",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
parent_key=VacuumCoordinatorDataAttributes.last_clean_details,
|
||||
name="Last Clean End",
|
||||
name="Last clean end",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
f"last_clean_{ATTR_LAST_CLEAN_TIME}": XiaomiMiioSensorDescription(
|
||||
|
@ -527,7 +527,7 @@ VACUUM_SENSORS = {
|
|||
icon="mdi:timer-sand",
|
||||
key=ATTR_LAST_CLEAN_TIME,
|
||||
parent_key=VacuumCoordinatorDataAttributes.last_clean_details,
|
||||
name="Last Clean Duration",
|
||||
name="Last clean duration",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
f"last_clean_{ATTR_LAST_CLEAN_AREA}": XiaomiMiioSensorDescription(
|
||||
|
@ -535,7 +535,7 @@ VACUUM_SENSORS = {
|
|||
icon="mdi:texture-box",
|
||||
key=ATTR_LAST_CLEAN_AREA,
|
||||
parent_key=VacuumCoordinatorDataAttributes.last_clean_details,
|
||||
name="Last Clean Area",
|
||||
name="Last clean area",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
f"current_{ATTR_STATUS_CLEAN_TIME}": XiaomiMiioSensorDescription(
|
||||
|
@ -543,7 +543,7 @@ VACUUM_SENSORS = {
|
|||
icon="mdi:timer-sand",
|
||||
key=ATTR_STATUS_CLEAN_TIME,
|
||||
parent_key=VacuumCoordinatorDataAttributes.status,
|
||||
name="Current Clean Duration",
|
||||
name="Current clean duration",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
f"current_{ATTR_LAST_CLEAN_AREA}": XiaomiMiioSensorDescription(
|
||||
|
@ -552,7 +552,7 @@ VACUUM_SENSORS = {
|
|||
key=ATTR_STATUS_CLEAN_AREA,
|
||||
parent_key=VacuumCoordinatorDataAttributes.status,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
name="Current Clean Area",
|
||||
name="Current clean area",
|
||||
),
|
||||
f"clean_history_{ATTR_CLEAN_HISTORY_TOTAL_DURATION}": XiaomiMiioSensorDescription(
|
||||
native_unit_of_measurement=TIME_SECONDS,
|
||||
|
@ -568,7 +568,7 @@ VACUUM_SENSORS = {
|
|||
icon="mdi:texture-box",
|
||||
key=ATTR_CLEAN_HISTORY_TOTAL_AREA,
|
||||
parent_key=VacuumCoordinatorDataAttributes.clean_history_status,
|
||||
name="Total Clean Area",
|
||||
name="Total clean area",
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
|
@ -578,17 +578,17 @@ VACUUM_SENSORS = {
|
|||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
key=ATTR_CLEAN_HISTORY_COUNT,
|
||||
parent_key=VacuumCoordinatorDataAttributes.clean_history_status,
|
||||
name="Total Clean Count",
|
||||
name="Total clean count",
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
f"clean_history_{ATTR_CLEAN_HISTORY_DUST_COLLECTION_COUNT}": XiaomiMiioSensorDescription(
|
||||
native_unit_of_measurement="",
|
||||
icon="mdi:counter",
|
||||
state_class="total_increasing",
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
key=ATTR_CLEAN_HISTORY_DUST_COLLECTION_COUNT,
|
||||
parent_key=VacuumCoordinatorDataAttributes.clean_history_status,
|
||||
name="Total Dust Collection Count",
|
||||
name="Total dust collection count",
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
|
@ -597,7 +597,7 @@ VACUUM_SENSORS = {
|
|||
icon="mdi:brush",
|
||||
key=ATTR_CONSUMABLE_STATUS_MAIN_BRUSH_LEFT,
|
||||
parent_key=VacuumCoordinatorDataAttributes.consumable_status,
|
||||
name="Main Brush Left",
|
||||
name="Main brush left",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
f"consumable_{ATTR_CONSUMABLE_STATUS_SIDE_BRUSH_LEFT}": XiaomiMiioSensorDescription(
|
||||
|
@ -605,7 +605,7 @@ VACUUM_SENSORS = {
|
|||
icon="mdi:brush",
|
||||
key=ATTR_CONSUMABLE_STATUS_SIDE_BRUSH_LEFT,
|
||||
parent_key=VacuumCoordinatorDataAttributes.consumable_status,
|
||||
name="Side Brush Left",
|
||||
name="Side brush left",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
f"consumable_{ATTR_CONSUMABLE_STATUS_FILTER_LEFT}": XiaomiMiioSensorDescription(
|
||||
|
@ -613,7 +613,7 @@ VACUUM_SENSORS = {
|
|||
icon="mdi:air-filter",
|
||||
key=ATTR_CONSUMABLE_STATUS_FILTER_LEFT,
|
||||
parent_key=VacuumCoordinatorDataAttributes.consumable_status,
|
||||
name="Filter Left",
|
||||
name="Filter left",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
f"consumable_{ATTR_CONSUMABLE_STATUS_SENSOR_DIRTY_LEFT}": XiaomiMiioSensorDescription(
|
||||
|
@ -621,7 +621,7 @@ VACUUM_SENSORS = {
|
|||
icon="mdi:eye-outline",
|
||||
key=ATTR_CONSUMABLE_STATUS_SENSOR_DIRTY_LEFT,
|
||||
parent_key=VacuumCoordinatorDataAttributes.consumable_status,
|
||||
name="Sensor Dirty Left",
|
||||
name="Sensor dirty left",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
}
|
||||
|
@ -644,7 +644,6 @@ def _setup_vacuum_sensors(hass, config_entry, async_add_entities):
|
|||
continue
|
||||
entities.append(
|
||||
XiaomiGenericSensor(
|
||||
f"{config_entry.title} {description.name}",
|
||||
device,
|
||||
config_entry,
|
||||
f"{sensor}_{config_entry.unique_id}",
|
||||
|
@ -741,7 +740,6 @@ async def async_setup_entry(
|
|||
continue
|
||||
entities.append(
|
||||
XiaomiGenericSensor(
|
||||
f"{config_entry.title} {description.name}",
|
||||
device,
|
||||
config_entry,
|
||||
f"{sensor}_{config_entry.unique_id}",
|
||||
|
@ -758,9 +756,9 @@ class XiaomiGenericSensor(XiaomiCoordinatedMiioEntity, SensorEntity):
|
|||
|
||||
entity_description: XiaomiMiioSensorDescription
|
||||
|
||||
def __init__(self, name, device, entry, unique_id, coordinator, description):
|
||||
def __init__(self, device, entry, unique_id, coordinator, description):
|
||||
"""Initialize the entity."""
|
||||
super().__init__(name, device, entry, unique_id, coordinator)
|
||||
super().__init__(device, entry, unique_id, coordinator)
|
||||
self.entity_description = description
|
||||
self._attr_unique_id = unique_id
|
||||
self._attr_native_value = self._determine_native_value()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue