diff --git a/homeassistant/components/fronius/coordinator.py b/homeassistant/components/fronius/coordinator.py index 7593c7f133b..f626fa9ca3d 100644 --- a/homeassistant/components/fronius/coordinator.py +++ b/homeassistant/components/fronius/coordinator.py @@ -18,7 +18,7 @@ from .const import ( FroniusDeviceInfo, SolarNetId, ) -from .descriptions import ( +from .sensor import ( INVERTER_ENTITY_DESCRIPTIONS, LOGGER_ENTITY_DESCRIPTIONS, METER_ENTITY_DESCRIPTIONS, diff --git a/homeassistant/components/fronius/descriptions.py b/homeassistant/components/fronius/descriptions.py deleted file mode 100644 index 79e97915647..00000000000 --- a/homeassistant/components/fronius/descriptions.py +++ /dev/null @@ -1,481 +0,0 @@ -"""Entity descriptions for the Fronius integration.""" -from __future__ import annotations - -from homeassistant.components.sensor import ( - STATE_CLASS_MEASUREMENT, - STATE_CLASS_TOTAL_INCREASING, - SensorEntityDescription, -) -from homeassistant.const import ( - DEVICE_CLASS_BATTERY, - DEVICE_CLASS_CURRENT, - DEVICE_CLASS_ENERGY, - DEVICE_CLASS_POWER, - DEVICE_CLASS_POWER_FACTOR, - DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_VOLTAGE, - ELECTRIC_CURRENT_AMPERE, - ELECTRIC_POTENTIAL_VOLT, - ENERGY_WATT_HOUR, - FREQUENCY_HERTZ, - PERCENTAGE, - POWER_VOLT_AMPERE, - POWER_WATT, - TEMP_CELSIUS, -) - -ELECTRIC_CHARGE_AMPERE_HOURS = "Ah" -ENERGY_VOLT_AMPERE_REACTIVE_HOUR = "varh" -POWER_VOLT_AMPERE_REACTIVE = "var" - - -INVERTER_ENTITY_DESCRIPTIONS: dict[str, SensorEntityDescription] = { - "energy_day": SensorEntityDescription( - key="energy_day", - name="Energy day", - native_unit_of_measurement=ENERGY_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, - ), - "energy_year": SensorEntityDescription( - key="energy_year", - name="Energy year", - native_unit_of_measurement=ENERGY_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, - ), - "energy_total": SensorEntityDescription( - key="energy_total", - name="Energy total", - native_unit_of_measurement=ENERGY_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, - ), - "frequency_ac": SensorEntityDescription( - key="frequency_ac", - name="Frequency AC", - native_unit_of_measurement=FREQUENCY_HERTZ, - state_class=STATE_CLASS_MEASUREMENT, - ), - "current_ac": SensorEntityDescription( - key="current_ac", - name="AC Current", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, - device_class=DEVICE_CLASS_CURRENT, - state_class=STATE_CLASS_MEASUREMENT, - ), - "current_dc": SensorEntityDescription( - key="current_dc", - name="DC current", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, - device_class=DEVICE_CLASS_CURRENT, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:current-dc", - ), - "current_dc_2": SensorEntityDescription( - key="current_dc_2", - name="DC Current 2", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, - device_class=DEVICE_CLASS_CURRENT, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:current-dc", - ), - "power_ac": SensorEntityDescription( - key="power_ac", - name="AC power", - native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, - ), - "voltage_ac": SensorEntityDescription( - key="voltage_ac", - name="AC voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, - ), - "voltage_dc": SensorEntityDescription( - key="voltage_dc", - name="DC voltage", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:current-dc", - ), - "voltage_dc_2": SensorEntityDescription( - key="voltage_dc_2", - name="DC voltage 2", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:current-dc", - ), -} - -LOGGER_ENTITY_DESCRIPTIONS: dict[str, SensorEntityDescription] = { - "co2_factor": SensorEntityDescription( - key="co2_factor", - name="CO₂ factor", - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:molecule-co2", - ), - "cash_factor": SensorEntityDescription( - key="cash_factor", - name="Grid export tariff", - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:cash-plus", - ), - "delivery_factor": SensorEntityDescription( - key="delivery_factor", - name="Grid import tariff", - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:cash-minus", - ), -} - -METER_ENTITY_DESCRIPTIONS: dict[str, SensorEntityDescription] = { - "current_ac_phase_1": SensorEntityDescription( - key="current_ac_phase_1", - name="Current AC phase 1", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, - device_class=DEVICE_CLASS_CURRENT, - state_class=STATE_CLASS_MEASUREMENT, - ), - "current_ac_phase_2": SensorEntityDescription( - key="current_ac_phase_2", - name="Current AC phase 2", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, - device_class=DEVICE_CLASS_CURRENT, - state_class=STATE_CLASS_MEASUREMENT, - ), - "current_ac_phase_3": SensorEntityDescription( - key="current_ac_phase_3", - name="Current AC phase 3", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, - device_class=DEVICE_CLASS_CURRENT, - state_class=STATE_CLASS_MEASUREMENT, - ), - "energy_reactive_ac_consumed": SensorEntityDescription( - key="energy_reactive_ac_consumed", - name="Energy Reactive AC consumed", - native_unit_of_measurement=ENERGY_VOLT_AMPERE_REACTIVE_HOUR, - state_class=STATE_CLASS_TOTAL_INCREASING, - icon="mdi:lightning-bolt-outline", - ), - "energy_reactive_ac_produced": SensorEntityDescription( - key="energy_reactive_ac_produced", - name="Energy Reactive AC produced", - native_unit_of_measurement=ENERGY_VOLT_AMPERE_REACTIVE_HOUR, - state_class=STATE_CLASS_TOTAL_INCREASING, - icon="mdi:lightning-bolt-outline", - ), - "energy_real_ac_minus": SensorEntityDescription( - key="energy_real_ac_minus", - name="Energy real AC minus", - native_unit_of_measurement=ENERGY_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, - ), - "energy_real_ac_plus": SensorEntityDescription( - key="energy_real_ac_plus", - name="Energy real AC plus", - native_unit_of_measurement=ENERGY_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, - ), - "energy_real_consumed": SensorEntityDescription( - key="energy_real_consumed", - name="Energy real consumed", - native_unit_of_measurement=ENERGY_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, - ), - "energy_real_produced": SensorEntityDescription( - key="energy_real_produced", - name="Energy real produced", - native_unit_of_measurement=ENERGY_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, - ), - "frequency_phase_average": SensorEntityDescription( - key="frequency_phase_average", - name="Frequency phase average", - native_unit_of_measurement=FREQUENCY_HERTZ, - state_class=STATE_CLASS_MEASUREMENT, - ), - "power_apparent_phase_1": SensorEntityDescription( - key="power_apparent_phase_1", - name="Power apparent phase 1", - native_unit_of_measurement=POWER_VOLT_AMPERE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:flash-outline", - ), - "power_apparent_phase_2": SensorEntityDescription( - key="power_apparent_phase_2", - name="Power apparent phase 2", - native_unit_of_measurement=POWER_VOLT_AMPERE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:flash-outline", - ), - "power_apparent_phase_3": SensorEntityDescription( - key="power_apparent_phase_3", - name="Power apparent phase 3", - native_unit_of_measurement=POWER_VOLT_AMPERE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:flash-outline", - ), - "power_apparent": SensorEntityDescription( - key="power_apparent", - name="Power apparent", - native_unit_of_measurement=POWER_VOLT_AMPERE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:flash-outline", - ), - "power_factor_phase_1": SensorEntityDescription( - key="power_factor_phase_1", - name="Power factor phase 1", - device_class=DEVICE_CLASS_POWER_FACTOR, - state_class=STATE_CLASS_MEASUREMENT, - ), - "power_factor_phase_2": SensorEntityDescription( - key="power_factor_phase_2", - name="Power factor phase 2", - device_class=DEVICE_CLASS_POWER_FACTOR, - state_class=STATE_CLASS_MEASUREMENT, - ), - "power_factor_phase_3": SensorEntityDescription( - key="power_factor_phase_3", - name="Power factor phase 3", - device_class=DEVICE_CLASS_POWER_FACTOR, - state_class=STATE_CLASS_MEASUREMENT, - ), - "power_factor": SensorEntityDescription( - key="power_factor", - name="Power factor", - device_class=DEVICE_CLASS_POWER_FACTOR, - state_class=STATE_CLASS_MEASUREMENT, - ), - "power_reactive_phase_1": SensorEntityDescription( - key="power_reactive_phase_1", - name="Power reactive phase 1", - native_unit_of_measurement=POWER_VOLT_AMPERE_REACTIVE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:flash-outline", - ), - "power_reactive_phase_2": SensorEntityDescription( - key="power_reactive_phase_2", - name="Power reactive phase 2", - native_unit_of_measurement=POWER_VOLT_AMPERE_REACTIVE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:flash-outline", - ), - "power_reactive_phase_3": SensorEntityDescription( - key="power_reactive_phase_3", - name="Power reactive phase 3", - native_unit_of_measurement=POWER_VOLT_AMPERE_REACTIVE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:flash-outline", - ), - "power_reactive": SensorEntityDescription( - key="power_reactive", - name="Power reactive", - native_unit_of_measurement=POWER_VOLT_AMPERE_REACTIVE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:flash-outline", - ), - "power_real_phase_1": SensorEntityDescription( - key="power_real_phase_1", - name="Power real phase 1", - native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, - ), - "power_real_phase_2": SensorEntityDescription( - key="power_real_phase_2", - name="Power real phase 2", - native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, - ), - "power_real_phase_3": SensorEntityDescription( - key="power_real_phase_3", - name="Power real phase 3", - native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, - ), - "power_real": SensorEntityDescription( - key="power_real", - name="Power real", - native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, - ), - "voltage_ac_phase_1": SensorEntityDescription( - key="voltage_ac_phase_1", - name="Voltage AC phase 1", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, - ), - "voltage_ac_phase_2": SensorEntityDescription( - key="voltage_ac_phase_2", - name="Voltage AC phase 2", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, - ), - "voltage_ac_phase_3": SensorEntityDescription( - key="voltage_ac_phase_3", - name="Voltage AC phase 3", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, - ), - "voltage_ac_phase_to_phase_12": SensorEntityDescription( - key="voltage_ac_phase_to_phase_12", - name="Voltage AC phase 1-2", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, - ), - "voltage_ac_phase_to_phase_23": SensorEntityDescription( - key="voltage_ac_phase_to_phase_23", - name="Voltage AC phase 2-3", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, - ), - "voltage_ac_phase_to_phase_31": SensorEntityDescription( - key="voltage_ac_phase_to_phase_31", - name="Voltage AC phase 3-1", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, - ), -} - -POWER_FLOW_ENTITY_DESCRIPTIONS: dict[str, SensorEntityDescription] = { - "energy_day": SensorEntityDescription( - key="energy_day", - name="Energy day", - native_unit_of_measurement=ENERGY_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, - ), - "energy_year": SensorEntityDescription( - key="energy_year", - name="Energy year", - native_unit_of_measurement=ENERGY_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, - ), - "energy_total": SensorEntityDescription( - key="energy_total", - name="Energy total", - native_unit_of_measurement=ENERGY_WATT_HOUR, - device_class=DEVICE_CLASS_ENERGY, - state_class=STATE_CLASS_TOTAL_INCREASING, - ), - "power_battery": SensorEntityDescription( - key="power_battery", - name="Power battery", - native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, - ), - "power_grid": SensorEntityDescription( - key="power_grid", - name="Power grid", - native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, - ), - "power_load": SensorEntityDescription( - key="power_load", - name="Power load", - native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, - ), - "power_photovoltaics": SensorEntityDescription( - key="power_photovoltaics", - name="Power photovoltaics", - native_unit_of_measurement=POWER_WATT, - device_class=DEVICE_CLASS_POWER, - state_class=STATE_CLASS_MEASUREMENT, - ), - "relative_autonomy": SensorEntityDescription( - key="relative_autonomy", - name="Relative autonomy", - native_unit_of_measurement=PERCENTAGE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:home-circle-outline", - ), - "relative_self_consumption": SensorEntityDescription( - key="relative_self_consumption", - name="Relative self consumption", - native_unit_of_measurement=PERCENTAGE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:solar-power", - ), -} - -STORAGE_ENTITY_DESCRIPTIONS: dict[str, SensorEntityDescription] = { - "capacity_maximum": SensorEntityDescription( - key="capacity_maximum", - name="Capacity maximum", - native_unit_of_measurement=ELECTRIC_CHARGE_AMPERE_HOURS, - ), - "capacity_designed": SensorEntityDescription( - key="capacity_designed", - name="Capacity designed", - native_unit_of_measurement=ELECTRIC_CHARGE_AMPERE_HOURS, - ), - "current_dc": SensorEntityDescription( - key="current_dc", - name="Current DC", - native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, - device_class=DEVICE_CLASS_CURRENT, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:current-dc", - ), - "voltage_dc": SensorEntityDescription( - key="voltage_dc", - name="Voltage DC", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:current-dc", - ), - "voltage_dc_maximum_cell": SensorEntityDescription( - key="voltage_dc_maximum_cell", - name="Voltage DC maximum cell", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:current-dc", - ), - "voltage_dc_minimum_cell": SensorEntityDescription( - key="voltage_dc_minimum_cell", - name="Voltage DC minimum cell", - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, - device_class=DEVICE_CLASS_VOLTAGE, - state_class=STATE_CLASS_MEASUREMENT, - icon="mdi:current-dc", - ), - "state_of_charge": SensorEntityDescription( - key="state_of_charge", - name="State of charge", - native_unit_of_measurement=PERCENTAGE, - device_class=DEVICE_CLASS_BATTERY, - state_class=STATE_CLASS_MEASUREMENT, - ), - "temperature_cell": SensorEntityDescription( - key="temperature_cell", - name="Temperature cell", - native_unit_of_measurement=TEMP_CELSIUS, - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, - ), -} diff --git a/homeassistant/components/fronius/sensor.py b/homeassistant/components/fronius/sensor.py index 1c6dbb40aa8..09d431624d1 100644 --- a/homeassistant/components/fronius/sensor.py +++ b/homeassistant/components/fronius/sensor.py @@ -8,10 +8,29 @@ import voluptuous as vol from homeassistant.components.sensor import ( PLATFORM_SCHEMA, + STATE_CLASS_MEASUREMENT, + STATE_CLASS_TOTAL_INCREASING, SensorEntity, SensorEntityDescription, ) -from homeassistant.const import CONF_RESOURCE +from homeassistant.const import ( + CONF_RESOURCE, + DEVICE_CLASS_BATTERY, + DEVICE_CLASS_CURRENT, + DEVICE_CLASS_ENERGY, + DEVICE_CLASS_POWER, + DEVICE_CLASS_POWER_FACTOR, + DEVICE_CLASS_TEMPERATURE, + DEVICE_CLASS_VOLTAGE, + ELECTRIC_CURRENT_AMPERE, + ELECTRIC_POTENTIAL_VOLT, + ENERGY_WATT_HOUR, + FREQUENCY_HERTZ, + PERCENTAGE, + POWER_VOLT_AMPERE, + POWER_WATT, + TEMP_CELSIUS, +) from homeassistant.core import HomeAssistant, callback import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -36,6 +55,461 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( extra=vol.ALLOW_EXTRA, ) +ELECTRIC_CHARGE_AMPERE_HOURS = "Ah" +ENERGY_VOLT_AMPERE_REACTIVE_HOUR = "varh" +POWER_VOLT_AMPERE_REACTIVE = "var" + +INVERTER_ENTITY_DESCRIPTIONS: dict[str, SensorEntityDescription] = { + "energy_day": SensorEntityDescription( + key="energy_day", + name="Energy day", + native_unit_of_measurement=ENERGY_WATT_HOUR, + device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, + ), + "energy_year": SensorEntityDescription( + key="energy_year", + name="Energy year", + native_unit_of_measurement=ENERGY_WATT_HOUR, + device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, + ), + "energy_total": SensorEntityDescription( + key="energy_total", + name="Energy total", + native_unit_of_measurement=ENERGY_WATT_HOUR, + device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, + ), + "frequency_ac": SensorEntityDescription( + key="frequency_ac", + name="Frequency AC", + native_unit_of_measurement=FREQUENCY_HERTZ, + state_class=STATE_CLASS_MEASUREMENT, + ), + "current_ac": SensorEntityDescription( + key="current_ac", + name="AC Current", + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + device_class=DEVICE_CLASS_CURRENT, + state_class=STATE_CLASS_MEASUREMENT, + ), + "current_dc": SensorEntityDescription( + key="current_dc", + name="DC current", + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + device_class=DEVICE_CLASS_CURRENT, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:current-dc", + ), + "current_dc_2": SensorEntityDescription( + key="current_dc_2", + name="DC Current 2", + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + device_class=DEVICE_CLASS_CURRENT, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:current-dc", + ), + "power_ac": SensorEntityDescription( + key="power_ac", + name="AC power", + native_unit_of_measurement=POWER_WATT, + device_class=DEVICE_CLASS_POWER, + state_class=STATE_CLASS_MEASUREMENT, + ), + "voltage_ac": SensorEntityDescription( + key="voltage_ac", + name="AC voltage", + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + device_class=DEVICE_CLASS_VOLTAGE, + state_class=STATE_CLASS_MEASUREMENT, + ), + "voltage_dc": SensorEntityDescription( + key="voltage_dc", + name="DC voltage", + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + device_class=DEVICE_CLASS_VOLTAGE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:current-dc", + ), + "voltage_dc_2": SensorEntityDescription( + key="voltage_dc_2", + name="DC voltage 2", + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + device_class=DEVICE_CLASS_VOLTAGE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:current-dc", + ), +} + +LOGGER_ENTITY_DESCRIPTIONS: dict[str, SensorEntityDescription] = { + "co2_factor": SensorEntityDescription( + key="co2_factor", + name="CO₂ factor", + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:molecule-co2", + ), + "cash_factor": SensorEntityDescription( + key="cash_factor", + name="Grid export tariff", + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:cash-plus", + ), + "delivery_factor": SensorEntityDescription( + key="delivery_factor", + name="Grid import tariff", + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:cash-minus", + ), +} + +METER_ENTITY_DESCRIPTIONS: dict[str, SensorEntityDescription] = { + "current_ac_phase_1": SensorEntityDescription( + key="current_ac_phase_1", + name="Current AC phase 1", + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + device_class=DEVICE_CLASS_CURRENT, + state_class=STATE_CLASS_MEASUREMENT, + ), + "current_ac_phase_2": SensorEntityDescription( + key="current_ac_phase_2", + name="Current AC phase 2", + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + device_class=DEVICE_CLASS_CURRENT, + state_class=STATE_CLASS_MEASUREMENT, + ), + "current_ac_phase_3": SensorEntityDescription( + key="current_ac_phase_3", + name="Current AC phase 3", + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + device_class=DEVICE_CLASS_CURRENT, + state_class=STATE_CLASS_MEASUREMENT, + ), + "energy_reactive_ac_consumed": SensorEntityDescription( + key="energy_reactive_ac_consumed", + name="Energy Reactive AC consumed", + native_unit_of_measurement=ENERGY_VOLT_AMPERE_REACTIVE_HOUR, + state_class=STATE_CLASS_TOTAL_INCREASING, + icon="mdi:lightning-bolt-outline", + ), + "energy_reactive_ac_produced": SensorEntityDescription( + key="energy_reactive_ac_produced", + name="Energy Reactive AC produced", + native_unit_of_measurement=ENERGY_VOLT_AMPERE_REACTIVE_HOUR, + state_class=STATE_CLASS_TOTAL_INCREASING, + icon="mdi:lightning-bolt-outline", + ), + "energy_real_ac_minus": SensorEntityDescription( + key="energy_real_ac_minus", + name="Energy real AC minus", + native_unit_of_measurement=ENERGY_WATT_HOUR, + device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, + ), + "energy_real_ac_plus": SensorEntityDescription( + key="energy_real_ac_plus", + name="Energy real AC plus", + native_unit_of_measurement=ENERGY_WATT_HOUR, + device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, + ), + "energy_real_consumed": SensorEntityDescription( + key="energy_real_consumed", + name="Energy real consumed", + native_unit_of_measurement=ENERGY_WATT_HOUR, + device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, + ), + "energy_real_produced": SensorEntityDescription( + key="energy_real_produced", + name="Energy real produced", + native_unit_of_measurement=ENERGY_WATT_HOUR, + device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, + ), + "frequency_phase_average": SensorEntityDescription( + key="frequency_phase_average", + name="Frequency phase average", + native_unit_of_measurement=FREQUENCY_HERTZ, + state_class=STATE_CLASS_MEASUREMENT, + ), + "power_apparent_phase_1": SensorEntityDescription( + key="power_apparent_phase_1", + name="Power apparent phase 1", + native_unit_of_measurement=POWER_VOLT_AMPERE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:flash-outline", + ), + "power_apparent_phase_2": SensorEntityDescription( + key="power_apparent_phase_2", + name="Power apparent phase 2", + native_unit_of_measurement=POWER_VOLT_AMPERE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:flash-outline", + ), + "power_apparent_phase_3": SensorEntityDescription( + key="power_apparent_phase_3", + name="Power apparent phase 3", + native_unit_of_measurement=POWER_VOLT_AMPERE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:flash-outline", + ), + "power_apparent": SensorEntityDescription( + key="power_apparent", + name="Power apparent", + native_unit_of_measurement=POWER_VOLT_AMPERE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:flash-outline", + ), + "power_factor_phase_1": SensorEntityDescription( + key="power_factor_phase_1", + name="Power factor phase 1", + device_class=DEVICE_CLASS_POWER_FACTOR, + state_class=STATE_CLASS_MEASUREMENT, + ), + "power_factor_phase_2": SensorEntityDescription( + key="power_factor_phase_2", + name="Power factor phase 2", + device_class=DEVICE_CLASS_POWER_FACTOR, + state_class=STATE_CLASS_MEASUREMENT, + ), + "power_factor_phase_3": SensorEntityDescription( + key="power_factor_phase_3", + name="Power factor phase 3", + device_class=DEVICE_CLASS_POWER_FACTOR, + state_class=STATE_CLASS_MEASUREMENT, + ), + "power_factor": SensorEntityDescription( + key="power_factor", + name="Power factor", + device_class=DEVICE_CLASS_POWER_FACTOR, + state_class=STATE_CLASS_MEASUREMENT, + ), + "power_reactive_phase_1": SensorEntityDescription( + key="power_reactive_phase_1", + name="Power reactive phase 1", + native_unit_of_measurement=POWER_VOLT_AMPERE_REACTIVE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:flash-outline", + ), + "power_reactive_phase_2": SensorEntityDescription( + key="power_reactive_phase_2", + name="Power reactive phase 2", + native_unit_of_measurement=POWER_VOLT_AMPERE_REACTIVE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:flash-outline", + ), + "power_reactive_phase_3": SensorEntityDescription( + key="power_reactive_phase_3", + name="Power reactive phase 3", + native_unit_of_measurement=POWER_VOLT_AMPERE_REACTIVE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:flash-outline", + ), + "power_reactive": SensorEntityDescription( + key="power_reactive", + name="Power reactive", + native_unit_of_measurement=POWER_VOLT_AMPERE_REACTIVE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:flash-outline", + ), + "power_real_phase_1": SensorEntityDescription( + key="power_real_phase_1", + name="Power real phase 1", + native_unit_of_measurement=POWER_WATT, + device_class=DEVICE_CLASS_POWER, + state_class=STATE_CLASS_MEASUREMENT, + ), + "power_real_phase_2": SensorEntityDescription( + key="power_real_phase_2", + name="Power real phase 2", + native_unit_of_measurement=POWER_WATT, + device_class=DEVICE_CLASS_POWER, + state_class=STATE_CLASS_MEASUREMENT, + ), + "power_real_phase_3": SensorEntityDescription( + key="power_real_phase_3", + name="Power real phase 3", + native_unit_of_measurement=POWER_WATT, + device_class=DEVICE_CLASS_POWER, + state_class=STATE_CLASS_MEASUREMENT, + ), + "power_real": SensorEntityDescription( + key="power_real", + name="Power real", + native_unit_of_measurement=POWER_WATT, + device_class=DEVICE_CLASS_POWER, + state_class=STATE_CLASS_MEASUREMENT, + ), + "voltage_ac_phase_1": SensorEntityDescription( + key="voltage_ac_phase_1", + name="Voltage AC phase 1", + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + device_class=DEVICE_CLASS_VOLTAGE, + state_class=STATE_CLASS_MEASUREMENT, + ), + "voltage_ac_phase_2": SensorEntityDescription( + key="voltage_ac_phase_2", + name="Voltage AC phase 2", + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + device_class=DEVICE_CLASS_VOLTAGE, + state_class=STATE_CLASS_MEASUREMENT, + ), + "voltage_ac_phase_3": SensorEntityDescription( + key="voltage_ac_phase_3", + name="Voltage AC phase 3", + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + device_class=DEVICE_CLASS_VOLTAGE, + state_class=STATE_CLASS_MEASUREMENT, + ), + "voltage_ac_phase_to_phase_12": SensorEntityDescription( + key="voltage_ac_phase_to_phase_12", + name="Voltage AC phase 1-2", + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + device_class=DEVICE_CLASS_VOLTAGE, + state_class=STATE_CLASS_MEASUREMENT, + ), + "voltage_ac_phase_to_phase_23": SensorEntityDescription( + key="voltage_ac_phase_to_phase_23", + name="Voltage AC phase 2-3", + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + device_class=DEVICE_CLASS_VOLTAGE, + state_class=STATE_CLASS_MEASUREMENT, + ), + "voltage_ac_phase_to_phase_31": SensorEntityDescription( + key="voltage_ac_phase_to_phase_31", + name="Voltage AC phase 3-1", + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + device_class=DEVICE_CLASS_VOLTAGE, + state_class=STATE_CLASS_MEASUREMENT, + ), +} + +POWER_FLOW_ENTITY_DESCRIPTIONS: dict[str, SensorEntityDescription] = { + "energy_day": SensorEntityDescription( + key="energy_day", + name="Energy day", + native_unit_of_measurement=ENERGY_WATT_HOUR, + device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, + ), + "energy_year": SensorEntityDescription( + key="energy_year", + name="Energy year", + native_unit_of_measurement=ENERGY_WATT_HOUR, + device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, + ), + "energy_total": SensorEntityDescription( + key="energy_total", + name="Energy total", + native_unit_of_measurement=ENERGY_WATT_HOUR, + device_class=DEVICE_CLASS_ENERGY, + state_class=STATE_CLASS_TOTAL_INCREASING, + ), + "power_battery": SensorEntityDescription( + key="power_battery", + name="Power battery", + native_unit_of_measurement=POWER_WATT, + device_class=DEVICE_CLASS_POWER, + state_class=STATE_CLASS_MEASUREMENT, + ), + "power_grid": SensorEntityDescription( + key="power_grid", + name="Power grid", + native_unit_of_measurement=POWER_WATT, + device_class=DEVICE_CLASS_POWER, + state_class=STATE_CLASS_MEASUREMENT, + ), + "power_load": SensorEntityDescription( + key="power_load", + name="Power load", + native_unit_of_measurement=POWER_WATT, + device_class=DEVICE_CLASS_POWER, + state_class=STATE_CLASS_MEASUREMENT, + ), + "power_photovoltaics": SensorEntityDescription( + key="power_photovoltaics", + name="Power photovoltaics", + native_unit_of_measurement=POWER_WATT, + device_class=DEVICE_CLASS_POWER, + state_class=STATE_CLASS_MEASUREMENT, + ), + "relative_autonomy": SensorEntityDescription( + key="relative_autonomy", + name="Relative autonomy", + native_unit_of_measurement=PERCENTAGE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:home-circle-outline", + ), + "relative_self_consumption": SensorEntityDescription( + key="relative_self_consumption", + name="Relative self consumption", + native_unit_of_measurement=PERCENTAGE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:solar-power", + ), +} + +STORAGE_ENTITY_DESCRIPTIONS: dict[str, SensorEntityDescription] = { + "capacity_maximum": SensorEntityDescription( + key="capacity_maximum", + name="Capacity maximum", + native_unit_of_measurement=ELECTRIC_CHARGE_AMPERE_HOURS, + ), + "capacity_designed": SensorEntityDescription( + key="capacity_designed", + name="Capacity designed", + native_unit_of_measurement=ELECTRIC_CHARGE_AMPERE_HOURS, + ), + "current_dc": SensorEntityDescription( + key="current_dc", + name="Current DC", + native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, + device_class=DEVICE_CLASS_CURRENT, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:current-dc", + ), + "voltage_dc": SensorEntityDescription( + key="voltage_dc", + name="Voltage DC", + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + device_class=DEVICE_CLASS_VOLTAGE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:current-dc", + ), + "voltage_dc_maximum_cell": SensorEntityDescription( + key="voltage_dc_maximum_cell", + name="Voltage DC maximum cell", + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + device_class=DEVICE_CLASS_VOLTAGE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:current-dc", + ), + "voltage_dc_minimum_cell": SensorEntityDescription( + key="voltage_dc_minimum_cell", + name="Voltage DC minimum cell", + native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + device_class=DEVICE_CLASS_VOLTAGE, + state_class=STATE_CLASS_MEASUREMENT, + icon="mdi:current-dc", + ), + "state_of_charge": SensorEntityDescription( + key="state_of_charge", + name="State of charge", + native_unit_of_measurement=PERCENTAGE, + device_class=DEVICE_CLASS_BATTERY, + state_class=STATE_CLASS_MEASUREMENT, + ), + "temperature_cell": SensorEntityDescription( + key="temperature_cell", + name="Temperature cell", + native_unit_of_measurement=TEMP_CELSIUS, + device_class=DEVICE_CLASS_TEMPERATURE, + state_class=STATE_CLASS_MEASUREMENT, + ), +} + async def async_setup_platform( hass: HomeAssistant,