Hi
I am trying rules to basically switch on some lights when Plex starts playing. I am having trouble when I add or manipulate datetimes
In the OpenHab designer I get errors for now entries and DateTime however not sure what I’m doing wrong. It could be something very simple.
Also rules file does not load i think when there is such entries. Without them I do get some logging.
I have openhab 1.8.2 on a raspberry pi
Any pointers would be greatly appreciated.
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.joda.time.*
var Number counter = 1
/**
* Loads on startup
*/
rule Startup
when
System started
then
logDebug("openhabrules", "OpenHab Rules Load")
end
/**
* When plex starts playing lights go on
*/
rule MovieLightsOn
when
Item PlexTVStatus changed to Playing
then
logDebug("openhabrules", "Plex Started Switch Lights")
var year = now.getYear
var month = now.getMonthOfYear
var day = now.getDayOfMonth
var DateTime sunset = parse(year+"-"+month+"-"+day+"T"+AASunset_Time.state)
if ( now.isAfter(sunset)) {
logDebug("openhabrules", "Plex Started Switch Lights")
sendCommand("livingrlamp1", "ON")
sendCommand("livingrlamp2", "ON")
}
else {
logDebug("openhabrules", "Plex Started Still Daylight")
}
end