strip shows rainbow
This commit is contained in:
parent
2b276cb1bc
commit
732abf5c2f
|
@ -191,6 +191,14 @@ class LightStrip(Device):
|
||||||
payload = payload.split(',')
|
payload = payload.split(',')
|
||||||
self.rainbow_params = [float(p) for p in payload[:3]]
|
self.rainbow_params = [float(p) for p in payload[:3]]
|
||||||
self.rainbow_params += [int(p) for p in payload[3:]]
|
self.rainbow_params += [int(p) for p in payload[3:]]
|
||||||
|
elif topic[1] == 'strip':
|
||||||
|
data['amount'] = topic[2]
|
||||||
|
if topic[2] == 'full':
|
||||||
|
payload = json.loads(payload)
|
||||||
|
data['colors'] = []
|
||||||
|
for i, color in enumerate(payload):
|
||||||
|
self.sub_devices[i].color = color
|
||||||
|
data['colors'].append(tools.to_html_color(color))
|
||||||
save_network(network)
|
save_network(network)
|
||||||
|
|
||||||
res = {'event': 'neopixel', 'data': data}
|
res = {'event': 'neopixel', 'data': data}
|
||||||
|
|
|
@ -183,8 +183,17 @@ function neopixel_recv(data) {
|
||||||
} else if (data.type === 'rainbow') {
|
} else if (data.type === 'rainbow') {
|
||||||
} else if (data.type === 'america') {
|
} else if (data.type === 'america') {
|
||||||
}
|
}
|
||||||
} else if (data.state === 'animation') {
|
} else if (data.change_mode === 'animation') {
|
||||||
|
} else if (data.change_mode === 'strip') {
|
||||||
|
if (data.amount === 'full') {
|
||||||
|
let sub_devices = device.querySelector('.sub_devices');
|
||||||
|
for (let i = 0; i < sub_devices.children.length; i++) {
|
||||||
|
sub_devices.children[i].firstElementChild.style.backgroundColor = data.colors[i];
|
||||||
|
sub_devices.children[i].firstElementChild.firstElementChild.value = data.colors[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Websocket send */
|
/* Websocket send */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user