summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sample.lua13
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)