Add entity translations to Nexia (#98803)
This commit is contained in:
parent
09efd1c972
commit
097c7fbfef
11 changed files with 90 additions and 45 deletions
|
@ -23,7 +23,7 @@ async def async_setup_entry(
|
|||
thermostat = nexia_home.get_thermostat_by_id(thermostat_id)
|
||||
entities.append(
|
||||
NexiaBinarySensor(
|
||||
coordinator, thermostat, "is_blower_active", "Blower Active"
|
||||
coordinator, thermostat, "is_blower_active", "blower_active"
|
||||
)
|
||||
)
|
||||
if thermostat.has_emergency_heat():
|
||||
|
@ -32,7 +32,7 @@ async def async_setup_entry(
|
|||
coordinator,
|
||||
thermostat,
|
||||
"is_emergency_heat_active",
|
||||
"Emergency Heat Active",
|
||||
"emergency_heat_active",
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -42,16 +42,16 @@ async def async_setup_entry(
|
|||
class NexiaBinarySensor(NexiaThermostatEntity, BinarySensorEntity):
|
||||
"""Provices Nexia BinarySensor support."""
|
||||
|
||||
def __init__(self, coordinator, thermostat, sensor_call, sensor_name):
|
||||
def __init__(self, coordinator, thermostat, sensor_call, translation_key):
|
||||
"""Initialize the nexia sensor."""
|
||||
super().__init__(
|
||||
coordinator,
|
||||
thermostat,
|
||||
name=f"{thermostat.get_name()} {sensor_name}",
|
||||
unique_id=f"{thermostat.thermostat_id}_{sensor_call}",
|
||||
)
|
||||
self._call = sensor_call
|
||||
self._state = None
|
||||
self._attr_translation_key = translation_key
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
|
|
@ -150,13 +150,13 @@ async def async_setup_entry(
|
|||
class NexiaZone(NexiaThermostatZoneEntity, ClimateEntity):
|
||||
"""Provides Nexia Climate support."""
|
||||
|
||||
_attr_name = None
|
||||
|
||||
def __init__(
|
||||
self, coordinator: NexiaDataUpdateCoordinator, zone: NexiaThermostatZone
|
||||
) -> None:
|
||||
"""Initialize the thermostat."""
|
||||
super().__init__(
|
||||
coordinator, zone, name=zone.get_name(), unique_id=zone.zone_id
|
||||
)
|
||||
super().__init__(coordinator, zone, zone.zone_id)
|
||||
unit = self._thermostat.get_unit()
|
||||
min_humidity, max_humidity = self._thermostat.get_humidity_setpoint_limits()
|
||||
min_setpoint, max_setpoint = self._thermostat.get_setpoint_limits()
|
||||
|
|
|
@ -31,21 +31,20 @@ class NexiaEntity(CoordinatorEntity[NexiaDataUpdateCoordinator]):
|
|||
|
||||
_attr_attribution = ATTRIBUTION
|
||||
|
||||
def __init__(
|
||||
self, coordinator: NexiaDataUpdateCoordinator, name: str, unique_id: str
|
||||
) -> None:
|
||||
def __init__(self, coordinator: NexiaDataUpdateCoordinator, unique_id: str) -> None:
|
||||
"""Initialize the entity."""
|
||||
super().__init__(coordinator)
|
||||
self._attr_unique_id = unique_id
|
||||
self._attr_name = name
|
||||
|
||||
|
||||
class NexiaThermostatEntity(NexiaEntity):
|
||||
"""Base class for nexia devices attached to a thermostat."""
|
||||
|
||||
def __init__(self, coordinator, thermostat, name, unique_id):
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(self, coordinator, thermostat, unique_id):
|
||||
"""Initialize the entity."""
|
||||
super().__init__(coordinator, name, unique_id)
|
||||
super().__init__(coordinator, unique_id)
|
||||
self._thermostat: NexiaThermostat = thermostat
|
||||
self._attr_device_info = DeviceInfo(
|
||||
configuration_url=self.coordinator.nexia_home.root_url,
|
||||
|
@ -89,9 +88,9 @@ class NexiaThermostatEntity(NexiaEntity):
|
|||
class NexiaThermostatZoneEntity(NexiaThermostatEntity):
|
||||
"""Base class for nexia devices attached to a thermostat."""
|
||||
|
||||
def __init__(self, coordinator, zone, name, unique_id):
|
||||
def __init__(self, coordinator, zone, unique_id):
|
||||
"""Initialize the entity."""
|
||||
super().__init__(coordinator, zone.thermostat, name, unique_id)
|
||||
super().__init__(coordinator, zone.thermostat, unique_id)
|
||||
self._zone: NexiaThermostatZone = zone
|
||||
zone_name = self._zone.get_name()
|
||||
self._attr_device_info |= {
|
||||
|
|
|
@ -42,6 +42,7 @@ class NexiaFanSpeedEntity(NexiaThermostatEntity, NumberEntity):
|
|||
|
||||
_attr_native_unit_of_measurement = PERCENTAGE
|
||||
_attr_icon = "mdi:fan"
|
||||
_attr_translation_key = "fan_speed"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -53,7 +54,6 @@ class NexiaFanSpeedEntity(NexiaThermostatEntity, NumberEntity):
|
|||
super().__init__(
|
||||
coordinator,
|
||||
thermostat,
|
||||
name=f"{thermostat.get_name()} Fan speed",
|
||||
unique_id=f"{thermostat.thermostat_id}_fan_speed_setpoint",
|
||||
)
|
||||
min_value, max_value = valid_range
|
||||
|
|
|
@ -43,9 +43,9 @@ class NexiaAutomationScene(NexiaEntity, Scene):
|
|||
"""Initialize the automation scene."""
|
||||
super().__init__(
|
||||
coordinator,
|
||||
name=automation.name,
|
||||
unique_id=automation.automation_id,
|
||||
automation.automation_id,
|
||||
)
|
||||
self._attr_name = automation.name
|
||||
self._automation: NexiaAutomation = automation
|
||||
self._attr_extra_state_attributes = {ATTR_DESCRIPTION: automation.description}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ async def async_setup_entry(
|
|||
coordinator,
|
||||
thermostat,
|
||||
"get_system_status",
|
||||
"System Status",
|
||||
"system_status",
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
|
@ -52,7 +52,7 @@ async def async_setup_entry(
|
|||
coordinator,
|
||||
thermostat,
|
||||
"get_air_cleaner_mode",
|
||||
"Air Cleaner Mode",
|
||||
"air_cleaner_mode",
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
|
@ -65,7 +65,7 @@ async def async_setup_entry(
|
|||
coordinator,
|
||||
thermostat,
|
||||
"get_current_compressor_speed",
|
||||
"Current Compressor Speed",
|
||||
"current_compressor_speed",
|
||||
None,
|
||||
PERCENTAGE,
|
||||
SensorStateClass.MEASUREMENT,
|
||||
|
@ -77,7 +77,7 @@ async def async_setup_entry(
|
|||
coordinator,
|
||||
thermostat,
|
||||
"get_requested_compressor_speed",
|
||||
"Requested Compressor Speed",
|
||||
"requested_compressor_speed",
|
||||
None,
|
||||
PERCENTAGE,
|
||||
SensorStateClass.MEASUREMENT,
|
||||
|
@ -95,7 +95,7 @@ async def async_setup_entry(
|
|||
coordinator,
|
||||
thermostat,
|
||||
"get_outdoor_temperature",
|
||||
"Outdoor Temperature",
|
||||
"outdoor_temperature",
|
||||
SensorDeviceClass.TEMPERATURE,
|
||||
unit,
|
||||
SensorStateClass.MEASUREMENT,
|
||||
|
@ -108,7 +108,7 @@ async def async_setup_entry(
|
|||
coordinator,
|
||||
thermostat,
|
||||
"get_relative_humidity",
|
||||
"Relative Humidity",
|
||||
None,
|
||||
SensorDeviceClass.HUMIDITY,
|
||||
PERCENTAGE,
|
||||
SensorStateClass.MEASUREMENT,
|
||||
|
@ -129,7 +129,7 @@ async def async_setup_entry(
|
|||
coordinator,
|
||||
zone,
|
||||
"get_temperature",
|
||||
"Temperature",
|
||||
None,
|
||||
SensorDeviceClass.TEMPERATURE,
|
||||
unit,
|
||||
SensorStateClass.MEASUREMENT,
|
||||
|
@ -139,7 +139,7 @@ async def async_setup_entry(
|
|||
# Zone Status
|
||||
entities.append(
|
||||
NexiaThermostatZoneSensor(
|
||||
coordinator, zone, "get_status", "Zone Status", None, None, None
|
||||
coordinator, zone, "get_status", "zone_status", None, None, None
|
||||
)
|
||||
)
|
||||
# Setpoint Status
|
||||
|
@ -148,7 +148,7 @@ async def async_setup_entry(
|
|||
coordinator,
|
||||
zone,
|
||||
"get_setpoint_status",
|
||||
"Zone Setpoint Status",
|
||||
"zone_setpoint_status",
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
|
@ -166,7 +166,7 @@ class NexiaThermostatSensor(NexiaThermostatEntity, SensorEntity):
|
|||
coordinator,
|
||||
thermostat,
|
||||
sensor_call,
|
||||
sensor_name,
|
||||
translation_key,
|
||||
sensor_class,
|
||||
sensor_unit,
|
||||
state_class,
|
||||
|
@ -176,7 +176,6 @@ class NexiaThermostatSensor(NexiaThermostatEntity, SensorEntity):
|
|||
super().__init__(
|
||||
coordinator,
|
||||
thermostat,
|
||||
name=f"{thermostat.get_name()} {sensor_name}",
|
||||
unique_id=f"{thermostat.thermostat_id}_{sensor_call}",
|
||||
)
|
||||
self._call = sensor_call
|
||||
|
@ -184,6 +183,8 @@ class NexiaThermostatSensor(NexiaThermostatEntity, SensorEntity):
|
|||
self._attr_device_class = sensor_class
|
||||
self._attr_native_unit_of_measurement = sensor_unit
|
||||
self._attr_state_class = state_class
|
||||
if translation_key is not None:
|
||||
self._attr_translation_key = translation_key
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
|
@ -204,7 +205,7 @@ class NexiaThermostatZoneSensor(NexiaThermostatZoneEntity, SensorEntity):
|
|||
coordinator,
|
||||
zone,
|
||||
sensor_call,
|
||||
sensor_name,
|
||||
translation_key,
|
||||
sensor_class,
|
||||
sensor_unit,
|
||||
state_class,
|
||||
|
@ -215,7 +216,6 @@ class NexiaThermostatZoneSensor(NexiaThermostatZoneEntity, SensorEntity):
|
|||
super().__init__(
|
||||
coordinator,
|
||||
zone,
|
||||
name=f"{zone.get_name()} {sensor_name}",
|
||||
unique_id=f"{zone.zone_id}_{sensor_call}",
|
||||
)
|
||||
self._call = sensor_call
|
||||
|
@ -223,6 +223,8 @@ class NexiaThermostatZoneSensor(NexiaThermostatZoneEntity, SensorEntity):
|
|||
self._attr_device_class = sensor_class
|
||||
self._attr_native_unit_of_measurement = sensor_unit
|
||||
self._attr_state_class = state_class
|
||||
if translation_key is not None:
|
||||
self._attr_translation_key = translation_key
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
|
|
|
@ -18,6 +18,49 @@
|
|||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"blower_active": {
|
||||
"name": "Blower active"
|
||||
},
|
||||
"emergency_heat_active": {
|
||||
"name": "Emergency heat active"
|
||||
}
|
||||
},
|
||||
"number": {
|
||||
"fan_speed": {
|
||||
"name": "Fan speed"
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
"system_status": {
|
||||
"name": "System status"
|
||||
},
|
||||
"air_cleaner_mode": {
|
||||
"name": "Air cleaner mode"
|
||||
},
|
||||
"current_compressor_speed": {
|
||||
"name": "Current compressor speed"
|
||||
},
|
||||
"requested_compressor_speed": {
|
||||
"name": "Requested compressor speed"
|
||||
},
|
||||
"outdoor_temperature": {
|
||||
"name": "Outdoor temperature"
|
||||
},
|
||||
"zone_status": {
|
||||
"name": "Zone status"
|
||||
},
|
||||
"zone_setpoint_status": {
|
||||
"name": "Zone setpoint status"
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
"hold": {
|
||||
"name": "Hold"
|
||||
}
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
"set_aircleaner_mode": {
|
||||
"name": "Set air cleaner mode",
|
||||
|
|
|
@ -39,13 +39,14 @@ async def async_setup_entry(
|
|||
class NexiaHoldSwitch(NexiaThermostatZoneEntity, SwitchEntity):
|
||||
"""Provides Nexia hold switch support."""
|
||||
|
||||
_attr_translation_key = "hold"
|
||||
|
||||
def __init__(
|
||||
self, coordinator: NexiaDataUpdateCoordinator, zone: NexiaThermostatZone
|
||||
) -> None:
|
||||
"""Initialize the hold mode switch."""
|
||||
switch_name = f"{zone.get_name()} Hold"
|
||||
zone_id = zone.zone_id
|
||||
super().__init__(coordinator, zone, name=switch_name, unique_id=zone_id)
|
||||
super().__init__(coordinator, zone, zone_id)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
|
|
|
@ -14,7 +14,7 @@ async def test_create_binary_sensors(hass: HomeAssistant) -> None:
|
|||
assert state.state == STATE_ON
|
||||
expected_attributes = {
|
||||
"attribution": "Data provided by Trane Technologies",
|
||||
"friendly_name": "Master Suite Blower Active",
|
||||
"friendly_name": "Master Suite Blower active",
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
|
@ -26,7 +26,7 @@ async def test_create_binary_sensors(hass: HomeAssistant) -> None:
|
|||
assert state.state == STATE_OFF
|
||||
expected_attributes = {
|
||||
"attribution": "Data provided by Trane Technologies",
|
||||
"friendly_name": "Downstairs East Wing Blower Active",
|
||||
"friendly_name": "Downstairs East Wing Blower active",
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
|
|
|
@ -53,7 +53,7 @@ async def test_device_remove_devices(
|
|||
is False
|
||||
)
|
||||
|
||||
entity = registry.entities["sensor.master_suite_relative_humidity"]
|
||||
entity = registry.entities["sensor.master_suite_humidity"]
|
||||
live_thermostat_device_entry = device_registry.async_get(entity.device_id)
|
||||
assert (
|
||||
await remove_device(
|
||||
|
|
|
@ -29,7 +29,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||
assert state.state == "Permanent Hold"
|
||||
expected_attributes = {
|
||||
"attribution": "Data provided by Trane Technologies",
|
||||
"friendly_name": "Nick Office Zone Setpoint Status",
|
||||
"friendly_name": "Nick Office Zone setpoint status",
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
|
@ -42,7 +42,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||
|
||||
expected_attributes = {
|
||||
"attribution": "Data provided by Trane Technologies",
|
||||
"friendly_name": "Nick Office Zone Status",
|
||||
"friendly_name": "Nick Office Zone status",
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
|
@ -55,7 +55,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||
|
||||
expected_attributes = {
|
||||
"attribution": "Data provided by Trane Technologies",
|
||||
"friendly_name": "Master Suite Air Cleaner Mode",
|
||||
"friendly_name": "Master Suite Air cleaner mode",
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
|
@ -68,7 +68,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||
|
||||
expected_attributes = {
|
||||
"attribution": "Data provided by Trane Technologies",
|
||||
"friendly_name": "Master Suite Current Compressor Speed",
|
||||
"friendly_name": "Master Suite Current compressor speed",
|
||||
"unit_of_measurement": PERCENTAGE,
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
|
@ -83,7 +83,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||
expected_attributes = {
|
||||
"attribution": "Data provided by Trane Technologies",
|
||||
"device_class": "temperature",
|
||||
"friendly_name": "Master Suite Outdoor Temperature",
|
||||
"friendly_name": "Master Suite Outdoor temperature",
|
||||
"unit_of_measurement": UnitOfTemperature.CELSIUS,
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
|
@ -92,13 +92,13 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
||||
)
|
||||
|
||||
state = hass.states.get("sensor.master_suite_relative_humidity")
|
||||
state = hass.states.get("sensor.master_suite_humidity")
|
||||
assert state.state == "52.0"
|
||||
|
||||
expected_attributes = {
|
||||
"attribution": "Data provided by Trane Technologies",
|
||||
"device_class": "humidity",
|
||||
"friendly_name": "Master Suite Relative Humidity",
|
||||
"friendly_name": "Master Suite Humidity",
|
||||
"unit_of_measurement": PERCENTAGE,
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
|
@ -112,7 +112,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||
|
||||
expected_attributes = {
|
||||
"attribution": "Data provided by Trane Technologies",
|
||||
"friendly_name": "Master Suite Requested Compressor Speed",
|
||||
"friendly_name": "Master Suite Requested compressor speed",
|
||||
"unit_of_measurement": PERCENTAGE,
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
|
@ -126,7 +126,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||
|
||||
expected_attributes = {
|
||||
"attribution": "Data provided by Trane Technologies",
|
||||
"friendly_name": "Master Suite System Status",
|
||||
"friendly_name": "Master Suite System status",
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue