blob: 27ae36b62f89fe0f2b0ab6852e48db61511423f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
switch_state = false
publish('cmnd/torsh/Color', '#00000000')
subscribe('zigbee2mqtt/switch', function(payload)
print('Switch says: ' .. payload)
if string.find(payload, '"action":"on"') ~= nil and switch_state == false then
switch_state = true
publish('cmnd/torsh/Color', '#000000ff')
elseif string.find(payload, '"action":"off"') ~= nil and switch_state == true then
switch_state = false
publish('cmnd/torsh/Color', '#00000000')
end
end)
|