Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.2 kB
0
Indexable
Never
// Triggers:
// - When GF_LivingDining_Door changed from OPEN to CLOSED
// - When GF_Backyard_Motion changed from CLOSED to OPEN

// context: default-1
logError("deu merda")
val joda = new DateTime((now.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
val anoitecer = new DateTime(AstroSunData_Daylight_EndTime.state.toString)
val amanhecer = new DateTime(AstroSunData_Daylight_StartTime.state.toString)
logInfo("Luzes Automaticas", joda.toString)
logInfo("Luzes Automaticas", anoitecer.toString)
logInfo("Luzes Automaticas", amanhecer.toString)
if(joda.isAfter (anoitecer)){
	logInfo("Luzes automaticas", "Passa do anoitecer")
	    	GF_Backyard_Light.sendCommand(ON)
            createTimer(joda.plusMinutes(5)) [|
                if (GF_Backyard_Light.state==ON) {
		    GF_Backyard_Light.sendCommand(OFF)
		}
	]
          
}
if(joda.isBefore (amanhecer)){
	logInfo("Luzes automaticas", "Antes de amanhecer")
	    	GF_Backyard_Light.sendCommand(ON)
            createTimer(joda.plusMinutes(5)) [|
                if (GF_Backyard_Light.state==ON) {
		    GF_Backyard_Light.sendCommand(OFF)
		}
	]
          
}