Hi folks.
Allow me to give some feedback on above.
Been at this for 3x weeks…or…actually more like 2x weeks…I’ve been away for 1x week vacation in the bushes.
I’ve done quite a bit…or rather learned quite a bit more on the systems…
Let me show you what I achieved.
there are some more things I need done…but I think best I address those under new topics.
So…one of my first problems was to create a timer triggered by a PIR and this should only happen after hours.
Then, I had to try establish when exactly is after hours, meaning night time.
So this is how I got them resolved.
First…I created a rule to indicate when it is night time and day time:
//Rule to know when night starts and stops
rule "Sunset Rule"
when
Channel 'astro:sun:local:set#event' triggered END
then
NightTime.sendCommand(ON)
logInfo("Night status", "Now turned NIGHT time!")
end
rule "Sunrise Rule"
when
Channel 'astro:sun:local:rise#event' triggered END
then
NightTime.sendCommand(OFF)
logInfo("Night status", "Now turned DAY time!")
end
This works great for me. So, what I did was to create a SWITCH in ITEMS “NightTime”.
Now, I created a new rule and this switches on an outside light covering my porch entrance.
//Rule to switch on outside left light after hours
var Timer MotionTimer = null
rule "Entrance left light timer"
when
Item GenericMQTTThing_RFBridgeRX received command EC65BE
then
logInfo("Outside Left Light", "Outside passage motion detected!")
if (NightTime.state == ON) {
GenericMQTTThing_LeftFrontOutsideLight.sendCommand(ON)
logInfo("Outside Left Light", "Switched on!")
MotionTimer = createTimer(now.plusMinutes(10)) [ |
GenericMQTTThing_LeftFrontOutsideLight.sendCommand(OFF)
MotionTimer = null
logInfo("Outside Left Light", "Switched off!")
] }
end
From above, rule only active if the “NightTime” status is “ON”.
I created another rule, this time when the outside driveway gate opens.
Again I have some lights switch on…the same as per above, the porch light…but also a second light covering the parking area in front of the garage.
Take note here…I used a GROUP as the function. So I added 2x lights into the same GROUP.
//Rule to switch on both left and right front lights when the gate opens after hours
var Timer GateTimer = null
rule "Gate Light Timer"
when
Item GenericMQTTThing_RFBridgeRX received command AC2B99
then
logInfo("Driveway gate", "Gate moving!")
if (NightTime.state == ON) {
Welcomelights.sendCommand(ON)
logInfo("All Front Outside Lights", "Switched on!")
GateTimer = createTimer(now.plusSeconds(10)) [ |
Welcomelights.sendCommand(OFF)
GateTimer = null
logInfo("Outside Light", "Switched off!")
] }
end
Above rule is triggered after hours via a RF transmitter with a magnetic strip.
Very happy with above…and to most of you this must seem like simple mundane stuff…but this is huge for me.
Then I got onto my next project…timing…I needed certain function to happen at certain times of the day.
Here is my next project.
A little detail around the hardware…I’m using SONOFF light switches and relay and the are all loaded with TASMOTA.
The following is a rule to control 2x fountains I have in the garden.
Or, rather, I have a small fountain in the front garden, then another larger fountain next to our front entrance.
//Rule to switch on front small fountain
var Timer smalltimer = null
var Timer walltimer = null
rule "Small fountain operations"
when
Time cron "0 5 12 ? * * *" // runs everyday at 12:05
or
Time cron "0 5 7 ? * * *" // runs everyday at 07:05
or
Time cron "0 5 16 ? * * *" // runs everday at 16:05
then
GenericMQTTThing_SmallFountain.sendCommand(ON)
logInfo("Front fountains", "Small fountain switched on!")
smalltimer = createTimer(now.plusMinutes(70)) [ |
GenericMQTTThing_SmallFountain.sendCommand(OFF)
smalltimer = null
logInfo("Front fountains", "Small fountain switched off!") ]
end
//--------------------------------------
//Rule to switch on wall fountain in the mornings and midday
rule "Wall fountain morning and midday operations"
when
Time cron "0 0 13 ? * * *" // runs everyday at 13:00
or
Time cron "0 0 9 ? * * *" // runs everyday at 09:00
then
if (VacationSW.state == OFF)
GenericMQTTThing_WallFountain.sendCommand(ON)
logInfo("Front fountains", "Wall fountain switched on normal times!")
walltimer = createTimer(now.plusMinutes(60)) [ |
GenericMQTTThing_WallFountain.sendCommand(OFF)
walltimer = null
logInfo("Front fountains", "Wall fountain switched off!") ]
end
//--------------------------------------
//Rule to switch on wall fountain in the afternoons
rule "Wall fountain afternoon operations"
when
Channel 'astro:sun:local:civilDusk#event' triggered START
then
if (VacationSW.state == OFF)
GenericMQTTThing_WallFountain.sendCommand(ON)
logInfo("Front fountains", "Wall fountain switched on before sunset!")
walltimer = createTimer(now.plusMinutes(60)) [ |
GenericMQTTThing_WallFountain.sendCommand(OFF)
walltimer = null
logInfo("Front fountains", "Wall fountain switched off!") ]
end
The first 2x portions of above rule I found easy to have implemented.
First portion is to run the small fountain in 3x cycles during the day.
The second portion is the larger wall fountain and that causes it to cycle twice every day.
But, the final portion was the most difficult…this took me days to solve, again with many hours of reading and experimenting.
What I was trying to achieve and finally got working…
The wall fountain runs 3x cycles per day.
First cycle early in the morning. The second cycle around lunchtime.
The final cycle is late afternoon. But, the issue I had…which is exactly right now…is the season.
So, being in WINTER at the moment…if I use CRON, then I could simply put a starting time down and voila…working. But, when summer comes…it will be running too soon…and I would have had to adjust the CRON time again.
The solution I was looking for was to use SUNSET time.
Use some sort of method to detect SUNSET but then start the wall fountain and run it for 1x hour and make it stop at SUNSET time.
I eventually got this sorted once I learned of the “OFFSET” function.
From the script you would see that I used “CIVILDUSK” event to detect the SUNSET period and I implemented via PAPER-UI a “-60” offset.
ok, so few more small things I’ve done but I think this is enough feedback here for now.
I now have a new quest regarding automation for pools…but I will start a new topic for this.
By the way, Rich and Rosko…I think I go the hang now of using THEN and IF…ELSE commands.