adjusted for mains switch
This commit is contained in:
8
mqtt.lua
8
mqtt.lua
@ -4,9 +4,9 @@ BRUSER = ""
|
|||||||
BRPWD = ""
|
BRPWD = ""
|
||||||
CLIENTID = "ESP8266-" .. node.chipid()
|
CLIENTID = "ESP8266-" .. node.chipid()
|
||||||
|
|
||||||
SWITCH_PIN = 0
|
SWITCH_PIN = 3
|
||||||
|
|
||||||
SWITCH_ID = 0
|
SWITCH_ID = 1
|
||||||
|
|
||||||
topics = {"IoT/Watchdog", "IoT/Switch" .. SWITCH_ID}
|
topics = {"IoT/Watchdog", "IoT/Switch" .. SWITCH_ID}
|
||||||
TOPIC_WATCHDOG = 1
|
TOPIC_WATCHDOG = 1
|
||||||
@ -90,9 +90,9 @@ function run_main_prog()
|
|||||||
if (switch_state ~= old_switch_state) then
|
if (switch_state ~= old_switch_state) then
|
||||||
old_switch_state = switch_state
|
old_switch_state = switch_state
|
||||||
if (switch_state) then
|
if (switch_state) then
|
||||||
gpio.write(SWITCH_PIN, gpio.HIGH)
|
|
||||||
else
|
|
||||||
gpio.write(SWITCH_PIN, gpio.LOW)
|
gpio.write(SWITCH_PIN, gpio.LOW)
|
||||||
|
else
|
||||||
|
gpio.write(SWITCH_PIN, gpio.HIGH)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user