mirror of
https://github.com/home-assistant/core.git
synced 2026-08-27 18:14:46 -05:00
fix EWS deviceType problem (#167597)
This commit is contained in:
@@ -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"]
|
||||
|
||||
@@ -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": {}},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user