I was trying to create some rules for my chicken.
Switch light on at 6:00 and switch off at sunrise + light on at sunrise and light off at 20:00
Later I would like to implement the door to open and close them automatically.
Additional I would like to toggle the light by pressing a button (key). Each parts of the code work alone.
My idea was to generate dummy variable to hold the state (light on morning, light on evening) and also use always the same code for switch the light, but it dosn't work propperly.
Could somebody tell me, what I'm doing wrong?
Code: Select all
on System#Boot do
timerSet,1,20
endon
on Rules#Timer=1 do
if %systm_hm% > 6:00 and %systm_hm% < %sunrise% or %systm_hm% > %sunset% and %systime% < 20:00
GPIO,12,0//Relais
GPIO,13,0//LED
else
GPIO,12,1//Relais
GPIO,13,1//LED
endif
endon
On Clock#Time=All,6:00 do // every day at 6:00 hours switch on relay on gpio 12
gpio,12,0
GPIO,13,0//LED
endon
//at sunrise time switch light off//set timer1 for 1 hour
On Clock#Time=All,%sunrise% do
//timerSet,2,3600
GPIO,12,1//Relais/light off
GPIO,13,1//LED off
//GPIO,1,0//door up
endon
//at sunset time switch light on
On Clock#Time=All,%sunset% do
timerSet,1,3600
GPIO,12,0//Relais
GPIO,13,0//LED
endon
//When Timer1 expires, <action>
On Rules#Timer=1 do
GPIO,1,0 // close door
endon
On Clock#Time=All,20:00 do // every day at 20:00 hours switch off relay on gpio 12
GPIO,12,1//Relais
GPIO,13,1//LED
endon