Migrate Tolo to entity name (#96244)

This commit is contained in:
Joost Lekkerkerker 2023-07-22 17:39:11 +02:00 committed by GitHub
parent a8d77cc5ad
commit d4f301f4a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 68 additions and 15 deletions

View File

@ -95,6 +95,8 @@ class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]):
class ToloSaunaCoordinatorEntity(CoordinatorEntity[ToloSaunaUpdateCoordinator]):
"""CoordinatorEntity for TOLO Sauna."""
_attr_has_entity_name = True
def __init__(
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry
) -> None:

View File

@ -32,7 +32,7 @@ class ToloFlowInBinarySensor(ToloSaunaCoordinatorEntity, BinarySensorEntity):
"""Water In Valve Sensor."""
_attr_entity_category = EntityCategory.DIAGNOSTIC
_attr_name = "Water In Valve"
_attr_translation_key = "water_in_valve"
_attr_device_class = BinarySensorDeviceClass.OPENING
_attr_icon = "mdi:water-plus-outline"
@ -54,7 +54,7 @@ class ToloFlowOutBinarySensor(ToloSaunaCoordinatorEntity, BinarySensorEntity):
"""Water Out Valve Sensor."""
_attr_entity_category = EntityCategory.DIAGNOSTIC
_attr_name = "Water Out Valve"
_attr_translation_key = "water_out_valve"
_attr_device_class = BinarySensorDeviceClass.OPENING
_attr_icon = "mdi:water-minus-outline"

View File

@ -31,7 +31,7 @@ class ToloLampNextColorButton(ToloSaunaCoordinatorEntity, ButtonEntity):
_attr_entity_category = EntityCategory.CONFIG
_attr_icon = "mdi:palette"
_attr_name = "Next Color"
_attr_translation_key = "next_color"
def __init__(
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry

View File

@ -47,7 +47,7 @@ class SaunaClimate(ToloSaunaCoordinatorEntity, ClimateEntity):
_attr_max_temp = DEFAULT_MAX_TEMP
_attr_min_humidity = DEFAULT_MIN_HUMIDITY
_attr_min_temp = DEFAULT_MIN_TEMP
_attr_name = "Sauna Climate"
_attr_name = None
_attr_precision = PRECISION_WHOLE
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE

View File

@ -26,7 +26,7 @@ async def async_setup_entry(
class ToloFan(ToloSaunaCoordinatorEntity, FanEntity):
"""Sauna fan control."""
_attr_name = "Fan"
_attr_translation_key = "fan"
def __init__(
self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry

View File

@ -26,7 +26,7 @@ class ToloLight(ToloSaunaCoordinatorEntity, LightEntity):
"""Sauna light control."""
_attr_color_mode = ColorMode.ONOFF
_attr_name = "Sauna Light"
_attr_translation_key = "light"
_attr_supported_color_modes = {ColorMode.ONOFF}
def __init__(

View File

@ -40,8 +40,8 @@ class ToloNumberEntityDescription(
NUMBERS = (
ToloNumberEntityDescription(
key="power_timer",
translation_key="power_timer",
icon="mdi:power-settings",
name="Power Timer",
native_unit_of_measurement=UnitOfTime.MINUTES,
native_max_value=POWER_TIMER_MAX,
getter=lambda settings: settings.power_timer,
@ -49,8 +49,8 @@ NUMBERS = (
),
ToloNumberEntityDescription(
key="salt_bath_timer",
translation_key="salt_bath_timer",
icon="mdi:shaker-outline",
name="Salt Bath Timer",
native_unit_of_measurement=UnitOfTime.MINUTES,
native_max_value=SALT_BATH_TIMER_MAX,
getter=lambda settings: settings.salt_bath_timer,
@ -58,8 +58,8 @@ NUMBERS = (
),
ToloNumberEntityDescription(
key="fan_timer",
translation_key="fan_timer",
icon="mdi:fan-auto",
name="Fan Timer",
native_unit_of_measurement=UnitOfTime.MINUTES,
native_max_value=FAN_TIMER_MAX,
getter=lambda settings: settings.fan_timer,

View File

@ -29,7 +29,6 @@ class ToloLampModeSelect(ToloSaunaCoordinatorEntity, SelectEntity):
_attr_entity_category = EntityCategory.CONFIG
_attr_icon = "mdi:lightbulb-multiple-outline"
_attr_name = "Lamp Mode"
_attr_options = [lamp_mode.name.lower() for lamp_mode in LampMode]
_attr_translation_key = "lamp_mode"

View File

@ -46,27 +46,27 @@ class ToloSensorEntityDescription(
SENSORS = (
ToloSensorEntityDescription(
key="water_level",
translation_key="water_level",
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:waves-arrow-up",
name="Water Level",
native_unit_of_measurement=PERCENTAGE,
getter=lambda status: status.water_level_percent,
availability_checker=None,
),
ToloSensorEntityDescription(
key="tank_temperature",
translation_key="tank_temperature",
device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC,
name="Tank Temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
getter=lambda status: status.tank_temperature,
availability_checker=None,
),
ToloSensorEntityDescription(
key="power_timer_remaining",
translation_key="power_timer_remaining",
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:power-settings",
name="Power Timer",
native_unit_of_measurement=UnitOfTime.MINUTES,
getter=lambda status: status.power_timer,
availability_checker=lambda settings, status: status.power_on
@ -74,9 +74,9 @@ SENSORS = (
),
ToloSensorEntityDescription(
key="salt_bath_timer_remaining",
translation_key="salt_bath_timer_remaining",
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:shaker-outline",
name="Salt Bath Timer",
native_unit_of_measurement=UnitOfTime.MINUTES,
getter=lambda status: status.salt_bath_timer,
availability_checker=lambda settings, status: status.salt_bath_on
@ -84,9 +84,9 @@ SENSORS = (
),
ToloSensorEntityDescription(
key="fan_timer_remaining",
translation_key="fan_timer_remaining",
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:fan-auto",
name="Fan Timer",
native_unit_of_measurement=UnitOfTime.MINUTES,
getter=lambda status: status.fan_timer,
availability_checker=lambda settings, status: status.fan_on

View File

@ -20,13 +20,65 @@
}
},
"entity": {
"binary_sensor": {
"water_in_valve": {
"name": "Water in valve"
},
"water_out_valve": {
"name": "Water out valve"
}
},
"button": {
"next_color": {
"name": "Next color"
}
},
"fan": {
"fan": {
"name": "[%key:component::fan::title%]"
}
},
"light": {
"light": {
"name": "[%key:component::light::title%]"
}
},
"number": {
"power_timer": {
"name": "Power timer"
},
"salt_bath_timer": {
"name": "Salt bath timer"
},
"fan_timer": {
"name": "Fan timer"
}
},
"select": {
"lamp_mode": {
"name": "Lamp mode",
"state": {
"automatic": "Automatic",
"manual": "Manual"
}
}
},
"sensor": {
"water_level": {
"name": "Water level"
},
"tank_temperature": {
"name": "Tank temperature"
},
"power_timer_remaining": {
"name": "Power timer"
},
"salt_bath_timer_remaining": {
"name": "Salt bath timer"
},
"fan_timer_remaining": {
"name": "Fan timer"
}
}
}
}