Skip to content

Commit 7d14955

Browse files
committed
#389 Melody support for Neo NAS-AB02B0
1 parent 6164881 commit 7d14955

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

adapters/neo/NASAB02B0.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ def __init__(self, devices):
1717
volume_switch.add_level('Low', 'low')
1818
volume_switch.add_level('Medium', 'medium')
1919
volume_switch.add_level('High', 'high')
20-
2120
self.devices.append(volume_switch)
2221

22+
melody_switch = SelectorSwitch(devices, 'mel', 'melody', ' (Melody)')
23+
for melody in range(1, 19):
24+
melody_switch.add_level(str(melody), melody)
25+
26+
self.devices.append(melody_switch)
27+
2328
def convert_message(self, message):
2429
message = super().convert_message(message)
2530

@@ -51,3 +56,15 @@ def handleCommand(self, alias, device, device_data, command, level, color):
5156
"volume": level_value
5257
})
5358
}
59+
60+
if alias == 'mel':
61+
switch = self.get_device_by_alias(alias)
62+
level_index = int(level / 10)
63+
level_value = switch.level_values[level_index]
64+
65+
return {
66+
'topic': device_data['friendly_name'] + '/set',
67+
'payload': json.dumps({
68+
"melody": level_value
69+
})
70+
}

0 commit comments

Comments
 (0)