I reckon I looked at my construct for far too long, and do not see what must be obvious.
The idea is:
receive geo location
check if within 400m of fixed point
send an email
set a lock; so that further locations within the 400m do not trigger another email
start a timer which will reset the lock
Below is the code, and further below the log; the code looks OK to me, but it doesn’t do what I want it to do > so the code must be wrong.
outside rule:
var Boolean blnEmailLockLocus_1 = false
inside rule:
// if within 400 metres of Locus_1
if (DistanceFromLocus_1.state < 0.400) {
// if we haven't sent an email yet
if (blnEmailLockLocus_1 == false) {
logInfo("Geo.3.4", "Send email (at Locus_1)")
sendMail(emailToPete, "Max is 20 minutes away", "Max is roughly 20 minutes away from pick-up location")
logInfo("Geo.3.5", "set blnEmailLockLocus_1 to true (={})", blnEmailLockLocus_1)
blnEmailLockLocus_1 = true
// start timer to reset blnEmailLockLocus_1 to false in 120 seconds
createTimer(now.plusSeconds(120), [|
logInfo("Geo.3.6", "set blnEmailLockLocus_1 to false (={})", blnEmailLockLocus_1)
blnEmailLockLocus_1 = false
])
}
}
2018-11-16 06:06:35.715 [INFO ] [g.openhab.model.script.Geo.3.4] - Send email (at Locus_1)
2018-11-16 06:06:42.242 [INFO ] [g.openhab.model.script.Geo.3.4] - Send email (at Locus_1)
2018-11-16 06:06:51.976 [INFO ] [g.openhab.model.script.Geo.3.4] - Send email (at Locus_1)
2018-11-16 06:06:53.271 [INFO ] [g.openhab.model.script.Geo.3.5] - set blnEmailLockLocus_1 to true (=false)
2018-11-16 06:06:55.375 [INFO ] [g.openhab.model.script.Geo.3.5] - set blnEmailLockLocus_1 to true (=true)
2018-11-16 06:07:05.348 [INFO ] [g.openhab.model.script.Geo.3.5] - set blnEmailLockLocus_1 to true (=true)
2018-11-16 06:08:55.826 [INFO ] [g.openhab.model.script.Geo.3.6] - set blnEmailLockLocus_1 to false (=true)
2018-11-16 06:08:56.294 [INFO ] [g.openhab.model.script.Geo.3.6] - set blnEmailLockLocus_1 to false (=true)
2018-11-16 06:09:05.369 [INFO ] [g.openhab.model.script.Geo.3.6] - set blnEmailLockLocus_1 to false (=false)
What is really interesting, I have another timer that is the same construct that actually works; maybe one timer in a rule file works without declaration; another one without a name does not work; but I agree, they should be declared, which I have done for both timers in that rule file.
I will test this on Monday (as I hit this geolocation Mon-Fri)… and then update this post.
Thanks, I hope you’re wrong as this confuses the heck out of me
If my timer (or more so Dim’s declaration) works that would be great.
But then there is: val Number GeoLoc_Home_Lat = new DecimalType()