I have this rule which was working fine when I used a switch on my site map to fire it. Now I want it to fire based on a cron scheduler. I made this just to try it out and I would expect it to fire every 5 minutes but it is not firing. Can anyone see what I am doing wrong?
import org.joda.time.*
var Timer sunrise_timer = null
var Timer sunset_timer = null
rule "get sunrise and sunset"
when
Time cron “0 0/5 * * * ?”
then
var String json = sendHttpGetRequest("http://api.wunderground.com/api//astronomy/q/Bermuda.json")
var String Hour = transform("JSONPATH", "$.sun_phase.sunrise.hour", json)
var String Minute = transform("JSONPATH", "$.sun_phase.sunrise.minute", json)
var String sunrise = Hour + ":" + Minute
var DateTime sunRise = parse(now.getYear() + "-" + now.getMonthOfYear() + "-" + now.getDayOfMonth() + "T" + sunrise)
Hour = transform("JSONPATH", "$.sun_phase.sunset.hour", json)
Minute = transform("JSONPATH", "$.sun_phase.sunset.minute", json)
var String sunset = Hour + ":" + Minute
var DateTime sunSet = parse(now.getYear() + "-" + now.getMonthOfYear() + "-" + now.getDayOfMonth() + "T" + sunset)
Sunrise.sendCommand(sunrise)
Sunset.sendCommand(sunset)
logInfo( "FILE", sunrise)
logInfo( "FILE", sunset)
sunrise_timer = createTimer(sunRise)[|
Outlet1_1.sendCommand(ON)
]
sunset_timer = createTimer(sunSet)[|
Outlet1_1.sendCommand(OFF)
]
end