diff options
| author | Mikhail Burakov <mburakov@mailbox.org> | 2021-11-01 14:45:08 +0100 |
|---|---|---|
| committer | Mikhail Burakov <mburakov@mailbox.org> | 2021-11-01 14:45:08 +0100 |
| commit | 7afb07ab8960bd2070d713b241aba0654e3afb10 (patch) | |
| tree | 59b11dd9db4a87c3b14e9593b470ab099accc60d | |
| parent | d6cf9f612c472d054632ef2937bc40da455be03b (diff) | |
Add sample lua script
| -rw-r--r-- | sample.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sample.lua b/sample.lua new file mode 100644 index 0000000..27ae36b --- /dev/null +++ b/sample.lua @@ -0,0 +1,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) |
