Finish Efergy entity translations (#107152)

This commit is contained in:
Joost Lekkerkerker 2024-01-05 12:32:32 +01:00 committed by GitHub
parent c805ea7b4f
commit 6033a7c3d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -96,7 +96,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
), ),
SensorEntityDescription( SensorEntityDescription(
key=CONF_CURRENT_VALUES, key=CONF_CURRENT_VALUES,
name="Power Usage", translation_key="power_usage",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=UnitOfPower.WATT, native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -156,7 +156,8 @@ class EfergySensor(EfergyEntity, SensorEntity):
super().__init__(api, server_unique_id) super().__init__(api, server_unique_id)
self.entity_description = description self.entity_description = description
if description.key == CONF_CURRENT_VALUES: if description.key == CONF_CURRENT_VALUES:
self._attr_name = f"{description.name}_{'' if sid is None else sid}" assert sid is not None
self._attr_translation_placeholders = {"sid": str(sid)}
self._attr_unique_id = ( self._attr_unique_id = (
f"{server_unique_id}/{description.key}_{'' if sid is None else sid}" f"{server_unique_id}/{description.key}_{'' if sid is None else sid}"
) )

View File

@ -48,6 +48,9 @@
}, },
"cost_year": { "cost_year": {
"name": "Yearly energy cost" "name": "Yearly energy cost"
},
"power_usage": {
"name": "Power usage {sid}"
} }
} }
} }