You have a few typos and syntax errors in your code:
- Syntax error: Any statement outside of and "on event do / endon" is ignored, so the let commands won't do anything
- Typo: "let2,0," won't work as expected
- Syntax error: "if if ..."
- Question: When is "on Ledweergave#State do" called?
I'm not sure why you are polling the GPIO pins, you'd better respond to an event once the state of a pin changes. That requires a complete rewrite of the code, but is more in the spirit of how an event system is intended to be used...
Checking the state and sending the status to Domoticz
can be handled in a single rule, making your code much more compact, another way to rewrite the code...
Your code with most issues fixed (no rewrite, yet
)
Code: Select all
on Rules#Timer=1 do
if [Voordeur#Fails] < 7
Let,1,1
if [Plugin#GPIO#Pinstate#12]=0
Publish domoticz/in,'{"idx":1003,"svalue":"OPEN","nvalue":4}'
else
Publish domoticz/in,'{"idx":1003,"svalue":"DICHT","nvalue":1}'
endif
else // [Voordeur#Fails] =>7
Let,1,0
Publish domoticz/in,'{"idx":1003,"svalue":"FOUT","nvalue":3}'
endif
if [Achterdeur#Fails] < 7
Let,2,1
if [Plugin#GPIO#Pinstate#4]=0
Publish domoticz/in,'{"idx":1004,"svalue":"OPEN","nvalue":4}'
else
Publish domoticz/in,'{"idx":1004,"svalue":"DICHT","nvalue":1}'
endif
else // [Achterdeur#Fails] => 7
Let,2,0
Publish domoticz/in,'{"idx":1004,"svalue":"PROBLEEM","nvalue":3}'
endif
if [Slaapkamerdeur#Fails] < 7
Let,3,1
if [Plugin#GPIO#Pinstate#13]=0
Publish domoticz/in,'{"idx":1005,"svalue":"OPEN","nvalue":4}'
else
Publish domoticz/in,'{"idx":1005,"svalue":"DICHT","nvalue":1}'
endif
else // [Slaapkamerdeur#Fails] >= 7
Let,3,0
Publish domoticz/in,'{"idx":1005,"svalue":"PROBLEEM","nvalue":3}'
endif
if [Tuinkastdeur#Fails] < 7
Let,4,1
if [Plugin#GPIO#Pinstate#14]=0
Publish domoticz/in,'{"idx":1006,"svalue":"OPEN","nvalue":4}'
else
Publish domoticz/in,'{"idx":1006,"svalue":"DICHT","nvalue":1}'
endif
else // [Tuinkastdeur#Fails] >= 7
Let,4,0
Publish domoticz/in,'{"idx":1006,"svalue":"PROBLEEM","nvalue":4}'
endif
if [Schuurdeur#Fails] < 7
Let,5,1
if [Plugin#GPIO#Pinstate#15]=0
Publish domoticz/in,'{"idx":1007,"svalue":"OPEN","nvalue":4}'
else
Publish domoticz/in,'{"idx":1007,"svalue":"DICHT","nvalue":1}'
endif
else // [Schuurdeur#Fails] >= 7
Let,5,0
Publish domoticz/in,'{"idx":1007,"svalue":"PROBLEEM","nvalue":4}'
endif
endon
//LED
On Ledweergave#State do
if [VAR#1]=1
GPIO,12,0//D6 voordeur
endif
if [VAR#2]=1
GPIO,4,0//D2 achterdeur
endif
if [VAR#3]=1
GPIO,13,0//D7 slaapkamer
endif
if [VAR#4]=1
GPIO,14,0//D5 tuinkast
endif
if [VAR#5]=1
GPIO,15,0//D8 schuurdeur
GPIO,16,0//D0 kleine poort
endif
endon
on System#Boot do
LoopTimerSet,1,45
Let,1,1
Let,2,1
Let,3,1
Let,4,1
Let,5,1
enddo