From b52ce22ee7cfdc58d088ee8d2ccf1bff6d6273c0 Mon Sep 17 00:00:00 2001 From: Leo Periou Date: Tue, 7 Apr 2026 15:49:21 +0200 Subject: [PATCH] fix EWS deviceType problem (#167597) --- homeassistant/components/myneomitis/select.py | 8 ++------ tests/components/myneomitis/test_select.py | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/myneomitis/select.py b/homeassistant/components/myneomitis/select.py index c2d70e70346d..6ae7b6a0c79d 100644 --- a/homeassistant/components/myneomitis/select.py +++ b/homeassistant/components/myneomitis/select.py @@ -104,12 +104,8 @@ async def async_setup_entry( def _create_entity(device: dict) -> MyNeoSelect: """Create a select entity for a device.""" if device["model"] == "EWS": - # According to the MyNeomitis API, EWS "relais" devices expose a "relayMode" - # field in their state, while "pilote" devices do not. We therefore use the - # presence of "relayMode" as an explicit heuristic to distinguish relais - # from pilote devices. If the upstream API changes this behavior, this - # detection logic must be revisited. - if "relayMode" in device.get("state", {}): + state = device.get("state") or {} + if state.get("deviceType") == 0: description = SELECT_TYPES["relais"] else: description = SELECT_TYPES["pilote"] diff --git a/tests/components/myneomitis/test_select.py b/tests/components/myneomitis/test_select.py index 8a3a9c7faf54..ce905206c4e0 100644 --- a/tests/components/myneomitis/test_select.py +++ b/tests/components/myneomitis/test_select.py @@ -14,7 +14,7 @@ RELAIS_DEVICE = { "_id": "relais1", "name": "Relais Device", "model": "EWS", - "state": {"relayMode": 1, "targetMode": 2}, + "state": {"deviceType": 0, "targetMode": 2}, "connected": True, "program": {"data": {}}, } @@ -23,7 +23,7 @@ PILOTE_DEVICE = { "_id": "pilote1", "name": "Pilote Device", "model": "EWS", - "state": {"targetMode": 1}, + "state": {"deviceType": 1, "targetMode": 1}, "connected": True, "program": {"data": {}}, }