Use new enums in growatt_server (#61655)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-13 17:35:06 +01:00 committed by GitHub
parent fadbab0e32
commit 88a93d5d53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 120 additions and 151 deletions

View File

@ -1,13 +1,8 @@
"""Growatt Sensor definitions for the Inverter type.""" """Growatt Sensor definitions for the Inverter type."""
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import STATE_CLASS_TOTAL from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_POWER,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_VOLTAGE,
ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
@ -24,7 +19,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Energy today", name="Energy today",
api_key="powerToday", api_key="powerToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -32,16 +27,16 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Lifetime energy output", name="Lifetime energy output",
api_key="powerTotal", api_key="powerTotal",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
precision=1, precision=1,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="inverter_voltage_input_1", key="inverter_voltage_input_1",
name="Input 1 voltage", name="Input 1 voltage",
api_key="vpv1", api_key="vpv1",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=2, precision=2,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -49,7 +44,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 1 Amperage", name="Input 1 Amperage",
api_key="ipv1", api_key="ipv1",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -57,7 +52,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 1 Wattage", name="Input 1 Wattage",
api_key="ppv1", api_key="ppv1",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -65,7 +60,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 2 voltage", name="Input 2 voltage",
api_key="vpv2", api_key="vpv2",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -73,7 +68,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 2 Amperage", name="Input 2 Amperage",
api_key="ipv2", api_key="ipv2",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -81,7 +76,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 2 Wattage", name="Input 2 Wattage",
api_key="ppv2", api_key="ppv2",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -89,7 +84,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 3 voltage", name="Input 3 voltage",
api_key="vpv3", api_key="vpv3",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -97,7 +92,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 3 Amperage", name="Input 3 Amperage",
api_key="ipv3", api_key="ipv3",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -105,7 +100,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 3 Wattage", name="Input 3 Wattage",
api_key="ppv3", api_key="ppv3",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -113,7 +108,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Internal wattage", name="Internal wattage",
api_key="ppv", api_key="ppv",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -121,7 +116,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Reactive voltage", name="Reactive voltage",
api_key="vacr", api_key="vacr",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -129,7 +124,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Reactive amperage", name="Reactive amperage",
api_key="iacr", api_key="iacr",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -144,7 +139,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Output power", name="Output power",
api_key="pac", api_key="pac",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -152,7 +147,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Reactive wattage", name="Reactive wattage",
api_key="pacr", api_key="pacr",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -160,7 +155,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Intelligent Power Management temperature", name="Intelligent Power Management temperature",
api_key="ipmTemperature", api_key="ipmTemperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -168,7 +163,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Temperature", name="Temperature",
api_key="temperature", api_key="temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
precision=1, precision=1,
), ),
) )

View File

