mirror of
https://github.com/home-assistant/core.git
synced 2026-12-04 12:50:45 -04:00
Add error code sensor to Overkiz (#186940)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Mick Vleeshouwer <mick@imick.nl>
This commit is contained in:
co-authored by
Claude Opus 5.5
Mick Vleeshouwer
parent
1d6681b0a2
commit
913756b79c
@@ -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,
|
||||
|
||||
@@ -2188,6 +2188,11 @@
|
||||
"minute": 22,
|
||||
"second": 57
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "core:ErrorCodeState",
|
||||
"type": 1,
|
||||
"value": 0
|
||||
}
|
||||
],
|
||||
"available": true,
|
||||
|
||||
@@ -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': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||
'entity_id': 'sensor.living_room_heater_error_code',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'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({
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Living room heater Error code',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.living_room_heater_error_code',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'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': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
})
|
||||
# ---
|
||||
# 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({
|
||||
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'temperature',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Somfy TaHoma Switch Living room temperature Temperature',
|
||||
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Living room heater Living room temperature Temperature',
|
||||
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.somfy_tahoma_switch_living_room_temperature_temperature',
|
||||
'entity_id': 'sensor.living_room_heater_living_room_temperature_temperature',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user