mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 17:49:37 +01:00
Refactor indevolt integration to remove magic number constants (#169337)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,14 @@
|
||||
|
||||
from typing import Final
|
||||
|
||||
from indevolt_api import (
|
||||
IndevoltBattery,
|
||||
IndevoltConfig,
|
||||
IndevoltGrid,
|
||||
IndevoltSolar,
|
||||
IndevoltSystem,
|
||||
)
|
||||
|
||||
DOMAIN: Final = "indevolt"
|
||||
|
||||
# Default configurations
|
||||
@@ -11,107 +19,99 @@ DEFAULT_PORT: Final = 8080
|
||||
CONF_SERIAL_NUMBER: Final = "serial_number"
|
||||
CONF_GENERATION: Final = "generation"
|
||||
|
||||
# API write/read keys for energy and value for outdoor/portable mode
|
||||
ENERGY_MODE_READ_KEY: Final = "7101"
|
||||
ENERGY_MODE_WRITE_KEY: Final = "47005"
|
||||
PORTABLE_MODE: Final = 0
|
||||
|
||||
# Value for real-time control mode
|
||||
REALTIME_ACTION_MODE: Final = 4
|
||||
|
||||
# API key fields
|
||||
SENSOR_KEYS: Final[dict[int, list[str]]] = {
|
||||
1: [
|
||||
"606",
|
||||
"7101",
|
||||
"2101",
|
||||
"2108",
|
||||
"2107",
|
||||
"6000",
|
||||
"6001",
|
||||
"6002",
|
||||
"1501",
|
||||
"1502",
|
||||
"1664",
|
||||
"1665",
|
||||
"1666",
|
||||
"1667",
|
||||
"6105",
|
||||
"21028",
|
||||
"1505",
|
||||
IndevoltSystem.OPERATING_MODE,
|
||||
IndevoltConfig.READ_ENERGY_MODE,
|
||||
IndevoltSystem.INPUT_POWER,
|
||||
IndevoltSystem.OUTPUT_POWER,
|
||||
IndevoltSystem.TOTAL_INPUT_ENERGY,
|
||||
IndevoltBattery.POWER,
|
||||
IndevoltBattery.CHARGE_DISCHARGE_STATE,
|
||||
IndevoltBattery.SOC,
|
||||
IndevoltSolar.DC_OUTPUT_POWER,
|
||||
IndevoltSolar.DAILY_PRODUCTION,
|
||||
IndevoltSolar.DC_INPUT_POWER_1,
|
||||
IndevoltSolar.DC_INPUT_POWER_2,
|
||||
IndevoltSolar.DC_INPUT_POWER_3,
|
||||
IndevoltSolar.DC_INPUT_POWER_4,
|
||||
IndevoltConfig.READ_DISCHARGE_LIMIT,
|
||||
IndevoltGrid.METER_POWER_GEN1,
|
||||
IndevoltSolar.CUMULATIVE_PRODUCTION,
|
||||
],
|
||||
2: [
|
||||
"606",
|
||||
"7101",
|
||||
"2101",
|
||||
"2108",
|
||||
"2107",
|
||||
"6000",
|
||||
"6001",
|
||||
"6002",
|
||||
"1501",
|
||||
"1502",
|
||||
"1664",
|
||||
"1665",
|
||||
"1666",
|
||||
"1667",
|
||||
"142",
|
||||
"667",
|
||||
"2104",
|
||||
"2105",
|
||||
"11034",
|
||||
"6004",
|
||||
"6005",
|
||||
"6006",
|
||||
"6007",
|
||||
"11016",
|
||||
"2600",
|
||||
"2612",
|
||||
"1632",
|
||||
"1600",
|
||||
"1633",
|
||||
"1601",
|
||||
"1634",
|
||||
"1602",
|
||||
"1635",
|
||||
"1603",
|
||||
"9008",
|
||||
"9032",
|
||||
"9051",
|
||||
"9070",
|
||||
"9165",
|
||||
"9218",
|
||||
"9000",
|
||||
"9016",
|
||||
"9035",
|
||||
"9054",
|
||||
"9149",
|
||||
"9202",
|
||||
"9012",
|
||||
"9030",
|
||||
"9049",
|
||||
"9068",
|
||||
"9163",
|
||||
"9216",
|
||||
"9004",
|
||||
"9020",
|
||||
"9039",
|
||||
"9058",
|
||||
"9153",
|
||||
"9206",
|
||||
"9013",
|
||||
"19173",
|
||||
"19174",
|
||||
"19175",
|
||||
"19176",
|
||||
"19177",
|
||||
"680",
|
||||
"2618",
|
||||
"7171",
|
||||
"11011",
|
||||
"11009",
|
||||
"11010",
|
||||
"6105",
|
||||
"1505",
|
||||
IndevoltSystem.OPERATING_MODE,
|
||||
IndevoltConfig.READ_ENERGY_MODE,
|
||||
IndevoltSystem.INPUT_POWER,
|
||||
IndevoltSystem.OUTPUT_POWER,
|
||||
IndevoltSystem.TOTAL_INPUT_ENERGY,
|
||||
IndevoltBattery.POWER,
|
||||
IndevoltBattery.CHARGE_DISCHARGE_STATE,
|
||||
IndevoltBattery.SOC,
|
||||
IndevoltSolar.DC_OUTPUT_POWER,
|
||||
IndevoltSolar.DAILY_PRODUCTION,
|
||||
IndevoltSolar.DC_INPUT_POWER_1,
|
||||
IndevoltSolar.DC_INPUT_POWER_2,
|
||||
IndevoltSolar.DC_INPUT_POWER_3,
|
||||
IndevoltSolar.DC_INPUT_POWER_4,
|
||||
IndevoltBattery.RATED_CAPACITY_GEN2,
|
||||
IndevoltSystem.BYPASS_POWER,
|
||||
IndevoltSystem.TOTAL_OUTPUT_ENERGY,
|
||||
IndevoltSystem.OFF_GRID_OUTPUT_ENERGY,
|
||||
IndevoltSystem.BYPASS_INPUT_ENERGY,
|
||||
IndevoltBattery.DAILY_CHARGING_ENERGY,
|
||||
IndevoltBattery.DAILY_DISCHARGING_ENERGY,
|
||||
IndevoltBattery.TOTAL_CHARGING_ENERGY,
|
||||
IndevoltBattery.TOTAL_DISCHARGING_ENERGY,
|
||||
IndevoltGrid.METER_POWER_GEN2,
|
||||
IndevoltGrid.VOLTAGE,
|
||||
IndevoltGrid.FREQUENCY,
|
||||
IndevoltSolar.DC_INPUT_CURRENT_1,
|
||||
IndevoltSolar.DC_INPUT_VOLTAGE_1,
|
||||
IndevoltSolar.DC_INPUT_CURRENT_2,
|
||||
IndevoltSolar.DC_INPUT_VOLTAGE_2,
|
||||
IndevoltSolar.DC_INPUT_CURRENT_3,
|
||||
IndevoltSolar.DC_INPUT_VOLTAGE_3,
|
||||
IndevoltSolar.DC_INPUT_CURRENT_4,
|
||||
IndevoltSolar.DC_INPUT_VOLTAGE_4,
|
||||
IndevoltBattery.MAIN_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_1_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_2_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_3_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_4_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_5_SERIAL_NUMBER,
|
||||
IndevoltBattery.MAIN_SOC,
|
||||
IndevoltBattery.PACK_1_SOC,
|
||||
IndevoltBattery.PACK_2_SOC,
|
||||
IndevoltBattery.PACK_3_SOC,
|
||||
IndevoltBattery.PACK_4_SOC,
|
||||
IndevoltBattery.PACK_5_SOC,
|
||||
IndevoltBattery.MAIN_TEMPERATURE,
|
||||
IndevoltBattery.PACK_1_TEMPERATURE,
|
||||
IndevoltBattery.PACK_2_TEMPERATURE,
|
||||
IndevoltBattery.PACK_3_TEMPERATURE,
|
||||
IndevoltBattery.PACK_4_TEMPERATURE,
|
||||
IndevoltBattery.PACK_5_TEMPERATURE,
|
||||
IndevoltBattery.MAIN_VOLTAGE,
|
||||
IndevoltBattery.PACK_1_VOLTAGE,
|
||||
IndevoltBattery.PACK_2_VOLTAGE,
|
||||
IndevoltBattery.PACK_3_VOLTAGE,
|
||||
IndevoltBattery.PACK_4_VOLTAGE,
|
||||
IndevoltBattery.PACK_5_VOLTAGE,
|
||||
IndevoltBattery.MAIN_CURRENT,
|
||||
IndevoltBattery.PACK_1_CURRENT,
|
||||
IndevoltBattery.PACK_2_CURRENT,
|
||||
IndevoltBattery.PACK_3_CURRENT,
|
||||
IndevoltBattery.PACK_4_CURRENT,
|
||||
IndevoltBattery.PACK_5_CURRENT,
|
||||
IndevoltConfig.READ_BYPASS,
|
||||
IndevoltConfig.READ_GRID_CHARGING,
|
||||
IndevoltConfig.READ_LIGHT,
|
||||
IndevoltConfig.READ_MAX_AC_OUTPUT_POWER,
|
||||
IndevoltConfig.READ_INVERTER_INPUT_LIMIT,
|
||||
IndevoltConfig.READ_FEEDIN_POWER_LIMIT,
|
||||
IndevoltConfig.READ_DISCHARGE_LIMIT,
|
||||
IndevoltSolar.CUMULATIVE_PRODUCTION,
|
||||
],
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ from aiohttp import ClientError
|
||||
from indevolt_api import (
|
||||
IndevoltAPI,
|
||||
IndevoltConfig,
|
||||
IndevoltEnergyMode,
|
||||
IndevoltRealtimeAction,
|
||||
TimeOutException,
|
||||
)
|
||||
@@ -26,10 +27,6 @@ from .const import (
|
||||
CONF_SERIAL_NUMBER,
|
||||
DEFAULT_PORT,
|
||||
DOMAIN,
|
||||
ENERGY_MODE_READ_KEY,
|
||||
ENERGY_MODE_WRITE_KEY,
|
||||
PORTABLE_MODE,
|
||||
REALTIME_ACTION_MODE,
|
||||
SENSOR_KEYS,
|
||||
)
|
||||
|
||||
@@ -112,10 +109,10 @@ class IndevoltCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||
raise DeviceConnectionError(f"Device push failed: {err}") from err
|
||||
|
||||
async def async_switch_energy_mode(
|
||||
self, target_mode: int, refresh: bool = True
|
||||
self, target_mode: IndevoltEnergyMode, refresh: bool = True
|
||||
) -> None:
|
||||
"""Attempt to switch device to given energy mode."""
|
||||
current_mode = self.data.get(ENERGY_MODE_READ_KEY)
|
||||
current_mode = self.data.get(IndevoltConfig.READ_ENERGY_MODE)
|
||||
|
||||
# Ensure current energy mode is known
|
||||
if current_mode is None:
|
||||
@@ -125,7 +122,7 @@ class IndevoltCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||
)
|
||||
|
||||
# Ensure device is not in "Outdoor/Portable mode"
|
||||
if current_mode == PORTABLE_MODE:
|
||||
if current_mode == IndevoltEnergyMode.OUTDOOR_PORTABLE:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="energy_mode_change_unavailable_outdoor_portable",
|
||||
@@ -134,7 +131,9 @@ class IndevoltCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||
# Switch energy mode if required
|
||||
if current_mode != target_mode:
|
||||
try:
|
||||
success = await self.async_push_data(ENERGY_MODE_WRITE_KEY, target_mode)
|
||||
success = await self.async_push_data(
|
||||
IndevoltConfig.WRITE_ENERGY_MODE, target_mode
|
||||
)
|
||||
except (DeviceTimeoutError, DeviceConnectionError) as err:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
@@ -158,7 +157,9 @@ class IndevoltCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||
) -> None:
|
||||
"""Switch mode, execute action, and refresh for real-time control."""
|
||||
|
||||
await self.async_switch_energy_mode(REALTIME_ACTION_MODE, refresh=False)
|
||||
await self.async_switch_energy_mode(
|
||||
IndevoltEnergyMode.REAL_TIME_CONTROL, refresh=False
|
||||
)
|
||||
|
||||
success = False
|
||||
|
||||
@@ -180,4 +181,4 @@ class IndevoltCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||
|
||||
def get_emergency_soc(self) -> int:
|
||||
"""Get the emergency SOC value."""
|
||||
return int(self.data[str(IndevoltConfig.READ_DISCHARGE_LIMIT)])
|
||||
return int(self.data[IndevoltConfig.READ_DISCHARGE_LIMIT])
|
||||
|
||||
@@ -4,6 +4,8 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from indevolt_api import IndevoltBattery, IndevoltSystem
|
||||
|
||||
from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -15,13 +17,13 @@ from .coordinator import IndevoltConfigEntry
|
||||
TO_REDACT = {
|
||||
CONF_HOST,
|
||||
CONF_SERIAL_NUMBER,
|
||||
"0",
|
||||
"9008",
|
||||
"9032",
|
||||
"9051",
|
||||
"9070",
|
||||
"9218",
|
||||
"9165",
|
||||
IndevoltSystem.SERIAL_NUMBER,
|
||||
IndevoltBattery.MAIN_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_1_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_2_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_3_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_4_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_5_SERIAL_NUMBER,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Final
|
||||
|
||||
from indevolt_api import IndevoltConfig
|
||||
|
||||
from homeassistant.components.number import (
|
||||
NumberDeviceClass,
|
||||
NumberEntity,
|
||||
@@ -37,8 +39,8 @@ NUMBERS: Final = (
|
||||
key="discharge_limit",
|
||||
generation=[2],
|
||||
translation_key="discharge_limit",
|
||||
read_key="6105",
|
||||
write_key="1142",
|
||||
read_key=IndevoltConfig.READ_DISCHARGE_LIMIT,
|
||||
write_key=IndevoltConfig.WRITE_DISCHARGE_LIMIT,
|
||||
native_min_value=0,
|
||||
native_max_value=100,
|
||||
native_step=1,
|
||||
@@ -48,8 +50,8 @@ NUMBERS: Final = (
|
||||
key="max_ac_output_power",
|
||||
generation=[2],
|
||||
translation_key="max_ac_output_power",
|
||||
read_key="11011",
|
||||
write_key="1147",
|
||||
read_key=IndevoltConfig.READ_MAX_AC_OUTPUT_POWER,
|
||||
write_key=IndevoltConfig.WRITE_MAX_AC_OUTPUT_POWER,
|
||||
native_min_value=0,
|
||||
native_max_value=2400,
|
||||
native_step=100,
|
||||
@@ -60,8 +62,8 @@ NUMBERS: Final = (
|
||||
key="inverter_input_limit",
|
||||
generation=[2],
|
||||
translation_key="inverter_input_limit",
|
||||
read_key="11009",
|
||||
write_key="1138",
|
||||
read_key=IndevoltConfig.READ_INVERTER_INPUT_LIMIT,
|
||||
write_key=IndevoltConfig.WRITE_INVERTER_INPUT_LIMIT,
|
||||
native_min_value=100,
|
||||
native_max_value=2400,
|
||||
native_step=100,
|
||||
@@ -72,8 +74,8 @@ NUMBERS: Final = (
|
||||
key="feedin_power_limit",
|
||||
generation=[2],
|
||||
translation_key="feedin_power_limit",
|
||||
read_key="11010",
|
||||
write_key="1146",
|
||||
read_key=IndevoltConfig.READ_FEEDIN_POWER_LIMIT,
|
||||
write_key=IndevoltConfig.WRITE_FEEDIN_POWER_LIMIT,
|
||||
native_min_value=0,
|
||||
native_max_value=2400,
|
||||
native_step=100,
|
||||
|
||||
@@ -5,6 +5,8 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Final
|
||||
|
||||
from indevolt_api import IndevoltConfig, IndevoltEnergyMode
|
||||
|
||||
from homeassistant.components.select import SelectEntity, SelectEntityDescription
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
@@ -23,8 +25,8 @@ class IndevoltSelectEntityDescription(SelectEntityDescription):
|
||||
|
||||
read_key: str
|
||||
write_key: str
|
||||
value_to_option: dict[int, str]
|
||||
unavailable_values: list[int] = field(default_factory=list)
|
||||
value_to_option: dict[IndevoltEnergyMode, str]
|
||||
unavailable_values: list[IndevoltEnergyMode] = field(default_factory=list)
|
||||
generation: list[int] = field(default_factory=lambda: [1, 2])
|
||||
|
||||
|
||||
@@ -32,14 +34,14 @@ SELECTS: Final = (
|
||||
IndevoltSelectEntityDescription(
|
||||
key="energy_mode",
|
||||
translation_key="energy_mode",
|
||||
read_key="7101",
|
||||
write_key="47005",
|
||||
read_key=IndevoltConfig.READ_ENERGY_MODE,
|
||||
write_key=IndevoltConfig.WRITE_ENERGY_MODE,
|
||||
value_to_option={
|
||||
1: "self_consumed_prioritized",
|
||||
4: "real_time_control",
|
||||
5: "charge_discharge_schedule",
|
||||
IndevoltEnergyMode.SELF_CONSUMED_PRIORITIZED: "self_consumed_prioritized",
|
||||
IndevoltEnergyMode.REAL_TIME_CONTROL: "real_time_control",
|
||||
IndevoltEnergyMode.CHARGE_DISCHARGE_SCHEDULE: "charge_discharge_schedule",
|
||||
},
|
||||
unavailable_values=[0],
|
||||
unavailable_values=[IndevoltEnergyMode.OUTDOOR_PORTABLE],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Final
|
||||
|
||||
from indevolt_api import (
|
||||
IndevoltBattery,
|
||||
IndevoltConfig,
|
||||
IndevoltGrid,
|
||||
IndevoltSolar,
|
||||
IndevoltSystem,
|
||||
)
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
@@ -40,7 +48,7 @@ class IndevoltSensorEntityDescription(SensorEntityDescription):
|
||||
SENSORS: Final = (
|
||||
# System Operating Information
|
||||
IndevoltSensorEntityDescription(
|
||||
key="606",
|
||||
key=IndevoltSystem.OPERATING_MODE,
|
||||
translation_key="mode",
|
||||
state_mapping={"1000": "main", "1001": "sub", "1002": "standalone"},
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
@@ -48,7 +56,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="7101",
|
||||
key=IndevoltConfig.READ_ENERGY_MODE,
|
||||
translation_key="energy_mode",
|
||||
state_mapping={
|
||||
0: "outdoor_portable",
|
||||
@@ -59,7 +67,7 @@ SENSORS: Final = (
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="142",
|
||||
key=IndevoltBattery.RATED_CAPACITY_GEN2,
|
||||
generation=[2],
|
||||
translation_key="rated_capacity",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@@ -67,27 +75,27 @@ SENSORS: Final = (
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="6105",
|
||||
key=IndevoltConfig.READ_DISCHARGE_LIMIT,
|
||||
generation=[1],
|
||||
translation_key="discharge_limit",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="2101",
|
||||
key=IndevoltSystem.INPUT_POWER,
|
||||
translation_key="ac_input_power",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="2108",
|
||||
key=IndevoltSystem.OUTPUT_POWER,
|
||||
translation_key="ac_output_power",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="667",
|
||||
key=IndevoltSystem.BYPASS_POWER,
|
||||
generation=[2],
|
||||
translation_key="bypass_power",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
@@ -96,14 +104,14 @@ SENSORS: Final = (
|
||||
),
|
||||
# Electrical Energy Information
|
||||
IndevoltSensorEntityDescription(
|
||||
key="2107",
|
||||
key=IndevoltSystem.TOTAL_INPUT_ENERGY,
|
||||
translation_key="total_ac_input_energy",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="2104",
|
||||
key=IndevoltSystem.TOTAL_OUTPUT_ENERGY,
|
||||
generation=[2],
|
||||
translation_key="total_ac_output_energy",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@@ -111,7 +119,7 @@ SENSORS: Final = (
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="2105",
|
||||
key=IndevoltSystem.OFF_GRID_OUTPUT_ENERGY,
|
||||
generation=[2],
|
||||
translation_key="off_grid_output_energy",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@@ -119,7 +127,7 @@ SENSORS: Final = (
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="11034",
|
||||
key=IndevoltSystem.BYPASS_INPUT_ENERGY,
|
||||
generation=[2],
|
||||
translation_key="bypass_input_energy",
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
@@ -127,7 +135,7 @@ SENSORS: Final = (
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="6004",
|
||||
key=IndevoltBattery.DAILY_CHARGING_ENERGY,
|
||||
generation=[2],
|
||||
translation_key="battery_daily_charging_energy",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@@ -135,7 +143,7 @@ SENSORS: Final = (
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="6005",
|
||||
key=IndevoltBattery.DAILY_DISCHARGING_ENERGY,
|
||||
generation=[2],
|
||||
translation_key="battery_daily_discharging_energy",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@@ -143,7 +151,7 @@ SENSORS: Final = (
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="6006",
|
||||
key=IndevoltBattery.TOTAL_CHARGING_ENERGY,
|
||||
generation=[2],
|
||||
translation_key="battery_total_charging_energy",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@@ -151,7 +159,7 @@ SENSORS: Final = (
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="6007",
|
||||
key=IndevoltBattery.TOTAL_DISCHARGING_ENERGY,
|
||||
generation=[2],
|
||||
translation_key="battery_total_discharging_energy",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@@ -160,7 +168,7 @@ SENSORS: Final = (
|
||||
),
|
||||
# Electricity Meter Status
|
||||
IndevoltSensorEntityDescription(
|
||||
key="11016",
|
||||
key=IndevoltGrid.METER_POWER_GEN2,
|
||||
generation=[2],
|
||||
translation_key="meter_power",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
@@ -168,7 +176,7 @@ SENSORS: Final = (
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="21028",
|
||||
key=IndevoltGrid.METER_POWER_GEN1,
|
||||
generation=[1],
|
||||
translation_key="meter_power",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
@@ -177,7 +185,7 @@ SENSORS: Final = (
|
||||
),
|
||||
# Grid information
|
||||
IndevoltSensorEntityDescription(
|
||||
key="2600",
|
||||
key=IndevoltGrid.VOLTAGE,
|
||||
generation=[2],
|
||||
translation_key="grid_voltage",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@@ -186,7 +194,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="2612",
|
||||
key=IndevoltGrid.FREQUENCY,
|
||||
generation=[2],
|
||||
translation_key="grid_frequency",
|
||||
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||
@@ -196,20 +204,20 @@ SENSORS: Final = (
|
||||
),
|
||||
# Battery Pack Operating Parameters
|
||||
IndevoltSensorEntityDescription(
|
||||
key="6000",
|
||||
key=IndevoltBattery.POWER,
|
||||
translation_key="battery_power",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="6001",
|
||||
key=IndevoltBattery.CHARGE_DISCHARGE_STATE,
|
||||
translation_key="battery_charge_discharge_state",
|
||||
state_mapping={1000: "static", 1001: "charging", 1002: "discharging"},
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="6002",
|
||||
key=IndevoltBattery.SOC,
|
||||
translation_key="battery_soc",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
device_class=SensorDeviceClass.BATTERY,
|
||||
@@ -217,21 +225,21 @@ SENSORS: Final = (
|
||||
),
|
||||
# PV Operating Parameters
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1501",
|
||||
key=IndevoltSolar.DC_OUTPUT_POWER,
|
||||
translation_key="dc_output_power",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1502",
|
||||
key=IndevoltSolar.DAILY_PRODUCTION,
|
||||
translation_key="daily_production",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1505",
|
||||
key=IndevoltSolar.CUMULATIVE_PRODUCTION,
|
||||
translation_key="cumulative_production",
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
@@ -239,7 +247,7 @@ SENSORS: Final = (
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1632",
|
||||
key=IndevoltSolar.DC_INPUT_CURRENT_1,
|
||||
generation=[2],
|
||||
translation_key="dc_input_current_1",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@@ -248,7 +256,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1600",
|
||||
key=IndevoltSolar.DC_INPUT_VOLTAGE_1,
|
||||
generation=[2],
|
||||
translation_key="dc_input_voltage_1",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@@ -257,7 +265,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1664",
|
||||
key=IndevoltSolar.DC_INPUT_POWER_1,
|
||||
translation_key="dc_input_power_1",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
@@ -265,7 +273,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1633",
|
||||
key=IndevoltSolar.DC_INPUT_CURRENT_2,
|
||||
generation=[2],
|
||||
translation_key="dc_input_current_2",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@@ -274,7 +282,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1601",
|
||||
key=IndevoltSolar.DC_INPUT_VOLTAGE_2,
|
||||
generation=[2],
|
||||
translation_key="dc_input_voltage_2",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@@ -283,7 +291,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1665",
|
||||
key=IndevoltSolar.DC_INPUT_POWER_2,
|
||||
translation_key="dc_input_power_2",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
@@ -291,7 +299,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1634",
|
||||
key=IndevoltSolar.DC_INPUT_CURRENT_3,
|
||||
generation=[2],
|
||||
translation_key="dc_input_current_3",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@@ -300,7 +308,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1602",
|
||||
key=IndevoltSolar.DC_INPUT_VOLTAGE_3,
|
||||
generation=[2],
|
||||
translation_key="dc_input_voltage_3",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@@ -309,7 +317,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1666",
|
||||
key=IndevoltSolar.DC_INPUT_POWER_3,
|
||||
generation=[2],
|
||||
translation_key="dc_input_power_3",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
@@ -318,7 +326,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1635",
|
||||
key=IndevoltSolar.DC_INPUT_CURRENT_4,
|
||||
generation=[2],
|
||||
translation_key="dc_input_current_4",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@@ -327,7 +335,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1603",
|
||||
key=IndevoltSolar.DC_INPUT_VOLTAGE_4,
|
||||
generation=[2],
|
||||
translation_key="dc_input_voltage_4",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@@ -336,7 +344,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="1667",
|
||||
key=IndevoltSolar.DC_INPUT_POWER_4,
|
||||
generation=[2],
|
||||
translation_key="dc_input_power_4",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
@@ -346,42 +354,42 @@ SENSORS: Final = (
|
||||
),
|
||||
# Battery Pack Serial Numbers
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9008",
|
||||
key=IndevoltBattery.MAIN_SERIAL_NUMBER,
|
||||
generation=[2],
|
||||
translation_key="main_serial_number",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9032",
|
||||
key=IndevoltBattery.PACK_1_SERIAL_NUMBER,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_1_serial_number",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9051",
|
||||
key=IndevoltBattery.PACK_2_SERIAL_NUMBER,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_2_serial_number",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9070",
|
||||
key=IndevoltBattery.PACK_3_SERIAL_NUMBER,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_3_serial_number",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9165",
|
||||
key=IndevoltBattery.PACK_4_SERIAL_NUMBER,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_4_serial_number",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9218",
|
||||
key=IndevoltBattery.PACK_5_SERIAL_NUMBER,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_5_serial_number",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
@@ -389,7 +397,7 @@ SENSORS: Final = (
|
||||
),
|
||||
# Battery Pack SOC
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9000",
|
||||
key=IndevoltBattery.MAIN_SOC,
|
||||
generation=[2],
|
||||
translation_key="main_soc",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
@@ -399,7 +407,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9016",
|
||||
key=IndevoltBattery.PACK_1_SOC,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_1_soc",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
@@ -409,7 +417,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9035",
|
||||
key=IndevoltBattery.PACK_2_SOC,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_2_soc",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
@@ -419,7 +427,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9054",
|
||||
key=IndevoltBattery.PACK_3_SOC,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_3_soc",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
@@ -429,7 +437,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9149",
|
||||
key=IndevoltBattery.PACK_4_SOC,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_4_soc",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
@@ -439,7 +447,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9202",
|
||||
key=IndevoltBattery.PACK_5_SOC,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_5_soc",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
@@ -450,7 +458,7 @@ SENSORS: Final = (
|
||||
),
|
||||
# Battery Pack Temperature
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9012",
|
||||
key=IndevoltBattery.MAIN_TEMPERATURE,
|
||||
generation=[2],
|
||||
translation_key="main_temperature",
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
@@ -460,7 +468,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9030",
|
||||
key=IndevoltBattery.PACK_1_TEMPERATURE,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_1_temperature",
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
@@ -470,7 +478,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9049",
|
||||
key=IndevoltBattery.PACK_2_TEMPERATURE,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_2_temperature",
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
@@ -480,7 +488,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9068",
|
||||
key=IndevoltBattery.PACK_3_TEMPERATURE,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_3_temperature",
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
@@ -490,7 +498,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9163",
|
||||
key=IndevoltBattery.PACK_4_TEMPERATURE,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_4_temperature",
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
@@ -500,7 +508,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9216",
|
||||
key=IndevoltBattery.PACK_5_TEMPERATURE,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_5_temperature",
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
@@ -511,7 +519,7 @@ SENSORS: Final = (
|
||||
),
|
||||
# Battery Pack Voltage
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9004",
|
||||
key=IndevoltBattery.MAIN_VOLTAGE,
|
||||
generation=[2],
|
||||
translation_key="main_voltage",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@@ -521,7 +529,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9020",
|
||||
key=IndevoltBattery.PACK_1_VOLTAGE,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_1_voltage",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@@ -531,7 +539,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9039",
|
||||
key=IndevoltBattery.PACK_2_VOLTAGE,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_2_voltage",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@@ -541,7 +549,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9058",
|
||||
key=IndevoltBattery.PACK_3_VOLTAGE,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_3_voltage",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@@ -551,7 +559,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9153",
|
||||
key=IndevoltBattery.PACK_4_VOLTAGE,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_4_voltage",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@@ -561,7 +569,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9206",
|
||||
key=IndevoltBattery.PACK_5_VOLTAGE,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_5_voltage",
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
@@ -572,7 +580,7 @@ SENSORS: Final = (
|
||||
),
|
||||
# Battery Pack Current
|
||||
IndevoltSensorEntityDescription(
|
||||
key="9013",
|
||||
key=IndevoltBattery.MAIN_CURRENT,
|
||||
generation=[2],
|
||||
translation_key="main_current",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@@ -582,7 +590,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="19173",
|
||||
key=IndevoltBattery.PACK_1_CURRENT,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_1_current",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@@ -592,7 +600,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="19174",
|
||||
key=IndevoltBattery.PACK_2_CURRENT,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_2_current",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@@ -602,7 +610,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="19175",
|
||||
key=IndevoltBattery.PACK_3_CURRENT,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_3_current",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@@ -612,7 +620,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="19176",
|
||||
key=IndevoltBattery.PACK_4_CURRENT,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_4_current",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@@ -622,7 +630,7 @@ SENSORS: Final = (
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
IndevoltSensorEntityDescription(
|
||||
key="19177",
|
||||
key=IndevoltBattery.PACK_5_CURRENT,
|
||||
generation=[2],
|
||||
translation_key="battery_pack_5_current",
|
||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
@@ -635,11 +643,41 @@ SENSORS: Final = (
|
||||
|
||||
# Sensors per battery pack (SN, SOC, Temperature, Voltage, Current)
|
||||
BATTERY_PACK_SENSOR_KEYS = [
|
||||
("9032", "9016", "9030", "9020", "19173"), # Battery Pack 1
|
||||
("9051", "9035", "9049", "9039", "19174"), # Battery Pack 2
|
||||
("9070", "9054", "9068", "9058", "19175"), # Battery Pack 3
|
||||
("9165", "9149", "9163", "9153", "19176"), # Battery Pack 4
|
||||
("9218", "9202", "9216", "9206", "19177"), # Battery Pack 5
|
||||
(
|
||||
IndevoltBattery.PACK_1_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_1_SOC,
|
||||
IndevoltBattery.PACK_1_TEMPERATURE,
|
||||
IndevoltBattery.PACK_1_VOLTAGE,
|
||||
IndevoltBattery.PACK_1_CURRENT,
|
||||
), # Battery Pack 1
|
||||
(
|
||||
IndevoltBattery.PACK_2_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_2_SOC,
|
||||
IndevoltBattery.PACK_2_TEMPERATURE,
|
||||
IndevoltBattery.PACK_2_VOLTAGE,
|
||||
IndevoltBattery.PACK_2_CURRENT,
|
||||
), # Battery Pack 2
|
||||
(
|
||||
IndevoltBattery.PACK_3_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_3_SOC,
|
||||
IndevoltBattery.PACK_3_TEMPERATURE,
|
||||
IndevoltBattery.PACK_3_VOLTAGE,
|
||||
IndevoltBattery.PACK_3_CURRENT,
|
||||
), # Battery Pack 3
|
||||
(
|
||||
IndevoltBattery.PACK_4_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_4_SOC,
|
||||
IndevoltBattery.PACK_4_TEMPERATURE,
|
||||
IndevoltBattery.PACK_4_VOLTAGE,
|
||||
IndevoltBattery.PACK_4_CURRENT,
|
||||
), # Battery Pack 4
|
||||
(
|
||||
IndevoltBattery.PACK_5_SERIAL_NUMBER,
|
||||
IndevoltBattery.PACK_5_SOC,
|
||||
IndevoltBattery.PACK_5_TEMPERATURE,
|
||||
IndevoltBattery.PACK_5_VOLTAGE,
|
||||
IndevoltBattery.PACK_5_CURRENT,
|
||||
), # Battery Pack 5
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Final
|
||||
|
||||
from indevolt_api import IndevoltConfig
|
||||
|
||||
from homeassistant.components.switch import (
|
||||
SwitchDeviceClass,
|
||||
SwitchEntity,
|
||||
@@ -37,8 +39,8 @@ SWITCHES: Final = (
|
||||
key="grid_charging",
|
||||
translation_key="grid_charging",
|
||||
generation=[2],
|
||||
read_key="2618",
|
||||
write_key="1143",
|
||||
read_key=IndevoltConfig.READ_GRID_CHARGING,
|
||||
write_key=IndevoltConfig.WRITE_GRID_CHARGING,
|
||||
read_on_value=1001,
|
||||
read_off_value=1000,
|
||||
device_class=SwitchDeviceClass.SWITCH,
|
||||
@@ -47,16 +49,16 @@ SWITCHES: Final = (
|
||||
key="light",
|
||||
translation_key="light",
|
||||
generation=[2],
|
||||
read_key="7171",
|
||||
write_key="7265",
|
||||
read_key=IndevoltConfig.READ_LIGHT,
|
||||
write_key=IndevoltConfig.WRITE_LIGHT,
|
||||
device_class=SwitchDeviceClass.SWITCH,
|
||||
),
|
||||
IndevoltSwitchEntityDescription(
|
||||
key="bypass",
|
||||
translation_key="bypass",
|
||||
generation=[2],
|
||||
read_key="680",
|
||||
write_key="7266",
|
||||
read_key=IndevoltConfig.READ_BYPASS,
|
||||
write_key=IndevoltConfig.WRITE_BYPASS,
|
||||
device_class=SwitchDeviceClass.SWITCH,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -2,16 +2,11 @@
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from indevolt_api import IndevoltConfig, IndevoltEnergyMode
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
|
||||
from homeassistant.components.indevolt.const import (
|
||||
ENERGY_MODE_READ_KEY,
|
||||
ENERGY_MODE_WRITE_KEY,
|
||||
PORTABLE_MODE,
|
||||
REALTIME_ACTION_MODE,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
@@ -64,7 +59,7 @@ async def test_button_press_standby(
|
||||
|
||||
# Verify set_data was called for mode switch and stop() was called
|
||||
mock_indevolt.set_data.assert_called_once_with(
|
||||
ENERGY_MODE_WRITE_KEY, REALTIME_ACTION_MODE
|
||||
IndevoltConfig.WRITE_ENERGY_MODE, IndevoltEnergyMode.REAL_TIME_CONTROL
|
||||
)
|
||||
mock_indevolt.stop.assert_called_once()
|
||||
|
||||
@@ -78,7 +73,9 @@ async def test_button_press_standby_already_in_realtime_mode(
|
||||
"""Test pressing standby when already in real-time mode skips the mode switch."""
|
||||
|
||||
# Force real-time control mode
|
||||
mock_indevolt.fetch_data.return_value[ENERGY_MODE_READ_KEY] = REALTIME_ACTION_MODE
|
||||
mock_indevolt.fetch_data.return_value[IndevoltConfig.READ_ENERGY_MODE] = (
|
||||
IndevoltEnergyMode.REAL_TIME_CONTROL
|
||||
)
|
||||
with patch("homeassistant.components.indevolt.PLATFORMS", [Platform.BUTTON]):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
@@ -130,7 +127,9 @@ async def test_button_press_standby_portable_mode_error(
|
||||
"""Test pressing standby raises HomeAssistantError when device is in outdoor/portable mode."""
|
||||
|
||||
# Force outdoor/portable mode
|
||||
mock_indevolt.fetch_data.return_value[ENERGY_MODE_READ_KEY] = PORTABLE_MODE
|
||||
mock_indevolt.fetch_data.return_value[IndevoltConfig.READ_ENERGY_MODE] = (
|
||||
IndevoltEnergyMode.OUTDOOR_PORTABLE
|
||||
)
|
||||
with patch("homeassistant.components.indevolt.PLATFORMS", [Platform.BUTTON]):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from datetime import timedelta
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from indevolt_api import IndevoltConfig
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
@@ -18,18 +19,6 @@ from . import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
|
||||
|
||||
KEY_READ_DISCHARGE_LIMIT = "6105"
|
||||
KEY_WRITE_DISCHARGE_LIMIT = "1142"
|
||||
|
||||
KEY_READ_MAX_AC_OUTPUT_POWER = "11011"
|
||||
KEY_WRITE_MAX_AC_OUTPUT_POWER = "1147"
|
||||
|
||||
KEY_READ_INVERTER_INPUT_LIMIT = "11009"
|
||||
KEY_WRITE_INVERTER_INPUT_LIMIT = "1138"
|
||||
|
||||
KEY_READ_FEEDIN_POWER_LIMIT = "11010"
|
||||
KEY_WRITE_FEEDIN_POWER_LIMIT = "1146"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
@pytest.mark.parametrize("generation", [2], indirect=True)
|
||||
@@ -53,26 +42,26 @@ async def test_number(
|
||||
[
|
||||
(
|
||||
"number.cms_sf2000_discharge_limit",
|
||||
KEY_READ_DISCHARGE_LIMIT,
|
||||
KEY_WRITE_DISCHARGE_LIMIT,
|
||||
IndevoltConfig.READ_DISCHARGE_LIMIT,
|
||||
IndevoltConfig.WRITE_DISCHARGE_LIMIT,
|
||||
50,
|
||||
),
|
||||
(
|
||||
"number.cms_sf2000_max_ac_output_power",
|
||||
KEY_READ_MAX_AC_OUTPUT_POWER,
|
||||
KEY_WRITE_MAX_AC_OUTPUT_POWER,
|
||||
IndevoltConfig.READ_MAX_AC_OUTPUT_POWER,
|
||||
IndevoltConfig.WRITE_MAX_AC_OUTPUT_POWER,
|
||||
1500,
|
||||
),
|
||||
(
|
||||
"number.cms_sf2000_inverter_input_limit",
|
||||
KEY_READ_INVERTER_INPUT_LIMIT,
|
||||
KEY_WRITE_INVERTER_INPUT_LIMIT,
|
||||
IndevoltConfig.READ_INVERTER_INPUT_LIMIT,
|
||||
IndevoltConfig.WRITE_INVERTER_INPUT_LIMIT,
|
||||
800,
|
||||
),
|
||||
(
|
||||
"number.cms_sf2000_feed_in_power_limit",
|
||||
KEY_READ_FEEDIN_POWER_LIMIT,
|
||||
KEY_WRITE_FEEDIN_POWER_LIMIT,
|
||||
IndevoltConfig.READ_FEEDIN_POWER_LIMIT,
|
||||
IndevoltConfig.WRITE_FEEDIN_POWER_LIMIT,
|
||||
1200,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -4,6 +4,7 @@ from datetime import timedelta
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from indevolt_api import IndevoltConfig, IndevoltEnergyMode
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
@@ -18,9 +19,6 @@ from . import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
|
||||
|
||||
KEY_READ_ENERGY_MODE = "7101"
|
||||
KEY_WRITE_ENERGY_MODE = "47005"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
@pytest.mark.parametrize("generation", [2, 1], indirect=True)
|
||||
@@ -42,9 +40,9 @@ async def test_select(
|
||||
@pytest.mark.parametrize(
|
||||
("option", "expected_value"),
|
||||
[
|
||||
("self_consumed_prioritized", 1),
|
||||
("real_time_control", 4),
|
||||
("charge_discharge_schedule", 5),
|
||||
("self_consumed_prioritized", IndevoltEnergyMode.SELF_CONSUMED_PRIORITIZED),
|
||||
("real_time_control", IndevoltEnergyMode.REAL_TIME_CONTROL),
|
||||
("charge_discharge_schedule", IndevoltEnergyMode.CHARGE_DISCHARGE_SCHEDULE),
|
||||
],
|
||||
)
|
||||
async def test_select_option(
|
||||
@@ -62,7 +60,9 @@ async def test_select_option(
|
||||
mock_indevolt.set_data.reset_mock()
|
||||
|
||||
# Update mock data to reflect the new value
|
||||
mock_indevolt.fetch_data.return_value[KEY_READ_ENERGY_MODE] = expected_value
|
||||
mock_indevolt.fetch_data.return_value[IndevoltConfig.READ_ENERGY_MODE] = (
|
||||
expected_value
|
||||
)
|
||||
|
||||
# Attempt to change option
|
||||
await hass.services.async_call(
|
||||
@@ -73,7 +73,9 @@ async def test_select_option(
|
||||
)
|
||||
|
||||
# Verify set_data was called with correct parameters
|
||||
mock_indevolt.set_data.assert_called_with(KEY_WRITE_ENERGY_MODE, expected_value)
|
||||
mock_indevolt.set_data.assert_called_with(
|
||||
IndevoltConfig.WRITE_ENERGY_MODE, expected_value
|
||||
)
|
||||
|
||||
# Verify updated state
|
||||
assert (state := hass.states.get("select.cms_sf2000_energy_mode")) is not None
|
||||
@@ -120,7 +122,9 @@ async def test_select_unavailable_outdoor_portable(
|
||||
"""Test that entity is unavailable when device is in outdoor/portable mode (value 0)."""
|
||||
|
||||
# Update mock data to fake outdoor/portable mode
|
||||
mock_indevolt.fetch_data.return_value[KEY_READ_ENERGY_MODE] = 0
|
||||
mock_indevolt.fetch_data.return_value[IndevoltConfig.READ_ENERGY_MODE] = (
|
||||
IndevoltEnergyMode.OUTDOOR_PORTABLE
|
||||
)
|
||||
|
||||
# Initialize platform to test availability logic
|
||||
with patch("homeassistant.components.indevolt.PLATFORMS", [Platform.SELECT]):
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from indevolt_api import PowerExceedsMaxError, SocBelowMinimumError
|
||||
from indevolt_api import (
|
||||
IndevoltConfig,
|
||||
IndevoltEnergyMode,
|
||||
PowerExceedsMaxError,
|
||||
SocBelowMinimumError,
|
||||
)
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.indevolt.const import (
|
||||
DOMAIN,
|
||||
ENERGY_MODE_READ_KEY,
|
||||
ENERGY_MODE_WRITE_KEY,
|
||||
PORTABLE_MODE,
|
||||
REALTIME_ACTION_MODE,
|
||||
)
|
||||
from homeassistant.components.indevolt.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
@@ -67,7 +66,7 @@ async def test_service_charge_discharge(
|
||||
|
||||
# Verify energy mode switch and charge/discharge were called correctly
|
||||
mock_indevolt.set_data.assert_called_once_with(
|
||||
ENERGY_MODE_WRITE_KEY, REALTIME_ACTION_MODE
|
||||
IndevoltConfig.WRITE_ENERGY_MODE, IndevoltEnergyMode.REAL_TIME_CONTROL
|
||||
)
|
||||
if service_name == "charge":
|
||||
mock_indevolt.charge.assert_called_once_with(power, target_soc)
|
||||
@@ -312,7 +311,9 @@ async def test_charge_outdoor_portable(
|
||||
|
||||
# Force outdoor/portable mode
|
||||
coordinator = mock_config_entry.runtime_data
|
||||
coordinator.data[ENERGY_MODE_READ_KEY] = PORTABLE_MODE
|
||||
coordinator.data[IndevoltConfig.READ_ENERGY_MODE] = (
|
||||
IndevoltEnergyMode.OUTDOOR_PORTABLE
|
||||
)
|
||||
|
||||
# Mock call to start charging (device in outdoor/portable mode)
|
||||
with pytest.raises(HomeAssistantError) as exc_info:
|
||||
@@ -345,7 +346,7 @@ async def test_service_charge_missing_energy_mode(
|
||||
|
||||
# Remove current energy mode value
|
||||
coordinator = mock_config_entry.runtime_data
|
||||
del coordinator.data[ENERGY_MODE_READ_KEY]
|
||||
del coordinator.data[IndevoltConfig.READ_ENERGY_MODE]
|
||||
|
||||
# Mock call to start charging (current energy mode unknown)
|
||||
with pytest.raises(HomeAssistantError) as exc_info:
|
||||
|
||||
@@ -4,6 +4,7 @@ from datetime import timedelta
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from indevolt_api import IndevoltConfig
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
@@ -18,15 +19,6 @@ from . import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
|
||||
|
||||
KEY_READ_GRID_CHARGING = "2618"
|
||||
KEY_WRITE_GRID_CHARGING = "1143"
|
||||
|
||||
KEY_READ_LIGHT = "7171"
|
||||
KEY_WRITE_LIGHT = "7265"
|
||||
|
||||
KEY_READ_BYPASS = "680"
|
||||
KEY_WRITE_BYPASS = "7266"
|
||||
|
||||
DEFAULT_STATE_ON = 1
|
||||
DEFAULT_STATE_OFF = 0
|
||||
|
||||
@@ -53,20 +45,20 @@ async def test_switch(
|
||||
[
|
||||
(
|
||||
"switch.cms_sf2000_allow_grid_charging",
|
||||
KEY_READ_GRID_CHARGING,
|
||||
KEY_WRITE_GRID_CHARGING,
|
||||
IndevoltConfig.READ_GRID_CHARGING,
|
||||
IndevoltConfig.WRITE_GRID_CHARGING,
|
||||
1001,
|
||||
),
|
||||
(
|
||||
"switch.cms_sf2000_led_indicator",
|
||||
KEY_READ_LIGHT,
|
||||
KEY_WRITE_LIGHT,
|
||||
IndevoltConfig.READ_LIGHT,
|
||||
IndevoltConfig.WRITE_LIGHT,
|
||||
DEFAULT_STATE_ON,
|
||||
),
|
||||
(
|
||||
"switch.cms_sf2000_bypass_socket",
|
||||
KEY_READ_BYPASS,
|
||||
KEY_WRITE_BYPASS,
|
||||
IndevoltConfig.READ_BYPASS,
|
||||
IndevoltConfig.WRITE_BYPASS,
|
||||
DEFAULT_STATE_ON,
|
||||
),
|
||||
],
|
||||
@@ -112,20 +104,20 @@ async def test_switch_turn_on(
|
||||
[
|
||||
(
|
||||
"switch.cms_sf2000_allow_grid_charging",
|
||||
KEY_READ_GRID_CHARGING,
|
||||
KEY_WRITE_GRID_CHARGING,
|
||||
IndevoltConfig.READ_GRID_CHARGING,
|
||||
IndevoltConfig.WRITE_GRID_CHARGING,
|
||||
1000,
|
||||
),
|
||||
(
|
||||
"switch.cms_sf2000_led_indicator",
|
||||
KEY_READ_LIGHT,
|
||||
KEY_WRITE_LIGHT,
|
||||
IndevoltConfig.READ_LIGHT,
|
||||
IndevoltConfig.WRITE_LIGHT,
|
||||
DEFAULT_STATE_OFF,
|
||||
),
|
||||
(
|
||||
"switch.cms_sf2000_bypass_socket",
|
||||
KEY_READ_BYPASS,
|
||||
KEY_WRITE_BYPASS,
|
||||
IndevoltConfig.READ_BYPASS,
|
||||
IndevoltConfig.WRITE_BYPASS,
|
||||
DEFAULT_STATE_OFF,
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user