Skip to content

Commit

Permalink
Add entity translations for homewizard (#95416)
Browse files Browse the repository at this point in the history
* Add entity translations for homewizard

* Add entity translations for homewizard

* Add entity translations for homewizard

* Fix tests
  • Loading branch information
joostlek authored Jun 28, 2023
1 parent 6c2c4c9 commit e9495c9
Show file tree
Hide file tree
Showing 5 changed files with 282 additions and 115 deletions.
5 changes: 3 additions & 2 deletions homeassistant/components/homewizard/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HWEnergyNumberEntity(HomeWizardEntity, NumberEntity):

_attr_entity_category = EntityCategory.CONFIG
_attr_icon = "mdi:lightbulb-on"
_attr_name = "Status light brightness"
_attr_translation_key = "status_light_brightness"
_attr_native_unit_of_measurement = PERCENTAGE

def __init__(
Expand All @@ -55,4 +55,5 @@ def native_value(self) -> float | None:
or self.coordinator.data.state.brightness is None
):
return None
return round(self.coordinator.data.state.brightness * (100 / 255))
brightness: float = self.coordinator.data.state.brightness
return round(brightness * (100 / 255))
82 changes: 41 additions & 41 deletions homeassistant/components/homewizard/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,39 @@ class HomeWizardSensorEntityDescription(
SENSORS: Final[tuple[HomeWizardSensorEntityDescription, ...]] = (
HomeWizardSensorEntityDescription(
key="smr_version",
name="DSMR version",
translation_key="dsmr_version",
icon="mdi:counter",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.smr_version is not None,
value_fn=lambda data: data.smr_version,
),
HomeWizardSensorEntityDescription(
key="meter_model",
name="Smart meter model",
translation_key="meter_model",
icon="mdi:gauge",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.meter_model is not None,
value_fn=lambda data: data.meter_model,
),
HomeWizardSensorEntityDescription(
key="unique_meter_id",
name="Smart meter identifier",
translation_key="unique_meter_id",
icon="mdi:alphabetical-variant",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.unique_meter_id is not None,
value_fn=lambda data: data.unique_meter_id,
),
HomeWizardSensorEntityDescription(
key="wifi_ssid",
name="Wi-Fi SSID",
translation_key="wifi_ssid",
icon="mdi:wifi",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.wifi_ssid is not None,
value_fn=lambda data: data.wifi_ssid,
),
HomeWizardSensorEntityDescription(
key="active_tariff",
name="Active tariff",
translation_key="active_tariff",
icon="mdi:calendar-clock",
has_fn=lambda data: data.active_tariff is not None,
value_fn=lambda data: (
Expand All @@ -97,7 +97,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="wifi_strength",
name="Wi-Fi strength",
translation_key="wifi_strength",
icon="mdi:wifi",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -108,7 +108,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="total_power_import_kwh",
name="Total power import",
translation_key="total_power_import_kwh",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
Expand All @@ -117,7 +117,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="total_power_import_t1_kwh",
name="Total power import T1",
translation_key="total_power_import_t1_kwh",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
Expand All @@ -126,7 +126,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="total_power_import_t2_kwh",
name="Total power import T2",
translation_key="total_power_import_t2_kwh",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
Expand All @@ -135,7 +135,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="total_power_import_t3_kwh",
name="Total power import T3",
translation_key="total_power_import_t3_kwh",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
Expand All @@ -144,7 +144,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="total_power_import_t4_kwh",
name="Total power import T4",
translation_key="total_power_import_t4_kwh",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
Expand All @@ -153,7 +153,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="total_power_export_kwh",
name="Total power export",
translation_key="total_power_export_kwh",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
Expand All @@ -163,7 +163,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="total_power_export_t1_kwh",
name="Total power export T1",
translation_key="total_power_export_t1_kwh",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
Expand All @@ -173,7 +173,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="total_power_export_t2_kwh",
name="Total power export T2",
translation_key="total_power_export_t2_kwh",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
Expand All @@ -183,7 +183,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="total_power_export_t3_kwh",
name="Total power export T3",
translation_key="total_power_export_t3_kwh",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
Expand All @@ -193,7 +193,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="total_power_export_t4_kwh",
name="Total power export T4",
translation_key="total_power_export_t4_kwh",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
Expand All @@ -203,7 +203,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="active_power_w",
name="Active power",
translation_key="active_power_w",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -212,7 +212,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="active_power_l1_w",
name="Active power L1",
translation_key="active_power_l1_w",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -221,7 +221,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="active_power_l2_w",
name="Active power L2",
translation_key="active_power_l2_w",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -230,7 +230,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="active_power_l3_w",
name="Active power L3",
translation_key="active_power_l3_w",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -239,7 +239,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="active_voltage_l1_v",
name="Active voltage L1",
translation_key="active_voltage_l1_v",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -249,7 +249,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="active_voltage_l2_v",
name="Active voltage L2",
translation_key="active_voltage_l2_v",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -259,7 +259,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="active_voltage_l3_v",
name="Active voltage L3",
translation_key="active_voltage_l3_v",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -269,7 +269,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="active_current_l1_a",
name="Active current L1",
translation_key="active_current_l1_a",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -279,7 +279,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="active_current_l2_a",
name="Active current L2",
translation_key="active_current_l2_a",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -289,7 +289,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="active_current_l3_a",
name="Active current L3",
translation_key="active_current_l3_a",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -299,7 +299,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="active_frequency_hz",
name="Active frequency",
translation_key="active_frequency_hz",
native_unit_of_measurement=UnitOfFrequency.HERTZ,
device_class=SensorDeviceClass.FREQUENCY,
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -309,87 +309,87 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="voltage_sag_l1_count",
name="Voltage sags detected L1",
translation_key="voltage_sag_l1_count",
icon="mdi:alert",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.voltage_sag_l1_count is not None,
value_fn=lambda data: data.voltage_sag_l1_count,
),
HomeWizardSensorEntityDescription(
key="voltage_sag_l2_count",
name="Voltage sags detected L2",
translation_key="voltage_sag_l2_count",
icon="mdi:alert",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.voltage_sag_l2_count is not None,
value_fn=lambda data: data.voltage_sag_l2_count,
),
HomeWizardSensorEntityDescription(
key="voltage_sag_l3_count",
name="Voltage sags detected L3",
translation_key="voltage_sag_l3_count",
icon="mdi:alert",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.voltage_sag_l3_count is not None,
value_fn=lambda data: data.voltage_sag_l3_count,
),
HomeWizardSensorEntityDescription(
key="voltage_swell_l1_count",
name="Voltage swells detected L1",
translation_key="voltage_swell_l1_count",
icon="mdi:alert",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.voltage_swell_l1_count is not None,
value_fn=lambda data: data.voltage_swell_l1_count,
),
HomeWizardSensorEntityDescription(
key="voltage_swell_l2_count",
name="Voltage swells detected L2",
translation_key="voltage_swell_l2_count",
icon="mdi:alert",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.voltage_swell_l2_count is not None,
value_fn=lambda data: data.voltage_swell_l2_count,
),
HomeWizardSensorEntityDescription(
key="voltage_swell_l3_count",
name="Voltage swells detected L3",
translation_key="voltage_swell_l3_count",
icon="mdi:alert",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.voltage_swell_l3_count is not None,
value_fn=lambda data: data.voltage_swell_l3_count,
),
HomeWizardSensorEntityDescription(
key="any_power_fail_count",
name="Power failures detected",
translation_key="any_power_fail_count",
icon="mdi:transmission-tower-off",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.any_power_fail_count is not None,
value_fn=lambda data: data.any_power_fail_count,
),
HomeWizardSensorEntityDescription(
key="long_power_fail_count",
name="Long power failures detected",
translation_key="long_power_fail_count",
icon="mdi:transmission-tower-off",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.long_power_fail_count is not None,
value_fn=lambda data: data.long_power_fail_count,
),
HomeWizardSensorEntityDescription(
key="active_power_average_w",
name="Active average demand",
translation_key="active_power_average_w",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
has_fn=lambda data: data.active_power_average_w is not None,
value_fn=lambda data: data.active_power_average_w,
),
HomeWizardSensorEntityDescription(
key="monthly_power_peak_w",
name="Peak demand current month",
translation_key="monthly_power_peak_w",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
has_fn=lambda data: data.monthly_power_peak_w is not None,
value_fn=lambda data: data.monthly_power_peak_w,
),
HomeWizardSensorEntityDescription(
key="total_gas_m3",
name="Total gas",
translation_key="total_gas_m3",
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
device_class=SensorDeviceClass.GAS,
state_class=SensorStateClass.TOTAL_INCREASING,
Expand All @@ -398,15 +398,15 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="gas_unique_id",
name="Gas meter identifier",
translation_key="gas_unique_id",
icon="mdi:alphabetical-variant",
entity_category=EntityCategory.DIAGNOSTIC,
has_fn=lambda data: data.gas_unique_id is not None,
value_fn=lambda data: data.gas_unique_id,
),
HomeWizardSensorEntityDescription(
key="active_liter_lpm",
name="Active water usage",
translation_key="active_liter_lpm",
native_unit_of_measurement="l/min",
icon="mdi:water",
state_class=SensorStateClass.MEASUREMENT,
Expand All @@ -415,7 +415,7 @@ class HomeWizardSensorEntityDescription(
),
HomeWizardSensorEntityDescription(
key="total_liter_m3",
name="Total water usage",
translation_key="total_liter_m3",
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
icon="mdi:gauge",
device_class=SensorDeviceClass.WATER,
Expand Down
Loading

0 comments on commit e9495c9

Please sign in to comment.