Add entity translations to PECO (#98847)

This commit is contained in:
Joost Lekkerkerker 2023-08-22 23:10:02 +02:00 committed by GitHub
parent 2ff5d6290f
commit e9af99e469
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 5 deletions

View file

@ -43,7 +43,7 @@ PARALLEL_UPDATES: Final = 0
SENSOR_LIST: tuple[PECOSensorEntityDescription, ...] = ( SENSOR_LIST: tuple[PECOSensorEntityDescription, ...] = (
PECOSensorEntityDescription( PECOSensorEntityDescription(
key="customers_out", key="customers_out",
name="Customers Out", translation_key="customers_out",
value_fn=lambda data: int(data.outages.customers_out), value_fn=lambda data: int(data.outages.customers_out),
attribute_fn=lambda data: {}, attribute_fn=lambda data: {},
icon="mdi:power-plug-off", icon="mdi:power-plug-off",
@ -51,7 +51,7 @@ SENSOR_LIST: tuple[PECOSensorEntityDescription, ...] = (
), ),
PECOSensorEntityDescription( PECOSensorEntityDescription(
key="percent_customers_out", key="percent_customers_out",
name="Percent Customers Out", translation_key="percent_customers_out",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
value_fn=lambda data: int(data.outages.percent_customers_out), value_fn=lambda data: int(data.outages.percent_customers_out),
attribute_fn=lambda data: {}, attribute_fn=lambda data: {},
@ -60,7 +60,7 @@ SENSOR_LIST: tuple[PECOSensorEntityDescription, ...] = (
), ),
PECOSensorEntityDescription( PECOSensorEntityDescription(
key="outage_count", key="outage_count",
name="Outage Count", translation_key="outage_count",
value_fn=lambda data: int(data.outages.outage_count), value_fn=lambda data: int(data.outages.outage_count),
attribute_fn=lambda data: {}, attribute_fn=lambda data: {},
icon="mdi:power-plug-off", icon="mdi:power-plug-off",
@ -68,7 +68,7 @@ SENSOR_LIST: tuple[PECOSensorEntityDescription, ...] = (
), ),
PECOSensorEntityDescription( PECOSensorEntityDescription(
key="customers_served", key="customers_served",
name="Customers Served", translation_key="customers_served",
value_fn=lambda data: int(data.outages.customers_served), value_fn=lambda data: int(data.outages.customers_served),
attribute_fn=lambda data: {}, attribute_fn=lambda data: {},
icon="mdi:power-plug-off", icon="mdi:power-plug-off",
@ -76,7 +76,7 @@ SENSOR_LIST: tuple[PECOSensorEntityDescription, ...] = (
), ),
PECOSensorEntityDescription( PECOSensorEntityDescription(
key="map_alert", key="map_alert",
name="Map Alert", translation_key="map_alert",
value_fn=lambda data: str(data.alerts.alert_title), value_fn=lambda data: str(data.alerts.alert_title),
attribute_fn=lambda data: {ATTR_CONTENT: data.alerts.alert_content}, attribute_fn=lambda data: {ATTR_CONTENT: data.alerts.alert_content},
icon="mdi:alert", icon="mdi:alert",

View file

@ -10,5 +10,24 @@
"abort": { "abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]" "already_configured": "[%key:common::config_flow::abort::already_configured_service%]"
} }
},
"entity": {
"sensor": {
"customers_out": {
"name": "Customers out"
},
"percent_customers_out": {
"name": "Percent customers out"
},
"outage_count": {
"name": "Outage count"
},
"customers_served": {
"name": "Customers served"
},
"map_alert": {
"name": "Map alert"
}
}
} }
} }