Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. var int percent = 0
  2. var Timer fade_Timer = null
  3. var Timer timerAlarm = null
  4.  
  5. rule "Android Alarm Clock"
  6. when
  7. Item Phone_R_Alarm changed
  8. then
  9. val epoch = (newState as DateTimeType).toLocaleZone.zonedDateTime.toInstant.toEpochMilli
  10. if( epoch <= 0 ) {
  11. if( timerAlarm !== null ) {
  12. timerAlarm.cancel
  13. timerAlarm = null
  14. }
  15. logInfo("Android-Alarm", "Alarm abgebrochen")
  16. } else {
  17. logInfo("Android-Alarm", "Scheduling Alarm for {} ({})", (newState as DateTimeType).toLocaleZone, epoch)
  18. if( timerAlarm !== null ) {
  19. logInfo("Android-Alarm", "Reschedule Alarm")
  20. timerAlarm.reschedule(new DateTime(epoch))
  21. } else {
  22. logInfo("Android-Alarm", "Neuer Alarm")
  23. timerAlarm = createTimer(new DateTime(epoch), [ |
  24. if (gPresence.state == ON && Wohnzimmer_Light_Dimmer.state instanceof DecimalType) {
  25. percent = ((Wohnzimmer_Light_Dimmer.state as DecimalType)/5).intValue * 5
  26. fade_Timer = createTimer(now.plusMillis(3000)) [|
  27. Flur_Light_Dimmer.sendCommand(percent)
  28. Wohnzimmer_Light_Dimmer.sendCommand(percent)
  29. Schlafzimmer_1_Light_Dimmer.sendCommand(percent)
  30. Schlafzimmer_2_Light_Dimmer.sendCommand(percent)
  31. if (percent < 100) {
  32. percent = percent + 1
  33. fade_Timer.reschedule(now.plusMillis(3000))
  34. }
  35. ]
  36. sendTelegram("Lichtsteuerung", "Androidwecker: " + Lokal_Uhrzeit.state + " Schlafzimmer, Wohnzimmer & Flur 5min. hochdimmen")
  37. }
  38. logInfo("Android-Alarm", "Alarm", "Alarm abgelaufen")
  39. timerAlarm = null
  40. ])
  41. }
  42. }
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement