I have done some progress, below is my code inspired from what you shared.
What it can do:
- It can switch the relay each time you press a button
- Works with 2 zones, should be able to expand to 8....
What I can't do yet:
- Control the system via http, I tried a "http:// ....PCFPulse,9,0,250" but it doesn't work.
- Still need to work on the publishing
What I'm pretty sure I don't understand...:
- VAR ? is it a special command ? Is it related with the let (i assume so)
- Do I need the boot to initialize ?
Any idea ?
Code: Select all
On System#Boot do //setup all the zones to 0
[VAR#1]=0
[VAR#2]=0
// complete all the zones
endon
on button1#State Do
if [button1#State]=1
Event,RelayToggle=1 //zone 1 = pdfgpio 1
endif
EndOn
on button2#State Do
if [button2#State]=1
Event,RelayToggle=2 //zone 2 =pcfgpio 2
endif
EndOn
On RelayToggle Do
if [VAR#%eventvalue%]=0 // not sure about the VAR, how does it work ?
pcfgpio,%eventvalue%,1
Let,%eventvalue%,1
// Publish for zone
else
pcfgpio,%eventvalue%,0
Let,%eventvalue%,0
// Publish for zone
endif
EndOn