@ -1,16 +1,8 @@
"""Growatt Sensor definitions for the Mix type.""" """Growatt Sensor definitions for the Mix type."""
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import ( from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
STATE_CLASS_TOTAL,
STATE_CLASS_TOTAL_INCREASING,
)
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_POWER,
DEVICE_CLASS_TIMESTAMP,
DEVICE_CLASS_VOLTAGE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
@ -27,80 +19,80 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Statement of charge", name="Statement of charge",
api_key="capacity", api_key="capacity",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
device_class=DEVICE_CLASS_BATTERY, device_class=SensorDeviceClass.BATTERY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_battery_charge_today", key="mix_battery_charge_today",
name="Battery charged today", name="Battery charged today",
api_key="eBatChargeToday", api_key="eBatChargeToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_battery_charge_lifetime", key="mix_battery_charge_lifetime",
name="Lifetime battery charged", name="Lifetime battery charged",
api_key="eBatChargeTotal", api_key="eBatChargeTotal",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_battery_discharge_today", key="mix_battery_discharge_today",
name="Battery discharged today", name="Battery discharged today",
api_key="eBatDisChargeToday", api_key="eBatDisChargeToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_battery_discharge_lifetime", key="mix_battery_discharge_lifetime",
name="Lifetime battery discharged", name="Lifetime battery discharged",
api_key="eBatDisChargeTotal", api_key="eBatDisChargeTotal",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_solar_generation_today", key="mix_solar_generation_today",
name="Solar energy today", name="Solar energy today",
api_key="epvToday", api_key="epvToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_solar_generation_lifetime", key="mix_solar_generation_lifetime",
name="Lifetime solar energy", name="Lifetime solar energy",
api_key="epvTotal", api_key="epvTotal",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_battery_discharge_w", key="mix_battery_discharge_w",
name="Battery discharging W", name="Battery discharging W",
api_key="pDischarge1", api_key="pDischarge1",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_battery_voltage", key="mix_battery_voltage",
name="Battery voltage", name="Battery voltage",
api_key="vbat", api_key="vbat",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_pv1_voltage", key="mix_pv1_voltage",
name="PV1 voltage", name="PV1 voltage",
api_key="vpv1", api_key="vpv1",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_pv2_voltage", key="mix_pv2_voltage",
name="PV2 voltage", name="PV2 voltage",
api_key="vpv2", api_key="vpv2",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
), ),
# Values from 'mix_totals' API call # Values from 'mix_totals' API call
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -108,30 +100,30 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Load consumption today", name="Load consumption today",
api_key="elocalLoadToday", api_key="elocalLoadToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_load_consumption_lifetime", key="mix_load_consumption_lifetime",
name="Lifetime load consumption", name="Lifetime load consumption",
api_key="elocalLoadTotal", api_key="elocalLoadTotal",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_export_to_grid_today", key="mix_export_to_grid_today",
name="Export to grid today", name="Export to grid today",
api_key="etoGridToday", api_key="etoGridToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_export_to_grid_lifetime", key="mix_export_to_grid_lifetime",
name="Lifetime export to grid", name="Lifetime export to grid",
api_key="etogridTotal", api_key="etogridTotal",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
), ),
# Values from 'mix_system_status' API call # Values from 'mix_system_status' API call
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -139,63 +131,63 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Battery charging", name="Battery charging",
api_key="chargePower", api_key="chargePower",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=POWER_KILO_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_load_consumption", key="mix_load_consumption",
name="Load consumption", name="Load consumption",
api_key="pLocalLoad", api_key="pLocalLoad",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=POWER_KILO_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_wattage_pv_1", key="mix_wattage_pv_1",
name="PV1 Wattage", name="PV1 Wattage",
api_key="pPv1", api_key="pPv1",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=POWER_KILO_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_wattage_pv_2", key="mix_wattage_pv_2",
name="PV2 Wattage", name="PV2 Wattage",
api_key="pPv2", api_key="pPv2",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=POWER_KILO_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_wattage_pv_all", key="mix_wattage_pv_all",
name="All PV Wattage", name="All PV Wattage",
api_key="ppv", api_key="ppv",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=POWER_KILO_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_export_to_grid", key="mix_export_to_grid",
name="Export to grid", name="Export to grid",
api_key="pactogrid", api_key="pactogrid",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=POWER_KILO_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_import_from_grid", key="mix_import_from_grid",
name="Import from grid", name="Import from grid",
api_key="pactouser", api_key="pactouser",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=POWER_KILO_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_battery_discharge_kw", key="mix_battery_discharge_kw",
name="Battery discharging kW", name="Battery discharging kW",
api_key="pdisCharge1", api_key="pdisCharge1",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=POWER_KILO_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_grid_voltage", key="mix_grid_voltage",
name="Grid voltage", name="Grid voltage",
api_key="vAc1", api_key="vAc1",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
), ),
# Values from 'mix_detail' API call # Values from 'mix_detail' API call
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -203,35 +195,35 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="System production today (self-consumption + export)", name="System production today (self-consumption + export)",
api_key="eCharge", api_key="eCharge",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_load_consumption_solar_today", key="mix_load_consumption_solar_today",
name="Load consumption today (solar)", name="Load consumption today (solar)",
api_key="eChargeToday", api_key="eChargeToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_self_consumption_today", key="mix_self_consumption_today",
name="Self consumption today (solar + battery)", name="Self consumption today (solar + battery)",
api_key="eChargeToday1", api_key="eChargeToday1",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_load_consumption_battery_today", key="mix_load_consumption_battery_today",
name="Load consumption today (battery)", name="Load consumption today (battery)",
api_key="echarge1", api_key="echarge1",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_import_from_grid_today", key="mix_import_from_grid_today",
name="Import from grid today (load)", name="Import from grid today (load)",
api_key="etouser", api_key="etouser",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
# This sensor is manually created using the most recent X-Axis value from the chartData # This sensor is manually created using the most recent X-Axis value from the chartData
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -239,7 +231,7 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Last Data Update", name="Last Data Update",
api_key="lastdataupdate", api_key="lastdataupdate",
native_unit_of_measurement=None, native_unit_of_measurement=None,
device_class=DEVICE_CLASS_TIMESTAMP, device_class=SensorDeviceClass.TIMESTAMP,
), ),
# Values from 'dashboard_data' API call # Values from 'dashboard_data' API call
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -247,7 +239,7 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Import from grid today (load + charging)", name="Import from grid today (load + charging)",
api_key="etouser_combined", # This id is not present in the raw API data, it is added by the sensor api_key="etouser_combined", # This id is not present in the raw API data, it is added by the sensor
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
) )

View File

@ -1,13 +1,8 @@
"""Growatt Sensor definitions for the Storage type.""" """Growatt Sensor definitions for the Storage type."""
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import STATE_CLASS_TOTAL from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_POWER,
DEVICE_CLASS_VOLTAGE,
ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
@ -24,73 +19,73 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Storage production today", name="Storage production today",
api_key="eBatDisChargeToday", api_key="eBatDisChargeToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_storage_production_lifetime", key="storage_storage_production_lifetime",
name="Lifetime Storage production", name="Lifetime Storage production",
api_key="eBatDisChargeTotal", api_key="eBatDisChargeTotal",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_grid_discharge_today", key="storage_grid_discharge_today",
name="Grid discharged today", name="Grid discharged today",
api_key="eacDisChargeToday", api_key="eacDisChargeToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_load_consumption_today", key="storage_load_consumption_today",
name="Load consumption today", name="Load consumption today",
api_key="eopDischrToday", api_key="eopDischrToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_load_consumption_lifetime", key="storage_load_consumption_lifetime",
name="Lifetime load consumption", name="Lifetime load consumption",
api_key="eopDischrTotal", api_key="eopDischrTotal",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_grid_charged_today", key="storage_grid_charged_today",
name="Grid charged today", name="Grid charged today",
api_key="eacChargeToday", api_key="eacChargeToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_charge_storage_lifetime", key="storage_charge_storage_lifetime",
name="Lifetime storaged charged", name="Lifetime storaged charged",
api_key="eChargeTotal", api_key="eChargeTotal",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_solar_production", key="storage_solar_production",
name="Solar power production", name="Solar power production",
api_key="ppv", api_key="ppv",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_battery_percentage", key="storage_battery_percentage",
name="Battery percentage", name="Battery percentage",
api_key="capacity", api_key="capacity",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
device_class=DEVICE_CLASS_BATTERY, device_class=SensorDeviceClass.BATTERY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_power_flow", key="storage_power_flow",
name="Storage charging/ discharging(-ve)", name="Storage charging/ discharging(-ve)",
api_key="pCharge", api_key="pCharge",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_load_consumption_solar_storage", key="storage_load_consumption_solar_storage",
@ -103,43 +98,43 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Charge today", name="Charge today",
api_key="eChargeToday", api_key="eChargeToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_import_from_grid", key="storage_import_from_grid",
name="Import from grid", name="Import from grid",
api_key="pAcInPut", api_key="pAcInPut",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_import_from_grid_today", key="storage_import_from_grid_today",
name="Import from grid today", name="Import from grid today",
api_key="eToUserToday", api_key="eToUserToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_import_from_grid_total", key="storage_import_from_grid_total",
name="Import from grid total", name="Import from grid total",
api_key="eToUserTotal", api_key="eToUserTotal",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_load_consumption", key="storage_load_consumption",
name="Load consumption", name="Load consumption",
api_key="outPutPower", api_key="outPutPower",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="storage_grid_voltage", key="storage_grid_voltage",
name="AC input voltage", name="AC input voltage",
api_key="vGrid", api_key="vGrid",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=2, precision=2,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -147,7 +142,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="PV charging voltage", name="PV charging voltage",
api_key="vpv", api_key="vpv",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=2, precision=2,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -162,7 +157,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Output voltage", name="Output voltage",
api_key="outPutVolt", api_key="outPutVolt",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=2, precision=2,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -177,7 +172,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Solar charge current", name="Solar charge current",
api_key="iAcCharge", api_key="iAcCharge",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=2, precision=2,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -185,7 +180,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Solar current to storage", name="Solar current to storage",
api_key="iChargePV1", api_key="iChargePV1",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=2, precision=2,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -193,7 +188,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Grid charge current", name="Grid charge current",
api_key="chgCurr", api_key="chgCurr",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=2, precision=2,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -201,7 +196,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Grid out current", name="Grid out current",
api_key="outPutCurrent", api_key="outPutCurrent",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=2, precision=2,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -209,7 +204,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Battery voltage", name="Battery voltage",
api_key="vBat", api_key="vBat",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=2, precision=2,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -217,7 +212,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Load percentage", name="Load percentage",
api_key="loadPercent", api_key="loadPercent",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
device_class=DEVICE_CLASS_BATTERY, device_class=SensorDeviceClass.BATTERY,
precision=2, precision=2,
), ),
) )

