mirror of
https://github.com/home-assistant/core.git
synced 2026-09-24 15:31:52 -05:00
Add address masks to Sofar diagnostics (#181628)
This commit is contained in:
@@ -30,6 +30,7 @@ async def async_get_config_entry_diagnostics(
|
||||
"readings_components": device.readings_components,
|
||||
"settings_components": device.settings_components,
|
||||
"active_faults": sorted(fault.key for fault in device.state.active_faults),
|
||||
"address_masks": await device.async_read_masks(),
|
||||
"raw": raw,
|
||||
},
|
||||
TO_REDACT,
|
||||
|
||||
@@ -3,6 +3,22 @@
|
||||
dict({
|
||||
'active_faults': list([
|
||||
]),
|
||||
'address_masks': dict({
|
||||
'1024': 0,
|
||||
'1088': 0,
|
||||
'1152': 0,
|
||||
'1280': 0,
|
||||
'1408': 0,
|
||||
'1472': 0,
|
||||
'1536': 0,
|
||||
'1600': 0,
|
||||
'1664': 0,
|
||||
'1728': 0,
|
||||
'4096': 0,
|
||||
'4160': 0,
|
||||
'4352': 0,
|
||||
'4480': 0,
|
||||
}),
|
||||
'inverter_type': 1537,
|
||||
'model': '4.4 KTLX-G3',
|
||||
'raw': dict({
|
||||
|
||||
@@ -60,3 +60,21 @@ async def test_diagnostics_redacts_serial_number(
|
||||
holding = diag["raw"]["holding"]
|
||||
for address in range(0x0445, 0x044C):
|
||||
assert str(address) not in holding
|
||||
|
||||
|
||||
async def test_diagnostics_decodes_address_masks(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
mock_connection: MockModbusConnection,
|
||||
init_integration: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test a mask is assembled from four registers, most significant first."""
|
||||
holding = mock_connection.for_unit(1).holding
|
||||
holding[0x0400] = 0x0001
|
||||
holding[0x0401] = 0x0002
|
||||
holding[0x0402] = 0x0003
|
||||
holding[0x0403] = 0x0004
|
||||
|
||||
diag = await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
|
||||
|
||||
assert diag["address_masks"]["1024"] == 0x0001000200030004
|
||||
|
||||
Reference in New Issue
Block a user