Refactor Growatt sensor types (#56544)
This commit is contained in:
parent
35acca1063
commit
ac08d05b76
7 changed files with 932 additions and 854 deletions
|
@ -1,40 +1,14 @@
|
||||||
"""Read status of growatt inverters."""
|
"""Read status of growatt inverters."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import growattServer
|
import growattServer
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import SensorEntity
|
||||||
STATE_CLASS_TOTAL,
|
from homeassistant.const import CONF_NAME, CONF_PASSWORD, CONF_URL, CONF_USERNAME
|
||||||
STATE_CLASS_TOTAL_INCREASING,
|
|
||||||
SensorEntity,
|
|
||||||
SensorEntityDescription,
|
|
||||||
)
|
|
||||||
from homeassistant.const import (
|
|
||||||
CONF_NAME,
|
|
||||||
CONF_PASSWORD,
|
|
||||||
CONF_URL,
|
|
||||||
CONF_USERNAME,
|
|
||||||
DEVICE_CLASS_BATTERY,
|
|
||||||
DEVICE_CLASS_CURRENT,
|
|
||||||
DEVICE_CLASS_ENERGY,
|
|
||||||
DEVICE_CLASS_POWER,
|
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
DEVICE_CLASS_TIMESTAMP,
|
|
||||||
DEVICE_CLASS_VOLTAGE,
|
|
||||||
ELECTRIC_CURRENT_AMPERE,
|
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
ENERGY_KILO_WATT_HOUR,
|
|
||||||
FREQUENCY_HERTZ,
|
|
||||||
PERCENTAGE,
|
|
||||||
POWER_KILO_WATT,
|
|
||||||
POWER_WATT,
|
|
||||||
TEMP_CELSIUS,
|
|
||||||
)
|
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.util import Throttle, dt
|
from homeassistant.util import Throttle, dt
|
||||||
|
|
||||||
|
@ -45,838 +19,18 @@ from .const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
LOGIN_INVALID_AUTH_CODE,
|
LOGIN_INVALID_AUTH_CODE,
|
||||||
)
|
)
|
||||||
|
from .sensor_types.inverter import INVERTER_SENSOR_TYPES
|
||||||
|
from .sensor_types.mix import MIX_SENSOR_TYPES
|
||||||
|
from .sensor_types.sensor_entity_description import GrowattSensorEntityDescription
|
||||||
|
from .sensor_types.storage import STORAGE_SENSOR_TYPES
|
||||||
|
from .sensor_types.tlx import TLX_SENSOR_TYPES
|
||||||
|
from .sensor_types.total import TOTAL_SENSOR_TYPES
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SCAN_INTERVAL = datetime.timedelta(minutes=1)
|
SCAN_INTERVAL = datetime.timedelta(minutes=1)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class GrowattRequiredKeysMixin:
|
|
||||||
"""Mixin for required keys."""
|
|
||||||
|
|
||||||
api_key: str
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class GrowattSensorEntityDescription(SensorEntityDescription, GrowattRequiredKeysMixin):
|
|
||||||
"""Describes Growatt sensor entity."""
|
|
||||||
|
|
||||||
precision: int | None = None
|
|
||||||
currency: bool = False
|
|
||||||
|
|
||||||
|
|
||||||
TOTAL_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="total_money_today",
|
|
||||||
name="Total money today",
|
|
||||||
api_key="plantMoneyText",
|
|
||||||
currency=True,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="total_money_total",
|
|
||||||
name="Money lifetime",
|
|
||||||
api_key="totalMoneyText",
|
|
||||||
currency=True,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="total_energy_today",
|
|
||||||
name="Energy Today",
|
|
||||||
api_key="todayEnergy",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="total_output_power",
|
|
||||||
name="Output Power",
|
|
||||||
api_key="invTodayPpv",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="total_energy_output",
|
|
||||||
name="Lifetime energy output",
|
|
||||||
api_key="totalEnergy",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="total_maximum_output",
|
|
||||||
name="Maximum power",
|
|
||||||
api_key="nominalPower",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_energy_today",
|
|
||||||
name="Energy today",
|
|
||||||
api_key="powerToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_energy_total",
|
|
||||||
name="Lifetime energy output",
|
|
||||||
api_key="powerTotal",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
precision=1,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_voltage_input_1",
|
|
||||||
name="Input 1 voltage",
|
|
||||||
api_key="vpv1",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
precision=2,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_amperage_input_1",
|
|
||||||
name="Input 1 Amperage",
|
|
||||||
api_key="ipv1",
|
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_wattage_input_1",
|
|
||||||
name="Input 1 Wattage",
|
|
||||||
api_key="ppv1",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_voltage_input_2",
|
|
||||||
name="Input 2 voltage",
|
|
||||||
api_key="vpv2",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_amperage_input_2",
|
|
||||||
name="Input 2 Amperage",
|
|
||||||
api_key="ipv2",
|
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_wattage_input_2",
|
|
||||||
name="Input 2 Wattage",
|
|
||||||
api_key="ppv2",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_voltage_input_3",
|
|
||||||
name="Input 3 voltage",
|
|
||||||
api_key="vpv3",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_amperage_input_3",
|
|
||||||
name="Input 3 Amperage",
|
|
||||||
api_key="ipv3",
|
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_wattage_input_3",
|
|
||||||
name="Input 3 Wattage",
|
|
||||||
api_key="ppv3",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_internal_wattage",
|
|
||||||
name="Internal wattage",
|
|
||||||
api_key="ppv",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_reactive_voltage",
|
|
||||||
name="Reactive voltage",
|
|
||||||
api_key="vacr",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_inverter_reactive_amperage",
|
|
||||||
name="Reactive amperage",
|
|
||||||
api_key="iacr",
|
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_frequency",
|
|
||||||
name="AC frequency",
|
|
||||||
api_key="fac",
|
|
||||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_current_wattage",
|
|
||||||
name="Output power",
|
|
||||||
api_key="pac",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_current_reactive_wattage",
|
|
||||||
name="Reactive wattage",
|
|
||||||
api_key="pacr",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_ipm_temperature",
|
|
||||||
name="Intelligent Power Management temperature",
|
|
||||||
api_key="ipmTemperature",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="inverter_temperature",
|
|
||||||
name="Temperature",
|
|
||||||
api_key="temperature",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_energy_today",
|
|
||||||
name="Energy today",
|
|
||||||
api_key="eacToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_energy_total",
|
|
||||||
name="Lifetime energy output",
|
|
||||||
api_key="eacTotal",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_energy_total_input_1",
|
|
||||||
name="Lifetime total energy input 1",
|
|
||||||
api_key="epv1Total",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_energy_today_input_1",
|
|
||||||
name="Energy Today Input 1",
|
|
||||||
api_key="epv1Today",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_voltage_input_1",
|
|
||||||
name="Input 1 voltage",
|
|
||||||
api_key="vpv1",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_amperage_input_1",
|
|
||||||
name="Input 1 Amperage",
|
|
||||||
api_key="ipv1",
|
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_wattage_input_1",
|
|
||||||
name="Input 1 Wattage",
|
|
||||||
api_key="ppv1",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_energy_total_input_2",
|
|
||||||
name="Lifetime total energy input 2",
|
|
||||||
api_key="epv2Total",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_energy_today_input_2",
|
|
||||||
name="Energy Today Input 2",
|
|
||||||
api_key="epv2Today",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_voltage_input_2",
|
|
||||||
name="Input 2 voltage",
|
|
||||||
api_key="vpv2",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_amperage_input_2",
|
|
||||||
name="Input 2 Amperage",
|
|
||||||
api_key="ipv2",
|
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_wattage_input_2",
|
|
||||||
name="Input 2 Wattage",
|
|
||||||
api_key="ppv2",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_internal_wattage",
|
|
||||||
name="Internal wattage",
|
|
||||||
api_key="ppv",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_reactive_voltage",
|
|
||||||
name="Reactive voltage",
|
|
||||||
api_key="vacrs",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_frequency",
|
|
||||||
name="AC frequency",
|
|
||||||
api_key="fac",
|
|
||||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_current_wattage",
|
|
||||||
name="Output power",
|
|
||||||
api_key="pac",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_temperature_1",
|
|
||||||
name="Temperature 1",
|
|
||||||
api_key="temp1",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_temperature_2",
|
|
||||||
name="Temperature 2",
|
|
||||||
api_key="temp2",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_temperature_3",
|
|
||||||
name="Temperature 3",
|
|
||||||
api_key="temp3",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_temperature_4",
|
|
||||||
name="Temperature 4",
|
|
||||||
api_key="temp4",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="tlx_temperature_5",
|
|
||||||
name="Temperature 5",
|
|
||||||
api_key="temp5",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
|
||||||
precision=1,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_storage_production_today",
|
|
||||||
name="Storage production today",
|
|
||||||
api_key="eBatDisChargeToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_storage_production_lifetime",
|
|
||||||
name="Lifetime Storage production",
|
|
||||||
api_key="eBatDisChargeTotal",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_grid_discharge_today",
|
|
||||||
name="Grid discharged today",
|
|
||||||
api_key="eacDisChargeToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_load_consumption_today",
|
|
||||||
name="Load consumption today",
|
|
||||||
api_key="eopDischrToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_load_consumption_lifetime",
|
|
||||||
name="Lifetime load consumption",
|
|
||||||
api_key="eopDischrTotal",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_grid_charged_today",
|
|
||||||
name="Grid charged today",
|
|
||||||
api_key="eacChargeToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_charge_storage_lifetime",
|
|
||||||
name="Lifetime storaged charged",
|
|
||||||
api_key="eChargeTotal",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_solar_production",
|
|
||||||
name="Solar power production",
|
|
||||||
api_key="ppv",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_battery_percentage",
|
|
||||||
name="Battery percentage",
|
|
||||||
api_key="capacity",
|
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
|
||||||
device_class=DEVICE_CLASS_BATTERY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_power_flow",
|
|
||||||
name="Storage charging/ discharging(-ve)",
|
|
||||||
api_key="pCharge",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_load_consumption_solar_storage",
|
|
||||||
name="Load consumption(Solar + Storage)",
|
|
||||||
api_key="rateVA",
|
|
||||||
native_unit_of_measurement="VA",
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_charge_today",
|
|
||||||
name="Charge today",
|
|
||||||
api_key="eChargeToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_import_from_grid",
|
|
||||||
name="Import from grid",
|
|
||||||
api_key="pAcInPut",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_import_from_grid_today",
|
|
||||||
name="Import from grid today",
|
|
||||||
api_key="eToUserToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_import_from_grid_total",
|
|
||||||
name="Import from grid total",
|
|
||||||
api_key="eToUserTotal",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_load_consumption",
|
|
||||||
name="Load consumption",
|
|
||||||
api_key="outPutPower",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_grid_voltage",
|
|
||||||
name="AC input voltage",
|
|
||||||
api_key="vGrid",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
precision=2,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_pv_charging_voltage",
|
|
||||||
name="PV charging voltage",
|
|
||||||
api_key="vpv",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
precision=2,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_ac_input_frequency_out",
|
|
||||||
name="AC input frequency",
|
|
||||||
api_key="freqOutPut",
|
|
||||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
|
||||||
precision=2,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_output_voltage",
|
|
||||||
name="Output voltage",
|
|
||||||
api_key="outPutVolt",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
precision=2,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_ac_output_frequency",
|
|
||||||
name="Ac output frequency",
|
|
||||||
api_key="freqGrid",
|
|
||||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
|
||||||
precision=2,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_current_PV",
|
|
||||||
name="Solar charge current",
|
|
||||||
api_key="iAcCharge",
|
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
|
||||||
precision=2,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_current_1",
|
|
||||||
name="Solar current to storage",
|
|
||||||
api_key="iChargePV1",
|
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
|
||||||
precision=2,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_grid_amperage_input",
|
|
||||||
name="Grid charge current",
|
|
||||||
api_key="chgCurr",
|
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
|
||||||
precision=2,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_grid_out_current",
|
|
||||||
name="Grid out current",
|
|
||||||
api_key="outPutCurrent",
|
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
|
||||||
precision=2,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_battery_voltage",
|
|
||||||
name="Battery voltage",
|
|
||||||
api_key="vBat",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
precision=2,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="storage_load_percentage",
|
|
||||||
name="Load percentage",
|
|
||||||
api_key="loadPercent",
|
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
|
||||||
device_class=DEVICE_CLASS_BATTERY,
|
|
||||||
precision=2,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|
||||||
# Values from 'mix_info' API call
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_statement_of_charge",
|
|
||||||
name="Statement of charge",
|
|
||||||
api_key="capacity",
|
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
|
||||||
device_class=DEVICE_CLASS_BATTERY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_battery_charge_today",
|
|
||||||
name="Battery charged today",
|
|
||||||
api_key="eBatChargeToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_battery_charge_lifetime",
|
|
||||||
name="Lifetime battery charged",
|
|
||||||
api_key="eBatChargeTotal",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_battery_discharge_today",
|
|
||||||
name="Battery discharged today",
|
|
||||||
api_key="eBatDisChargeToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_battery_discharge_lifetime",
|
|
||||||
name="Lifetime battery discharged",
|
|
||||||
api_key="eBatDisChargeTotal",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_solar_generation_today",
|
|
||||||
name="Solar energy today",
|
|
||||||
api_key="epvToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_solar_generation_lifetime",
|
|
||||||
name="Lifetime solar energy",
|
|
||||||
api_key="epvTotal",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_battery_discharge_w",
|
|
||||||
name="Battery discharging W",
|
|
||||||
api_key="pDischarge1",
|
|
||||||
native_unit_of_measurement=POWER_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_battery_voltage",
|
|
||||||
name="Battery voltage",
|
|
||||||
api_key="vbat",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_pv1_voltage",
|
|
||||||
name="PV1 voltage",
|
|
||||||
api_key="vpv1",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_pv2_voltage",
|
|
||||||
name="PV2 voltage",
|
|
||||||
api_key="vpv2",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
),
|
|
||||||
# Values from 'mix_totals' API call
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_load_consumption_today",
|
|
||||||
name="Load consumption today",
|
|
||||||
api_key="elocalLoadToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_load_consumption_lifetime",
|
|
||||||
name="Lifetime load consumption",
|
|
||||||
api_key="elocalLoadTotal",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_export_to_grid_today",
|
|
||||||
name="Export to grid today",
|
|
||||||
api_key="etoGridToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_export_to_grid_lifetime",
|
|
||||||
name="Lifetime export to grid",
|
|
||||||
api_key="etogridTotal",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL,
|
|
||||||
),
|
|
||||||
# Values from 'mix_system_status' API call
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_battery_charge",
|
|
||||||
name="Battery charging",
|
|
||||||
api_key="chargePower",
|
|
||||||
native_unit_of_measurement=POWER_KILO_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_load_consumption",
|
|
||||||
name="Load consumption",
|
|
||||||
api_key="pLocalLoad",
|
|
||||||
native_unit_of_measurement=POWER_KILO_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_wattage_pv_1",
|
|
||||||
name="PV1 Wattage",
|
|
||||||
api_key="pPv1",
|
|
||||||
native_unit_of_measurement=POWER_KILO_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_wattage_pv_2",
|
|
||||||
name="PV2 Wattage",
|
|
||||||
api_key="pPv2",
|
|
||||||
native_unit_of_measurement=POWER_KILO_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_wattage_pv_all",
|
|
||||||
name="All PV Wattage",
|
|
||||||
api_key="ppv",
|
|
||||||
native_unit_of_measurement=POWER_KILO_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_export_to_grid",
|
|
||||||
name="Export to grid",
|
|
||||||
api_key="pactogrid",
|
|
||||||
native_unit_of_measurement=POWER_KILO_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_import_from_grid",
|
|
||||||
name="Import from grid",
|
|
||||||
api_key="pactouser",
|
|
||||||
native_unit_of_measurement=POWER_KILO_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_battery_discharge_kw",
|
|
||||||
name="Battery discharging kW",
|
|
||||||
api_key="pdisCharge1",
|
|
||||||
native_unit_of_measurement=POWER_KILO_WATT,
|
|
||||||
device_class=DEVICE_CLASS_POWER,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_grid_voltage",
|
|
||||||
name="Grid voltage",
|
|
||||||
api_key="vAc1",
|
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
|
||||||
),
|
|
||||||
# Values from 'mix_detail' API call
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_system_production_today",
|
|
||||||
name="System production today (self-consumption + export)",
|
|
||||||
api_key="eCharge",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_load_consumption_solar_today",
|
|
||||||
name="Load consumption today (solar)",
|
|
||||||
api_key="eChargeToday",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_self_consumption_today",
|
|
||||||
name="Self consumption today (solar + battery)",
|
|
||||||
api_key="eChargeToday1",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_load_consumption_battery_today",
|
|
||||||
name="Load consumption today (battery)",
|
|
||||||
api_key="echarge1",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_import_from_grid_today",
|
|
||||||
name="Import from grid today (load)",
|
|
||||||
api_key="etouser",
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
),
|
|
||||||
# This sensor is manually created using the most recent X-Axis value from the chartData
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_last_update",
|
|
||||||
name="Last Data Update",
|
|
||||||
api_key="lastdataupdate",
|
|
||||||
native_unit_of_measurement=None,
|
|
||||||
device_class=DEVICE_CLASS_TIMESTAMP,
|
|
||||||
),
|
|
||||||
# Values from 'dashboard_data' API call
|
|
||||||
GrowattSensorEntityDescription(
|
|
||||||
key="mix_import_from_grid_today_combined",
|
|
||||||
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
|
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_device_list(api, config):
|
def get_device_list(api, config):
|
||||||
"""Retrieve the device list for the selected plant."""
|
"""Retrieve the device list for the selected plant."""
|
||||||
plant_id = config[CONF_PLANT_ID]
|
plant_id = config[CONF_PLANT_ID]
|
||||||
|
|
174
homeassistant/components/growatt_server/sensor_types/inverter.py
Normal file
174
homeassistant/components/growatt_server/sensor_types/inverter.py
Normal file
|
@ -0,0 +1,174 @@
|
||||||
|
"""Growatt Sensor definitions for the Inverter type."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import STATE_CLASS_TOTAL
|
||||||
|
from homeassistant.const import (
|
||||||
|
DEVICE_CLASS_CURRENT,
|
||||||
|
DEVICE_CLASS_ENERGY,
|
||||||
|
DEVICE_CLASS_POWER,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
DEVICE_CLASS_VOLTAGE,
|
||||||
|
ELECTRIC_CURRENT_AMPERE,
|
||||||
|
ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
ENERGY_KILO_WATT_HOUR,
|
||||||
|
FREQUENCY_HERTZ,
|
||||||
|
POWER_WATT,
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
)
|
||||||
|
|
||||||
|
from .sensor_entity_description import GrowattSensorEntityDescription
|
||||||
|
|
||||||
|
INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_energy_today",
|
||||||
|
name="Energy today",
|
||||||
|
api_key="powerToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_energy_total",
|
||||||
|
name="Lifetime energy output",
|
||||||
|
api_key="powerTotal",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
precision=1,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_voltage_input_1",
|
||||||
|
name="Input 1 voltage",
|
||||||
|
api_key="vpv1",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
precision=2,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_amperage_input_1",
|
||||||
|
name="Input 1 Amperage",
|
||||||
|
api_key="ipv1",
|
||||||
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
|
device_class=DEVICE_CLASS_CURRENT,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_wattage_input_1",
|
||||||
|
name="Input 1 Wattage",
|
||||||
|
api_key="ppv1",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_voltage_input_2",
|
||||||
|
name="Input 2 voltage",
|
||||||
|
api_key="vpv2",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_amperage_input_2",
|
||||||
|
name="Input 2 Amperage",
|
||||||
|
api_key="ipv2",
|
||||||
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
|
device_class=DEVICE_CLASS_CURRENT,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_wattage_input_2",
|
||||||
|
name="Input 2 Wattage",
|
||||||
|
api_key="ppv2",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_voltage_input_3",
|
||||||
|
name="Input 3 voltage",
|
||||||
|
api_key="vpv3",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_amperage_input_3",
|
||||||
|
name="Input 3 Amperage",
|
||||||
|
api_key="ipv3",
|
||||||
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
|
device_class=DEVICE_CLASS_CURRENT,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_wattage_input_3",
|
||||||
|
name="Input 3 Wattage",
|
||||||
|
api_key="ppv3",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_internal_wattage",
|
||||||
|
name="Internal wattage",
|
||||||
|
api_key="ppv",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_reactive_voltage",
|
||||||
|
name="Reactive voltage",
|
||||||
|
api_key="vacr",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_inverter_reactive_amperage",
|
||||||
|
name="Reactive amperage",
|
||||||
|
api_key="iacr",
|
||||||
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
|
device_class=DEVICE_CLASS_CURRENT,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_frequency",
|
||||||
|
name="AC frequency",
|
||||||
|
api_key="fac",
|
||||||
|
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_current_wattage",
|
||||||
|
name="Output power",
|
||||||
|
api_key="pac",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_current_reactive_wattage",
|
||||||
|
name="Reactive wattage",
|
||||||
|
api_key="pacr",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_ipm_temperature",
|
||||||
|
name="Intelligent Power Management temperature",
|
||||||
|
api_key="ipmTemperature",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="inverter_temperature",
|
||||||
|
name="Temperature",
|
||||||
|
api_key="temperature",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
)
|
253
homeassistant/components/growatt_server/sensor_types/mix.py
Normal file
253
homeassistant/components/growatt_server/sensor_types/mix.py
Normal file
|
@ -0,0 +1,253 @@
|
||||||
|
"""Growatt Sensor definitions for the Mix type."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import (
|
||||||
|
STATE_CLASS_TOTAL,
|
||||||
|
STATE_CLASS_TOTAL_INCREASING,
|
||||||
|
)
|
||||||
|
from homeassistant.const import (
|
||||||
|
DEVICE_CLASS_BATTERY,
|
||||||
|
DEVICE_CLASS_ENERGY,
|
||||||
|
DEVICE_CLASS_POWER,
|
||||||
|
DEVICE_CLASS_TIMESTAMP,
|
||||||
|
DEVICE_CLASS_VOLTAGE,
|
||||||
|
ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
ENERGY_KILO_WATT_HOUR,
|
||||||
|
PERCENTAGE,
|
||||||
|
POWER_KILO_WATT,
|
||||||
|
POWER_WATT,
|
||||||
|
)
|
||||||
|
|
||||||
|
from .sensor_entity_description import GrowattSensorEntityDescription
|
||||||
|
|
||||||
|
MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
||||||
|
# Values from 'mix_info' API call
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_statement_of_charge",
|
||||||
|
name="Statement of charge",
|
||||||
|
api_key="capacity",
|
||||||
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
device_class=DEVICE_CLASS_BATTERY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_battery_charge_today",
|
||||||
|
name="Battery charged today",
|
||||||
|
api_key="eBatChargeToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_battery_charge_lifetime",
|
||||||
|
name="Lifetime battery charged",
|
||||||
|
api_key="eBatChargeTotal",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_battery_discharge_today",
|
||||||
|
name="Battery discharged today",
|
||||||
|
api_key="eBatDisChargeToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_battery_discharge_lifetime",
|
||||||
|
name="Lifetime battery discharged",
|
||||||
|
api_key="eBatDisChargeTotal",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_solar_generation_today",
|
||||||
|
name="Solar energy today",
|
||||||
|
api_key="epvToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_solar_generation_lifetime",
|
||||||
|
name="Lifetime solar energy",
|
||||||
|
api_key="epvTotal",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_battery_discharge_w",
|
||||||
|
name="Battery discharging W",
|
||||||
|
api_key="pDischarge1",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_battery_voltage",
|
||||||
|
name="Battery voltage",
|
||||||
|
api_key="vbat",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_pv1_voltage",
|
||||||
|
name="PV1 voltage",
|
||||||
|
api_key="vpv1",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_pv2_voltage",
|
||||||
|
name="PV2 voltage",
|
||||||
|
api_key="vpv2",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
),
|
||||||
|
# Values from 'mix_totals' API call
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_load_consumption_today",
|
||||||
|
name="Load consumption today",
|
||||||
|
api_key="elocalLoadToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_load_consumption_lifetime",
|
||||||
|
name="Lifetime load consumption",
|
||||||
|
api_key="elocalLoadTotal",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_export_to_grid_today",
|
||||||
|
name="Export to grid today",
|
||||||
|
api_key="etoGridToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_export_to_grid_lifetime",
|
||||||
|
name="Lifetime export to grid",
|
||||||
|
api_key="etogridTotal",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
),
|
||||||
|
# Values from 'mix_system_status' API call
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_battery_charge",
|
||||||
|
name="Battery charging",
|
||||||
|
api_key="chargePower",
|
||||||
|
native_unit_of_measurement=POWER_KILO_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_load_consumption",
|
||||||
|
name="Load consumption",
|
||||||
|
api_key="pLocalLoad",
|
||||||
|
native_unit_of_measurement=POWER_KILO_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_wattage_pv_1",
|
||||||
|
name="PV1 Wattage",
|
||||||
|
api_key="pPv1",
|
||||||
|
native_unit_of_measurement=POWER_KILO_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_wattage_pv_2",
|
||||||
|
name="PV2 Wattage",
|
||||||
|
api_key="pPv2",
|
||||||
|
native_unit_of_measurement=POWER_KILO_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_wattage_pv_all",
|
||||||
|
name="All PV Wattage",
|
||||||
|
api_key="ppv",
|
||||||
|
native_unit_of_measurement=POWER_KILO_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_export_to_grid",
|
||||||
|
name="Export to grid",
|
||||||
|
api_key="pactogrid",
|
||||||
|
native_unit_of_measurement=POWER_KILO_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_import_from_grid",
|
||||||
|
name="Import from grid",
|
||||||
|
api_key="pactouser",
|
||||||
|
native_unit_of_measurement=POWER_KILO_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_battery_discharge_kw",
|
||||||
|
name="Battery discharging kW",
|
||||||
|
api_key="pdisCharge1",
|
||||||
|
native_unit_of_measurement=POWER_KILO_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_grid_voltage",
|
||||||
|
name="Grid voltage",
|
||||||
|
api_key="vAc1",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
),
|
||||||
|
# Values from 'mix_detail' API call
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_system_production_today",
|
||||||
|
name="System production today (self-consumption + export)",
|
||||||
|
api_key="eCharge",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_load_consumption_solar_today",
|
||||||
|
name="Load consumption today (solar)",
|
||||||
|
api_key="eChargeToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_self_consumption_today",
|
||||||
|
name="Self consumption today (solar + battery)",
|
||||||
|
api_key="eChargeToday1",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_load_consumption_battery_today",
|
||||||
|
name="Load consumption today (battery)",
|
||||||
|
api_key="echarge1",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_import_from_grid_today",
|
||||||
|
name="Import from grid today (load)",
|
||||||
|
api_key="etouser",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
# This sensor is manually created using the most recent X-Axis value from the chartData
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_last_update",
|
||||||
|
name="Last Data Update",
|
||||||
|
api_key="lastdataupdate",
|
||||||
|
native_unit_of_measurement=None,
|
||||||
|
device_class=DEVICE_CLASS_TIMESTAMP,
|
||||||
|
),
|
||||||
|
# Values from 'dashboard_data' API call
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="mix_import_from_grid_today_combined",
|
||||||
|
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
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL_INCREASING,
|
||||||
|
),
|
||||||
|
)
|
|
@ -0,0 +1,21 @@
|
||||||
|
"""Sensor Entity Description for the Growatt integration."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import SensorEntityDescription
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class GrowattRequiredKeysMixin:
|
||||||
|
"""Mixin for required keys."""
|
||||||
|
|
||||||
|
api_key: str
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class GrowattSensorEntityDescription(SensorEntityDescription, GrowattRequiredKeysMixin):
|
||||||
|
"""Describes Growatt sensor entity."""
|
||||||
|
|
||||||
|
precision: int | None = None
|
||||||
|
currency: bool = False
|
223
homeassistant/components/growatt_server/sensor_types/storage.py
Normal file
223
homeassistant/components/growatt_server/sensor_types/storage.py
Normal file
|
@ -0,0 +1,223 @@
|
||||||
|
"""Growatt Sensor definitions for the Storage type."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import STATE_CLASS_TOTAL
|
||||||
|
from homeassistant.const import (
|
||||||
|
DEVICE_CLASS_BATTERY,
|
||||||
|
DEVICE_CLASS_CURRENT,
|
||||||
|
DEVICE_CLASS_ENERGY,
|
||||||
|
DEVICE_CLASS_POWER,
|
||||||
|
DEVICE_CLASS_VOLTAGE,
|
||||||
|
ELECTRIC_CURRENT_AMPERE,
|
||||||
|
ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
ENERGY_KILO_WATT_HOUR,
|
||||||
|
FREQUENCY_HERTZ,
|
||||||
|
PERCENTAGE,
|
||||||
|
POWER_WATT,
|
||||||
|
)
|
||||||
|
|
||||||
|
from .sensor_entity_description import GrowattSensorEntityDescription
|
||||||
|
|
||||||
|
STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_storage_production_today",
|
||||||
|
name="Storage production today",
|
||||||
|
api_key="eBatDisChargeToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_storage_production_lifetime",
|
||||||
|
name="Lifetime Storage production",
|
||||||
|
api_key="eBatDisChargeTotal",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_grid_discharge_today",
|
||||||
|
name="Grid discharged today",
|
||||||
|
api_key="eacDisChargeToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_load_consumption_today",
|
||||||
|
name="Load consumption today",
|
||||||
|
api_key="eopDischrToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_load_consumption_lifetime",
|
||||||
|
name="Lifetime load consumption",
|
||||||
|
api_key="eopDischrTotal",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_grid_charged_today",
|
||||||
|
name="Grid charged today",
|
||||||
|
api_key="eacChargeToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_charge_storage_lifetime",
|
||||||
|
name="Lifetime storaged charged",
|
||||||
|
api_key="eChargeTotal",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_solar_production",
|
||||||
|
name="Solar power production",
|
||||||
|
api_key="ppv",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_battery_percentage",
|
||||||
|
name="Battery percentage",
|
||||||
|
api_key="capacity",
|
||||||
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
device_class=DEVICE_CLASS_BATTERY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_power_flow",
|
||||||
|
name="Storage charging/ discharging(-ve)",
|
||||||
|
api_key="pCharge",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_load_consumption_solar_storage",
|
||||||
|
name="Load consumption(Solar + Storage)",
|
||||||
|
api_key="rateVA",
|
||||||
|
native_unit_of_measurement="VA",
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_charge_today",
|
||||||
|
name="Charge today",
|
||||||
|
api_key="eChargeToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_import_from_grid",
|
||||||
|
name="Import from grid",
|
||||||
|
api_key="pAcInPut",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_import_from_grid_today",
|
||||||
|
name="Import from grid today",
|
||||||
|
api_key="eToUserToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_import_from_grid_total",
|
||||||
|
name="Import from grid total",
|
||||||
|
api_key="eToUserTotal",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_load_consumption",
|
||||||
|
name="Load consumption",
|
||||||
|
api_key="outPutPower",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_grid_voltage",
|
||||||
|
name="AC input voltage",
|
||||||
|
api_key="vGrid",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
precision=2,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_pv_charging_voltage",
|
||||||
|
name="PV charging voltage",
|
||||||
|
api_key="vpv",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
precision=2,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_ac_input_frequency_out",
|
||||||
|
name="AC input frequency",
|
||||||
|
api_key="freqOutPut",
|
||||||
|
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||||
|
precision=2,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_output_voltage",
|
||||||
|
name="Output voltage",
|
||||||
|
api_key="outPutVolt",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
precision=2,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_ac_output_frequency",
|
||||||
|
name="Ac output frequency",
|
||||||
|
api_key="freqGrid",
|
||||||
|
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||||
|
precision=2,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_current_PV",
|
||||||
|
name="Solar charge current",
|
||||||
|
api_key="iAcCharge",
|
||||||
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
|
device_class=DEVICE_CLASS_CURRENT,
|
||||||
|
precision=2,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_current_1",
|
||||||
|
name="Solar current to storage",
|
||||||
|
api_key="iChargePV1",
|
||||||
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
|
device_class=DEVICE_CLASS_CURRENT,
|
||||||
|
precision=2,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_grid_amperage_input",
|
||||||
|
name="Grid charge current",
|
||||||
|
api_key="chgCurr",
|
||||||
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
|
device_class=DEVICE_CLASS_CURRENT,
|
||||||
|
precision=2,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_grid_out_current",
|
||||||
|
name="Grid out current",
|
||||||
|
api_key="outPutCurrent",
|
||||||
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
|
device_class=DEVICE_CLASS_CURRENT,
|
||||||
|
precision=2,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_battery_voltage",
|
||||||
|
name="Battery voltage",
|
||||||
|
api_key="vBat",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
precision=2,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="storage_load_percentage",
|
||||||
|
name="Load percentage",
|
||||||
|
api_key="loadPercent",
|
||||||
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
device_class=DEVICE_CLASS_BATTERY,
|
||||||
|
precision=2,
|
||||||
|
),
|
||||||
|
)
|
197
homeassistant/components/growatt_server/sensor_types/tlx.py
Normal file
197
homeassistant/components/growatt_server/sensor_types/tlx.py
Normal file
|
@ -0,0 +1,197 @@
|
||||||
|
"""Growatt Sensor definitions for the TLX type."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import (
|
||||||
|
STATE_CLASS_TOTAL,
|
||||||
|
STATE_CLASS_TOTAL_INCREASING,
|
||||||
|
)
|
||||||
|
from homeassistant.const import (
|
||||||
|
DEVICE_CLASS_CURRENT,
|
||||||
|
DEVICE_CLASS_ENERGY,
|
||||||
|
DEVICE_CLASS_POWER,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
DEVICE_CLASS_VOLTAGE,
|
||||||
|
ELECTRIC_CURRENT_AMPERE,
|
||||||
|
ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
ENERGY_KILO_WATT_HOUR,
|
||||||
|
FREQUENCY_HERTZ,
|
||||||
|
POWER_WATT,
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
)
|
||||||
|
|
||||||
|
from .sensor_entity_description import GrowattSensorEntityDescription
|
||||||
|
|
||||||
|
TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_energy_today",
|
||||||
|
name="Energy today",
|
||||||
|
api_key="eacToday",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_energy_total",
|
||||||
|
name="Lifetime energy output",
|
||||||
|
api_key="eacTotal",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_energy_total_input_1",
|
||||||
|
name="Lifetime total energy input 1",
|
||||||
|
api_key="epv1Total",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_energy_today_input_1",
|
||||||
|
name="Energy Today Input 1",
|
||||||
|
api_key="epv1Today",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL_INCREASING,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_voltage_input_1",
|
||||||
|
name="Input 1 voltage",
|
||||||
|
api_key="vpv1",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_amperage_input_1",
|
||||||
|
name="Input 1 Amperage",
|
||||||
|
api_key="ipv1",
|
||||||
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
|
device_class=DEVICE_CLASS_CURRENT,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_wattage_input_1",
|
||||||
|
name="Input 1 Wattage",
|
||||||
|
api_key="ppv1",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_energy_total_input_2",
|
||||||
|
name="Lifetime total energy input 2",
|
||||||
|
api_key="epv2Total",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_energy_today_input_2",
|
||||||
|
name="Energy Today Input 2",
|
||||||
|
api_key="epv2Today",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL_INCREASING,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_voltage_input_2",
|
||||||
|
name="Input 2 voltage",
|
||||||
|
api_key="vpv2",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_amperage_input_2",
|
||||||
|
name="Input 2 Amperage",
|
||||||
|
api_key="ipv2",
|
||||||
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
|
device_class=DEVICE_CLASS_CURRENT,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_wattage_input_2",
|
||||||
|
name="Input 2 Wattage",
|
||||||
|
api_key="ppv2",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_internal_wattage",
|
||||||
|
name="Internal wattage",
|
||||||
|
api_key="ppv",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_reactive_voltage",
|
||||||
|
name="Reactive voltage",
|
||||||
|
api_key="vacrs",
|
||||||
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
|
device_class=DEVICE_CLASS_VOLTAGE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_frequency",
|
||||||
|
name="AC frequency",
|
||||||
|
api_key="fac",
|
||||||
|
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_current_wattage",
|
||||||
|
name="Output power",
|
||||||
|
api_key="pac",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_temperature_1",
|
||||||
|
name="Temperature 1",
|
||||||
|
api_key="temp1",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_temperature_2",
|
||||||
|
name="Temperature 2",
|
||||||
|
api_key="temp2",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_temperature_3",
|
||||||
|
name="Temperature 3",
|
||||||
|
api_key="temp3",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_temperature_4",
|
||||||
|
name="Temperature 4",
|
||||||
|
api_key="temp4",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="tlx_temperature_5",
|
||||||
|
name="Temperature 5",
|
||||||
|
api_key="temp5",
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||||
|
precision=1,
|
||||||
|
),
|
||||||
|
)
|
|
@ -0,0 +1,56 @@
|
||||||
|
"""Growatt Sensor definitions for Totals."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import STATE_CLASS_TOTAL
|
||||||
|
from homeassistant.const import (
|
||||||
|
DEVICE_CLASS_ENERGY,
|
||||||
|
DEVICE_CLASS_POWER,
|
||||||
|
ENERGY_KILO_WATT_HOUR,
|
||||||
|
POWER_WATT,
|
||||||
|
)
|
||||||
|
|
||||||
|
from .sensor_entity_description import GrowattSensorEntityDescription
|
||||||
|
|
||||||
|
TOTAL_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="total_money_today",
|
||||||
|
name="Total money today",
|
||||||
|
api_key="plantMoneyText",
|
||||||
|
currency=True,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="total_money_total",
|
||||||
|
name="Money lifetime",
|
||||||
|
api_key="totalMoneyText",
|
||||||
|
currency=True,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="total_energy_today",
|
||||||
|
name="Energy Today",
|
||||||
|
api_key="todayEnergy",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="total_output_power",
|
||||||
|
name="Output Power",
|
||||||
|
api_key="invTodayPpv",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="total_energy_output",
|
||||||
|
name="Lifetime energy output",
|
||||||
|
api_key="totalEnergy",
|
||||||
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
|
device_class=DEVICE_CLASS_ENERGY,
|
||||||
|
state_class=STATE_CLASS_TOTAL,
|
||||||
|
),
|
||||||
|
GrowattSensorEntityDescription(
|
||||||
|
key="total_maximum_output",
|
||||||
|
name="Maximum power",
|
||||||
|
api_key="nominalPower",
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
device_class=DEVICE_CLASS_POWER,
|
||||||
|
),
|
||||||
|
)
|
Loading…
Add table
Reference in a new issue