Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var int percent = 0
- var Timer fade_Timer = null
- var Timer timerAlarm = null
- rule "Android Alarm Clock"
- when
- Item Phone_R_Alarm changed
- then
- val epoch = (newState as DateTimeType).toLocaleZone.zonedDateTime.toInstant.toEpochMilli
- if( epoch <= 0 ) {
- if( timerAlarm !== null ) {
- timerAlarm.cancel
- timerAlarm = null
- }
- logInfo("Android-Alarm", "Alarm abgebrochen")
- } else {
- logInfo("Android-Alarm", "Scheduling Alarm for {} ({})", (newState as DateTimeType).toLocaleZone, epoch)
- if( timerAlarm !== null ) {
- logInfo("Android-Alarm", "Reschedule Alarm")
- timerAlarm.reschedule(new DateTime(epoch))
- } else {
- logInfo("Android-Alarm", "Neuer Alarm")
- timerAlarm = createTimer(new DateTime(epoch), [ |
- if (gPresence.state == ON && Wohnzimmer_Light_Dimmer.state instanceof DecimalType) {
- percent = ((Wohnzimmer_Light_Dimmer.state as DecimalType)/5).intValue * 5
- fade_Timer = createTimer(now.plusMillis(3000)) [|
- Flur_Light_Dimmer.sendCommand(percent)
- Wohnzimmer_Light_Dimmer.sendCommand(percent)
- Schlafzimmer_1_Light_Dimmer.sendCommand(percent)
- Schlafzimmer_2_Light_Dimmer.sendCommand(percent)
- if (percent < 100) {
- percent = percent + 1
- fade_Timer.reschedule(now.plusMillis(3000))
- }
- ]
- sendTelegram("Lichtsteuerung", "Androidwecker: " + Lokal_Uhrzeit.state + " Schlafzimmer, Wohnzimmer & Flur 5min. hochdimmen")
- }
- logInfo("Android-Alarm", "Alarm", "Alarm abgelaufen")
- timerAlarm = null
- ])
- }
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement