1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 17:49:37 +01:00

Add indevolt battery temp sensors for Gen-1 devices (#169404)

This commit is contained in:
A. Gideonse
2026-04-30 12:05:58 +02:00
committed by GitHub
parent 6fe0409dc2
commit fd6cf11dda
7 changed files with 360 additions and 69 deletions
@@ -41,6 +41,10 @@ SENSOR_KEYS: Final[dict[int, list[str]]] = {
IndevoltGrid.METER_CONNECTED,
IndevoltSolar.CUMULATIVE_PRODUCTION,
IndevoltSystem.HEATING_STATE,
IndevoltBattery.GEN_1_INVERTER_TEMPERATURE,
IndevoltBattery.GEN_1_PACK_1_TEMPERATURE,
IndevoltBattery.GEN_1_PACK_2_TEMPERATURE,
IndevoltBattery.GEN_1_PACK_3_TEMPERATURE,
],
2: [
IndevoltSystem.OPERATING_MODE,
+105 -61
View File
@@ -42,7 +42,7 @@ class IndevoltSensorEntityDescription(SensorEntityDescription):
"""Custom entity description class for Indevolt sensors."""
state_mapping: dict[str | int, str] = field(default_factory=dict)
generation: list[int] = field(default_factory=lambda: [1, 2])
generation: tuple[int, ...] = (1, 2)
SENSORS: Final = (
@@ -50,7 +50,11 @@ SENSORS: Final = (
IndevoltSensorEntityDescription(
key=IndevoltSystem.OPERATING_MODE,
translation_key="mode",
state_mapping={"1000": "main", "1001": "sub", "1002": "standalone"},
state_mapping={
"1000": "main",
"1001": "sub",
"1002": "standalone",
},
device_class=SensorDeviceClass.ENUM,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
@@ -68,7 +72,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.RATED_CAPACITY_GEN2,
generation=[2],
generation=(2,),
translation_key="rated_capacity",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@@ -76,7 +80,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltConfig.READ_DISCHARGE_LIMIT,
generation=[1],
generation=(1,),
translation_key="discharge_limit",
native_unit_of_measurement=PERCENTAGE,
),
@@ -96,7 +100,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSystem.BYPASS_POWER,
generation=[2],
generation=(2,),
translation_key="bypass_power",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
@@ -112,7 +116,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSystem.TOTAL_OUTPUT_ENERGY,
generation=[2],
generation=(2,),
translation_key="total_ac_output_energy",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@@ -120,7 +124,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSystem.OFF_GRID_OUTPUT_ENERGY,
generation=[2],
generation=(2,),
translation_key="off_grid_output_energy",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@@ -128,7 +132,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSystem.BYPASS_INPUT_ENERGY,
generation=[2],
generation=(2,),
translation_key="bypass_input_energy",
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@@ -136,7 +140,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.DAILY_CHARGING_ENERGY,
generation=[2],
generation=(2,),
translation_key="battery_daily_charging_energy",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@@ -144,7 +148,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.DAILY_DISCHARGING_ENERGY,
generation=[2],
generation=(2,),
translation_key="battery_daily_discharging_energy",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@@ -152,7 +156,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.TOTAL_CHARGING_ENERGY,
generation=[2],
generation=(2,),
translation_key="battery_total_charging_energy",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@@ -160,7 +164,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.TOTAL_DISCHARGING_ENERGY,
generation=[2],
generation=(2,),
translation_key="battery_total_discharging_energy",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
@@ -169,7 +173,7 @@ SENSORS: Final = (
# Electricity Meter Status
IndevoltSensorEntityDescription(
key=IndevoltGrid.METER_POWER_GEN2,
generation=[2],
generation=(2,),
translation_key="meter_power",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
@@ -177,7 +181,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltGrid.METER_POWER_GEN1,
generation=[1],
generation=(1,),
translation_key="meter_power",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
@@ -186,7 +190,7 @@ SENSORS: Final = (
# Grid information
IndevoltSensorEntityDescription(
key=IndevoltGrid.VOLTAGE,
generation=[2],
generation=(2,),
translation_key="grid_voltage",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
@@ -195,7 +199,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltGrid.FREQUENCY,
generation=[2],
generation=(2,),
translation_key="grid_frequency",
native_unit_of_measurement=UnitOfFrequency.HERTZ,
device_class=SensorDeviceClass.FREQUENCY,
@@ -248,7 +252,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSolar.DC_INPUT_CURRENT_1,
generation=[2],
generation=(2,),
translation_key="dc_input_current_1",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
@@ -257,7 +261,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSolar.DC_INPUT_VOLTAGE_1,
generation=[2],
generation=(2,),
translation_key="dc_input_voltage_1",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
@@ -274,7 +278,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSolar.DC_INPUT_CURRENT_2,
generation=[2],
generation=(2,),
translation_key="dc_input_current_2",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
@@ -283,7 +287,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSolar.DC_INPUT_VOLTAGE_2,
generation=[2],
generation=(2,),
translation_key="dc_input_voltage_2",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
@@ -300,7 +304,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSolar.DC_INPUT_CURRENT_3,
generation=[2],
generation=(2,),
translation_key="dc_input_current_3",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
@@ -309,7 +313,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSolar.DC_INPUT_VOLTAGE_3,
generation=[2],
generation=(2,),
translation_key="dc_input_voltage_3",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
@@ -318,7 +322,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSolar.DC_INPUT_POWER_3,
generation=[2],
generation=(2,),
translation_key="dc_input_power_3",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
@@ -327,7 +331,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSolar.DC_INPUT_CURRENT_4,
generation=[2],
generation=(2,),
translation_key="dc_input_current_4",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
@@ -336,7 +340,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSolar.DC_INPUT_VOLTAGE_4,
generation=[2],
generation=(2,),
translation_key="dc_input_voltage_4",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
@@ -345,7 +349,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltSolar.DC_INPUT_POWER_4,
generation=[2],
generation=(2,),
translation_key="dc_input_power_4",
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
@@ -355,42 +359,42 @@ SENSORS: Final = (
# Battery Pack Serial Numbers
IndevoltSensorEntityDescription(
key=IndevoltBattery.MAIN_SERIAL_NUMBER,
generation=[2],
generation=(2,),
translation_key="main_serial_number",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_1_SERIAL_NUMBER,
generation=[2],
generation=(2,),
translation_key="battery_pack_1_serial_number",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_2_SERIAL_NUMBER,
generation=[2],
generation=(2,),
translation_key="battery_pack_2_serial_number",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_3_SERIAL_NUMBER,
generation=[2],
generation=(2,),
translation_key="battery_pack_3_serial_number",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_4_SERIAL_NUMBER,
generation=[2],
generation=(2,),
translation_key="battery_pack_4_serial_number",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_5_SERIAL_NUMBER,
generation=[2],
generation=(2,),
translation_key="battery_pack_5_serial_number",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
@@ -398,7 +402,7 @@ SENSORS: Final = (
# Battery Pack SOC
IndevoltSensorEntityDescription(
key=IndevoltBattery.MAIN_SOC,
generation=[2],
generation=(2,),
translation_key="main_soc",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY,
@@ -408,7 +412,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_1_SOC,
generation=[2],
generation=(2,),
translation_key="battery_pack_1_soc",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY,
@@ -418,7 +422,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_2_SOC,
generation=[2],
generation=(2,),
translation_key="battery_pack_2_soc",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY,
@@ -428,7 +432,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_3_SOC,
generation=[2],
generation=(2,),
translation_key="battery_pack_3_soc",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY,
@@ -438,7 +442,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_4_SOC,
generation=[2],
generation=(2,),
translation_key="battery_pack_4_soc",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY,
@@ -448,7 +452,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_5_SOC,
generation=[2],
generation=(2,),
translation_key="battery_pack_5_soc",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY,
@@ -457,9 +461,49 @@ SENSORS: Final = (
entity_registry_enabled_default=False,
),
# Battery Pack Temperature
IndevoltSensorEntityDescription(
key=IndevoltBattery.GEN_1_INVERTER_TEMPERATURE,
generation=(1,),
translation_key="inverter_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.GEN_1_PACK_1_TEMPERATURE,
generation=(1,),
translation_key="battery_pack_1_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.GEN_1_PACK_2_TEMPERATURE,
generation=(1,),
translation_key="battery_pack_2_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.GEN_1_PACK_3_TEMPERATURE,
generation=(1,),
translation_key="battery_pack_3_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.MAIN_TEMPERATURE,
generation=[2],
generation=(2,),
translation_key="main_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
@@ -469,7 +513,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_1_TEMPERATURE,
generation=[2],
generation=(2,),
translation_key="battery_pack_1_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
@@ -479,7 +523,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_2_TEMPERATURE,
generation=[2],
generation=(2,),
translation_key="battery_pack_2_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
@@ -489,7 +533,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_3_TEMPERATURE,
generation=[2],
generation=(2,),
translation_key="battery_pack_3_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
@@ -499,7 +543,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_4_TEMPERATURE,
generation=[2],
generation=(2,),
translation_key="battery_pack_4_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
@@ -509,7 +553,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_5_TEMPERATURE,
generation=[2],
generation=(2,),
translation_key="battery_pack_5_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
@@ -520,7 +564,7 @@ SENSORS: Final = (
# Battery Pack Voltage
IndevoltSensorEntityDescription(
key=IndevoltBattery.MAIN_VOLTAGE,
generation=[2],
generation=(2,),
translation_key="main_voltage",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
@@ -530,7 +574,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_1_VOLTAGE,
generation=[2],
generation=(2,),
translation_key="battery_pack_1_voltage",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
@@ -540,7 +584,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_2_VOLTAGE,
generation=[2],
generation=(2,),
translation_key="battery_pack_2_voltage",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
@@ -550,7 +594,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_3_VOLTAGE,
generation=[2],
generation=(2,),
translation_key="battery_pack_3_voltage",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
@@ -560,7 +604,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_4_VOLTAGE,
generation=[2],
generation=(2,),
translation_key="battery_pack_4_voltage",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
@@ -570,7 +614,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_5_VOLTAGE,
generation=[2],
generation=(2,),
translation_key="battery_pack_5_voltage",
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
@@ -581,7 +625,7 @@ SENSORS: Final = (
# Battery Pack Current
IndevoltSensorEntityDescription(
key=IndevoltBattery.MAIN_CURRENT,
generation=[2],
generation=(2,),
translation_key="main_current",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
@@ -591,7 +635,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_1_CURRENT,
generation=[2],
generation=(2,),
translation_key="battery_pack_1_current",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
@@ -601,7 +645,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_2_CURRENT,
generation=[2],
generation=(2,),
translation_key="battery_pack_2_current",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
@@ -611,7 +655,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_3_CURRENT,
generation=[2],
generation=(2,),
translation_key="battery_pack_3_current",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
@@ -621,7 +665,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_4_CURRENT,
generation=[2],
generation=(2,),
translation_key="battery_pack_4_current",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
@@ -631,7 +675,7 @@ SENSORS: Final = (
),
IndevoltSensorEntityDescription(
key=IndevoltBattery.PACK_5_CURRENT,
generation=[2],
generation=(2,),
translation_key="battery_pack_5_current",
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
@@ -649,35 +693,35 @@ BATTERY_PACK_SENSOR_KEYS = [
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
),
]
@@ -267,6 +267,9 @@
"grid_voltage": {
"name": "Grid voltage"
},
"inverter_temperature": {
"name": "Inverter temperature"
},
"main_current": {
"name": "Main current"
},
+8 -1
View File
@@ -103,8 +103,15 @@ def mock_indevolt(generation: int) -> Generator[AsyncMock]:
),
):
# Mock coordinator API (get_data)
# fetch_data filters by requested keys so that SENSOR_KEYS omissions
# cause test failures instead of silently returning extra fixture data.
# Tests that mutate fetch_data.return_value[key] to simulate state
# changes will still work because side_effect reads from return_value.
client = mock_client.return_value
client.fetch_data.return_value = fixture_data
client.fetch_data.return_value = dict(fixture_data)
client.fetch_data.side_effect = lambda keys: {
k: v for k, v in client.fetch_data.return_value.items() if k in keys
}
client.set_data.return_value = True
client.stop.return_value = True
client.charge.return_value = True
@@ -20,5 +20,9 @@
"6007": 256.39,
"7120": 1000,
"7121": 1,
"7600": 35.2,
"7605": 28.1,
"7620": 27.4,
"7621": 29.0,
"21028": 0
}
@@ -2,7 +2,6 @@
# name: test_diagnostics[1]
dict({
'coordinator_data': dict({
'0': '**REDACTED**',
'1501': 0,
'1502': 0,
'1505': 553673,
@@ -15,15 +14,15 @@
'6000': 0,
'6001': 1000,
'6002': 92,
'6004': 0,
'6005': 0,
'6006': 277.16,
'6007': 256.39,
'606': '1000',
'6105': 5,
'7101': 5,
'7120': 1000,
'7121': 1,
'7600': 35.2,
'7605': 28.1,
'7620': 27.4,
'7621': 29.0,
}),
'device': dict({
'firmware_version': '1.2.3',
@@ -43,7 +42,6 @@
# name: test_diagnostics[2]
dict({
'coordinator_data': dict({
'0': '**REDACTED**',
'11009': 50.2,
'11010': 52.3,
'11011': 85,
@@ -53,7 +51,6 @@
'1501': 0,
'1502': 0,
'1505': 553673,
'1532': 150,
'1600': 48.5,
'1601': 48.3,
'1602': 48.7,
@@ -177,6 +177,180 @@
'state': 'static',
})
# ---
# name: test_sensor[1][sensor.bk1600_battery_pack_1_temperature-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.bk1600_battery_pack_1_temperature',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Battery pack 1 temperature',
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
'original_icon': None,
'original_name': 'Battery pack 1 temperature',
'platform': 'indevolt',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'battery_pack_1_temperature',
'unique_id': 'BK1600-12345678_7605',
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_sensor[1][sensor.bk1600_battery_pack_1_temperature-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'temperature',
'friendly_name': 'BK1600 Battery pack 1 temperature',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.bk1600_battery_pack_1_temperature',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '28.1',
})
# ---
# name: test_sensor[1][sensor.bk1600_battery_pack_2_temperature-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.bk1600_battery_pack_2_temperature',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Battery pack 2 temperature',
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
'original_icon': None,
'original_name': 'Battery pack 2 temperature',
'platform': 'indevolt',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'battery_pack_2_temperature',
'unique_id': 'BK1600-12345678_7620',
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_sensor[1][sensor.bk1600_battery_pack_2_temperature-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'temperature',
'friendly_name': 'BK1600 Battery pack 2 temperature',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.bk1600_battery_pack_2_temperature',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '27.4',
})
# ---
# name: test_sensor[1][sensor.bk1600_battery_pack_3_temperature-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.bk1600_battery_pack_3_temperature',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Battery pack 3 temperature',
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
'original_icon': None,
'original_name': 'Battery pack 3 temperature',
'platform': 'indevolt',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'battery_pack_3_temperature',
'unique_id': 'BK1600-12345678_7621',
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_sensor[1][sensor.bk1600_battery_pack_3_temperature-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'temperature',
'friendly_name': 'BK1600 Battery pack 3 temperature',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.bk1600_battery_pack_3_temperature',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '29.0',
})
# ---
# name: test_sensor[1][sensor.bk1600_battery_power-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
@@ -760,6 +934,64 @@
'state': 'charge_discharge_schedule',
})
# ---
# name: test_sensor[1][sensor.bk1600_inverter_temperature-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': dict({
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.bk1600_inverter_temperature',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Inverter temperature',
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
'original_icon': None,
'original_name': 'Inverter temperature',
'platform': 'indevolt',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'inverter_temperature',
'unique_id': 'BK1600-12345678_7600',
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_sensor[1][sensor.bk1600_inverter_temperature-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'temperature',
'friendly_name': 'BK1600 Inverter temperature',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.bk1600_inverter_temperature',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '35.2',
})
# ---
# name: test_sensor[1][sensor.bk1600_meter_power-entry]
EntityRegistryEntrySnapshot({
'aliases': list([