Add sensors for new P1 datapoints in HomeWizard (#85198)
Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Franck Nijhof <git@frenck.dev> fixes undefined
This commit is contained in:
parent
ce43a53585
commit
ccd8bc14e0
5 changed files with 1070 additions and 34 deletions
|
@ -10,7 +10,15 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import PERCENTAGE, UnitOfEnergy, UnitOfPower, UnitOfVolume
|
||||
from homeassistant.const import (
|
||||
PERCENTAGE,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
UnitOfVolume,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -41,6 +49,11 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = (
|
|||
icon="mdi:wifi",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="active_tariff",
|
||||
name="Active tariff",
|
||||
icon="mdi:calendar-clock",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="wifi_strength",
|
||||
name="Wi-Fi strength",
|
||||
|
@ -50,6 +63,13 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = (
|
|||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="total_power_import_kwh",
|
||||
name="Total power import",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="total_power_import_t1_kwh",
|
||||
name="Total power import T1",
|
||||
|
@ -64,6 +84,27 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = (
|
|||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="total_power_import_t3_kwh",
|
||||
name="Total power import T3",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="total_power_import_t4_kwh",
|
||||
name="Total power import T4",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="total_power_export_kwh",
|
||||
name="Total power export",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="total_power_export_t1_kwh",
|
||||
name="Total power export T1",
|
||||
|
@ -78,6 +119,20 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = (
|
|||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="total_power_export_t3_kwh",
|
||||
name="Total power export T3",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="total_power_export_t4_kwh",
|
||||
name="Total power export T4",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="active_power_w",
|
||||
name="Active power",
|
||||
|
@ -106,6 +161,122 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = (
|
|||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="active_voltage_l1_v",
|
||||
name="Active voltage L1",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="active_voltage_l2_v",
|
||||
name="Active voltage L2",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="active_voltage_l3_v",
|
||||
name="Active voltage L3",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="active_current_l1_a",
|
||||
name="Active current L1",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="active_current_l2_a",
|
||||
name="Active current L2",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="active_current_l3_a",
|
||||
name="Active current L3",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="active_frequency_hz",
|
||||
name="Active frequency",
|
||||
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||
device_class=SensorDeviceClass.FREQUENCY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="voltage_sag_l1_count",
|
||||
name="Voltage sags detected L1",
|
||||
icon="mdi:alert",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="voltage_sag_l2_count",
|
||||
name="Voltage sags detected L2",
|
||||
icon="mdi:alert",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="voltage_sag_l3_count",
|
||||
name="Voltage sags detected L3",
|
||||
icon="mdi:alert",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="voltage_swell_l1_count",
|
||||
name="Voltage swells detected L1",
|
||||
icon="mdi:alert",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="voltage_swell_l2_count",
|
||||
name="Voltage swells detected L2",
|
||||
icon="mdi:alert",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="voltage_swell_l3_count",
|
||||
name="Voltage swells detected L3",
|
||||
icon="mdi:alert",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="any_power_fail_count",
|
||||
name="Power failures detected",
|
||||
icon="mdi:transmission-tower-off",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="long_power_fail_count",
|
||||
name="Long power failures detected",
|
||||
icon="mdi:transmission-tower-off",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="active_power_average_w",
|
||||
name="Active average demand",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="montly_power_peak_w",
|
||||
name="Peak demand current month",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="total_gas_m3",
|
||||
name="Total gas",
|
||||
|
@ -171,8 +342,11 @@ class HWEnergySensor(HomeWizardEntity, SensorEntity):
|
|||
if (
|
||||
self.data_type
|
||||
in [
|
||||
"total_power_export_kwh",
|
||||
"total_power_export_t1_kwh",
|
||||
"total_power_export_t2_kwh",
|
||||
"total_power_export_t3_kwh",
|
||||
"total_power_export_t4_kwh",
|
||||
]
|
||||
and self.native_value == 0
|
||||
):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue