Thanks for the reply. But I have a question the cron time I use is as follows:-
to close door active = 0 00 22 ? * SUN-THU
to open door active = 0 00 07 ? * SUN-THU
Friday and Saturday door is on Manual operation only.
how can I implement this in the script.
and also !sensor.value is this a variable? the Variable for the Relay Data point "Board 2 - Relay 8" where does that go in the script?
ok I tried to wrap my head around it. your script is treating the relay as on off when in fact it's a toggle because I have another script running that keep checking the relay, if it is true then it returns it to false.
so :
- if sensor value is 0 (zero) at 0700 then the script should turn the relay to true, but if it is 1 (one) then it will not send any commands to the relay, because the door is open,
- if sensor value is 1 (one) at 2200 then the script should turn the relay to true, but if it is 0 (zero) then it will not send any commands to the relay because the door is close.
I set in the data source the following:-
Cron pattern = 0 00 07,22 ? * SUN-THU
Variable control = Board 2 - Relay 8
Variable sensor = tM-P3R3 - Garage Door Sensor
var hour = (new Date()).getHours();
if( hour == 7 && !sensor.value ) <-- Where do you get the sensor value (0 or 1) is the "!" trigger???
control.set( true );
else if( hour == 22 && sensor.value )
control.set( true );
I hope this is logical?
forgive me, I'm a total noob with scripts.