From 913756b79c84efb5a222e80868614493ab7e07d9 Mon Sep 17 00:00:00 2001 From: koukihai Date: Tue, 20 Oct 2026 23:04:39 +0200 Subject: [PATCH] Add error code sensor to Overkiz (#186940) Co-authored-by: Claude Opus 5.5 Co-authored-by: Mick Vleeshouwer --- homeassistant/components/overkiz/sensor.py | 5 ++ .../setup/cloud_atlantic_cozytouch.json | 5 ++ .../overkiz/snapshots/test_sensor.ambr | 60 +++++++++++++++++-- tests/components/overkiz/test_sensor.py | 42 +++++++++++++ 4 files changed, 107 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/overkiz/sensor.py b/homeassistant/components/overkiz/sensor.py index c90ce715a6d0..9508576a90b0 100644 --- a/homeassistant/components/overkiz/sensor.py +++ b/homeassistant/components/overkiz/sensor.py @@ -448,6 +448,11 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [ device_class=SensorDeviceClass.ENUM, options=["dead", "low_battery", "maintenance_required", "no_defect"], ), + OverkizSensorDescription( + key=OverkizState.CORE_ERROR_CODE, + name="Error code", + entity_category=EntityCategory.DIAGNOSTIC, + ), # DomesticHotWaterProduction/WaterHeatingSystem OverkizSensorDescription( key=OverkizState.IO_HEAT_PUMP_OPERATING_TIME, diff --git a/tests/components/overkiz/fixtures/setup/cloud_atlantic_cozytouch.json b/tests/components/overkiz/fixtures/setup/cloud_atlantic_cozytouch.json index ba77297a89d7..dc66bdbbfb6a 100644 --- a/tests/components/overkiz/fixtures/setup/cloud_atlantic_cozytouch.json +++ b/tests/components/overkiz/fixtures/setup/cloud_atlantic_cozytouch.json @@ -2188,6 +2188,11 @@ "minute": 22, "second": 57 } + }, + { + "name": "core:ErrorCodeState", + "type": 1, + "value": 0 } ], "available": true, diff --git a/tests/components/overkiz/snapshots/test_sensor.ambr b/tests/components/overkiz/snapshots/test_sensor.ambr index 225684056e7c..5105bd0c1083 100644 --- a/tests/components/overkiz/snapshots/test_sensor.ambr +++ b/tests/components/overkiz/snapshots/test_sensor.ambr @@ -1,5 +1,55 @@ # serializer version: 1 -# name: test_sensor_entities_snapshot[cloud_atlantic_cozytouch.json][sensor.somfy_tahoma_switch_living_room_temperature_temperature-entry] +# name: test_sensor_entities_snapshot[cloud_atlantic_cozytouch.json][sensor.living_room_heater_error_code-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.living_room_heater_error_code', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Error code', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Error code', + 'platform': 'overkiz', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': 'modbuslink://1234-5678-5643/1#1-core:ErrorCodeState', + 'unit_of_measurement': None, + }) +# --- +# name: test_sensor_entities_snapshot[cloud_atlantic_cozytouch.json][sensor.living_room_heater_error_code-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'Living room heater Error code', + }), + 'context': , + 'entity_id': 'sensor.living_room_heater_error_code', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_sensor_entities_snapshot[cloud_atlantic_cozytouch.json][sensor.living_room_heater_living_room_temperature_temperature-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ None, @@ -15,7 +65,7 @@ 'disabled_by': None, 'domain': 'sensor', 'entity_category': None, - 'entity_id': 'sensor.somfy_tahoma_switch_living_room_temperature_temperature', + 'entity_id': 'sensor.living_room_heater_living_room_temperature_temperature', 'has_entity_name': True, 'hidden_by': None, 'icon': None, @@ -41,16 +91,16 @@ 'unit_of_measurement': , }) # --- -# name: test_sensor_entities_snapshot[cloud_atlantic_cozytouch.json][sensor.somfy_tahoma_switch_living_room_temperature_temperature-state] +# name: test_sensor_entities_snapshot[cloud_atlantic_cozytouch.json][sensor.living_room_heater_living_room_temperature_temperature-state] StateSnapshot({ 'attributes': ReadOnlyDict({ : 'temperature', - : 'Somfy TaHoma Switch Living room temperature Temperature', + : 'Living room heater Living room temperature Temperature', : , : , }), 'context': , - 'entity_id': 'sensor.somfy_tahoma_switch_living_room_temperature_temperature', + 'entity_id': 'sensor.living_room_heater_living_room_temperature_temperature', 'last_changed': , 'last_reported': , 'last_updated': , diff --git a/tests/components/overkiz/test_sensor.py b/tests/components/overkiz/test_sensor.py index 866ffdad1eeb..4f0956afb751 100644 --- a/tests/components/overkiz/test_sensor.py +++ b/tests/components/overkiz/test_sensor.py @@ -63,6 +63,12 @@ DHW_HEAT_PUMP_OPERATING_TIME = FixtureDevice( "io://1234-5678-5643/6713703#1", "sensor.my_home_water_heater_heat_pump_operating_time", ) +# Atlantic heater exposing core:ErrorCodeState (0 means no fault) +COZYTOUCH_ERROR_CODE = FixtureDevice( + "setup/cloud_atlantic_cozytouch.json", + "modbuslink://1234-5678-5643/1#1", + "sensor.living_room_heater_error_code", +) # Hitachi Yutaki heat pump exposing energy and temperature sensors YUTAKI = FixtureDevice( "setup/cloud_hi_kumo_europe.json", @@ -298,6 +304,42 @@ async def test_sensor_dynamic_unit_with_zero_value( assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfEnergy.KILO_WATT_HOUR +async def test_sensor_error_code_state_update( + hass: HomeAssistant, + setup_overkiz_integration: SetupOverkizIntegration, + mock_client: MockOverkizClient, + freezer: FrozenDateTimeFactory, +) -> None: + """Test error code reports a fault and its clearing (0 → 370 → 0).""" + await setup_overkiz_integration(fixture=COZYTOUCH_ERROR_CODE.fixture) + + state = hass.states.get(COZYTOUCH_ERROR_CODE.entity_id) + assert state + assert state.state == "0" + + for value in (370, 0): + await async_deliver_events( + hass, + freezer, + mock_client, + [ + device_state_changed_event( + device_url=COZYTOUCH_ERROR_CODE.device_url, + device_states=[ + { + "name": OverkizState.CORE_ERROR_CODE.value, + "type": 1, + "value": value, + }, + ], + ) + ], + ) + + state = hass.states.get(COZYTOUCH_ERROR_CODE.entity_id) + assert state.state == str(value) + + async def test_sensor_unavailability( hass: HomeAssistant, setup_overkiz_integration: SetupOverkizIntegration,