fix EWS deviceType problem (#167597)

This commit is contained in:
Leo Periou
2026-04-07 15:49:21 +02:00
committed by GitHub
parent 920ffdb9b5
commit b52ce22ee7
2 changed files with 4 additions and 8 deletions
@@ -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"]
+2 -2
View File
@@ -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": {}},
}