Skip to content

Commit a0a4cc9

Browse files
authored
Fix consumption types error (#35)
1 parent 1f20d96 commit a0a4cc9

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

python_scripts/shellies_discovery_gen2.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -1014,15 +1014,11 @@ def configure_device():
10141014
config[topic] = payload
10151015

10161016
for relay_id in range(relays):
1017-
relay_type = (
1018-
ATTR_LIGHT
1019-
if ATTR_LIGHT
1020-
in device_config["sys"]["ui_data"]
1021-
.get("consumption_types", {})
1022-
.get(relay_id, "switch")
1023-
.lower()
1024-
else ATTR_SWITCH
1025-
)
1017+
consumption_types = [
1018+
item.lower()
1019+
for item in device_config["sys"]["device"].get("consumption_types", [])
1020+
]
1021+
relay_type = ATTR_LIGHT if ATTR_LIGHT in consumption_types else ATTR_SWITCH
10261022

10271023
topic, payload = get_switch(relay_id, relay_type, profile)
10281024
config[topic] = payload

0 commit comments

Comments
 (0)