Add entity name translations to sun (#90732)

This commit is contained in:
Michael 2023-04-03 21:15:44 +02:00 committed by Paulus Schoutsen
parent 8f9868024c
commit da1e5f6a3c
2 changed files with 21 additions and 8 deletions

View File

@ -42,48 +42,48 @@ SENSOR_TYPES: tuple[SunSensorEntityDescription, ...] = (
SunSensorEntityDescription(
key="next_dawn",
device_class=SensorDeviceClass.TIMESTAMP,
name="Next dawn",
translation_key="next_dawn",
icon="mdi:sun-clock",
value_fn=lambda data: data.next_dawn,
),
SunSensorEntityDescription(
key="next_dusk",
device_class=SensorDeviceClass.TIMESTAMP,
name="Next dusk",
translation_key="next_dusk",
icon="mdi:sun-clock",
value_fn=lambda data: data.next_dusk,
),
SunSensorEntityDescription(
key="next_midnight",
device_class=SensorDeviceClass.TIMESTAMP,
name="Next midnight",
translation_key="next_midnight",
icon="mdi:sun-clock",
value_fn=lambda data: data.next_midnight,
),
SunSensorEntityDescription(
key="next_noon",
device_class=SensorDeviceClass.TIMESTAMP,
name="Next noon",
translation_key="next_noon",
icon="mdi:sun-clock",
value_fn=lambda data: data.next_noon,
),
SunSensorEntityDescription(
key="next_rising",
device_class=SensorDeviceClass.TIMESTAMP,
name="Next rising",
translation_key="next_rising",
icon="mdi:sun-clock",
value_fn=lambda data: data.next_rising,
),
SunSensorEntityDescription(
key="next_setting",
device_class=SensorDeviceClass.TIMESTAMP,
name="Next setting",
translation_key="next_setting",
icon="mdi:sun-clock",
value_fn=lambda data: data.next_setting,
),
SunSensorEntityDescription(
key="solar_elevation",
name="Solar elevation",
translation_key="solar_elevation",
icon="mdi:theme-light-dark",
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda data: data.solar_elevation,
@ -92,7 +92,7 @@ SENSOR_TYPES: tuple[SunSensorEntityDescription, ...] = (
),
SunSensorEntityDescription(
key="solar_azimuth",
name="Solar azimuth",
translation_key="solar_azimuth",
icon="mdi:sun-angle",
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda data: data.solar_azimuth,
@ -117,6 +117,7 @@ async def async_setup_entry(
class SunSensor(SensorEntity):
"""Representation of a Sun Sensor."""
_attr_has_entity_name = True
entity_description: SunSensorEntityDescription
def __init__(

View File

@ -18,5 +18,17 @@
"below_horizon": "Below horizon"
}
}
},
"entity": {
"sensor": {
"next_dawn": { "name": "Next dawn" },
"next_dusk": { "name": "Next dusk" },
"next_midnight": { "name": "Next midnight" },
"next_noon": { "name": "Next noon" },
"next_rising": { "name": "Next rising" },
"next_setting": { "name": "Next setting" },
"solar_azimuth": { "name": "Solar azimuth" },
"solar_elevation": { "name": "Solar elevation" }
}
}
}