Add more sensors to aurora_abb_powerone (part 2) (#114097)

This commit is contained in:
Dave T 2024-03-24 11:04:12 +00:00 committed by GitHub
parent d14a442ac3
commit 579084a21e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 59 additions and 0 deletions

View File

@ -41,7 +41,10 @@ class AuroraAbbDataUpdateCoordinator(DataUpdateCoordinator[dict[str, float]]):
grid_current = self.client.measure(2, True)
power_watts = self.client.measure(3, True)
frequency = self.client.measure(4)
i_leak_dcdc = self.client.measure(6)
i_leak_inverter = self.client.measure(7)
temperature_c = self.client.measure(21)
r_iso = self.client.measure(30)
energy_wh = self.client.cumulated_energy(5)
[alarm, *_] = self.client.alarms()
except AuroraTimeoutError:
@ -64,7 +67,10 @@ class AuroraAbbDataUpdateCoordinator(DataUpdateCoordinator[dict[str, float]]):
data["grid_current"] = round(grid_current, 1)
data["instantaneouspower"] = round(power_watts, 1)
data["grid_frequency"] = round(frequency, 1)
data["i_leak_dcdc"] = i_leak_dcdc
data["i_leak_inverter"] = i_leak_inverter
data["temp"] = round(temperature_c, 1)
data["r_iso"] = r_iso
data["totalenergy"] = round(energy_wh / 1000, 2)
data["alarm"] = alarm
self.available = True

View File

@ -0,0 +1,12 @@
{
"entity": {
"sensor": {
"r_iso": {
"default": "mdi:omega"
},
"alarm": {
"default": "mdi:alert-octagon"
}
}
}
}

View File

@ -71,6 +71,24 @@ SENSOR_TYPES = [
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="i_leak_dcdc",
device_class=SensorDeviceClass.CURRENT,
entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT,
translation_key="i_leak_dcdc",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="i_leak_inverter",
device_class=SensorDeviceClass.CURRENT,
entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
state_class=SensorStateClass.MEASUREMENT,
translation_key="i_leak_inverter",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="alarm",
device_class=SensorDeviceClass.ENUM,
@ -92,6 +110,14 @@ SENSOR_TYPES = [
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="r_iso",
entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement="MOhms",
state_class=SensorStateClass.MEASUREMENT,
translation_key="r_iso",
entity_registry_enabled_default=False,
),
SensorEntityDescription(
key="totalenergy",
device_class=SensorDeviceClass.ENERGY,

View File

@ -33,8 +33,17 @@
"power_output": {
"name": "Power output"
},
"i_leak_dcdc": {
"name": "DC-DC leak current"
},
"i_leak_inverter": {
"name": "Inverter leak current"
},
"total_energy": {
"name": "Total energy"
},
"r_iso": {
"name": "Isolation resistance"
}
}
}

View File

@ -36,7 +36,10 @@ def _simulated_returns(index, global_measure=None):
2: 2.7894, # current
3: 45.678, # power
4: 50.789, # frequency
6: 1.2345, # leak dcdc
7: 2.3456, # leak inverter
21: 9.876, # temperature
30: 0.1234, # Isolation resistance
5: 12345, # energy
}
return returns[index]
@ -107,6 +110,9 @@ async def test_sensors(hass: HomeAssistant, entity_registry: EntityRegistry) ->
("sensor.mydevicename_grid_voltage", "235.9"),
("sensor.mydevicename_grid_current", "2.8"),
("sensor.mydevicename_frequency", "50.8"),
("sensor.mydevicename_dc_dc_leak_current", "1.2345"),
("sensor.mydevicename_inverter_leak_current", "2.3456"),
("sensor.mydevicename_isolation_resistance", "0.1234"),
]
for entity_id, _ in sensors:
assert not hass.states.get(entity_id)