View File

@ -1,16 +1,8 @@
"""Growatt Sensor definitions for the TLX type.""" """Growatt Sensor definitions for the TLX type."""
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import ( from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
STATE_CLASS_TOTAL,
STATE_CLASS_TOTAL_INCREASING,
)
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_POWER,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_VOLTAGE,
ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
@ -27,7 +19,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Energy today", name="Energy today",
api_key="eacToday", api_key="eacToday",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -35,8 +27,8 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Lifetime energy output", name="Lifetime energy output",
api_key="eacTotal", api_key="eacTotal",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -44,8 +36,8 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Lifetime total energy input 1", name="Lifetime total energy input 1",
api_key="epv1Total", api_key="epv1Total",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -53,8 +45,8 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Energy Today Input 1", name="Energy Today Input 1",
api_key="epv1Today", api_key="epv1Today",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -62,7 +54,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 1 voltage", name="Input 1 voltage",
api_key="vpv1", api_key="vpv1",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -70,7 +62,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 1 Amperage", name="Input 1 Amperage",
api_key="ipv1", api_key="ipv1",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -78,7 +70,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 1 Wattage", name="Input 1 Wattage",
api_key="ppv1", api_key="ppv1",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -86,8 +78,8 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Lifetime total energy input 2", name="Lifetime total energy input 2",
api_key="epv2Total", api_key="epv2Total",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -95,8 +87,8 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Energy Today Input 2", name="Energy Today Input 2",
api_key="epv2Today", api_key="epv2Today",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -104,7 +96,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 2 voltage", name="Input 2 voltage",
api_key="vpv2", api_key="vpv2",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -112,7 +104,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 2 Amperage", name="Input 2 Amperage",
api_key="ipv2", api_key="ipv2",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE, native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT, device_class=SensorDeviceClass.CURRENT,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -120,7 +112,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Input 2 Wattage", name="Input 2 Wattage",
api_key="ppv2", api_key="ppv2",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -128,7 +120,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Internal wattage", name="Internal wattage",
api_key="ppv", api_key="ppv",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -136,7 +128,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Reactive voltage", name="Reactive voltage",
api_key="vacrs", api_key="vacrs",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=DEVICE_CLASS_VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -151,7 +143,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Output power", name="Output power",
api_key="pac", api_key="pac",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -159,7 +151,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Temperature 1", name="Temperature 1",
api_key="temp1", api_key="temp1",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -167,7 +159,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Temperature 2", name="Temperature 2",
api_key="temp2", api_key="temp2",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -175,7 +167,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Temperature 3", name="Temperature 3",
api_key="temp3", api_key="temp3",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -183,7 +175,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Temperature 4", name="Temperature 4",
api_key="temp4", api_key="temp4",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
precision=1, precision=1,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -191,7 +183,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Temperature 5", name="Temperature 5",
api_key="temp5", api_key="temp5",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
precision=1, precision=1,
), ),
) )

View File

@ -1,13 +1,8 @@
"""Growatt Sensor definitions for Totals.""" """Growatt Sensor definitions for Totals."""
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import STATE_CLASS_TOTAL from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import ( from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_POWER,
ENERGY_KILO_WATT_HOUR,
POWER_WATT,
)
from .sensor_entity_description import GrowattSensorEntityDescription from .sensor_entity_description import GrowattSensorEntityDescription
@ -29,28 +24,28 @@ TOTAL_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
name="Energy Today", name="Energy Today",
api_key="todayEnergy", api_key="todayEnergy",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="total_output_power", key="total_output_power",
name="Output Power", name="Output Power",
api_key="invTodayPpv", api_key="invTodayPpv",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="total_energy_output", key="total_energy_output",
name="Lifetime energy output", name="Lifetime energy output",
api_key="totalEnergy", api_key="totalEnergy",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY, device_class=SensorDeviceClass.ENERGY,
state_class=STATE_CLASS_TOTAL, state_class=SensorStateClass.TOTAL,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="total_maximum_output", key="total_maximum_output",
name="Maximum power", name="Maximum power",
api_key="nominalPower", api_key="nominalPower",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
), ),
) )