wakeup.yaml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. sensor:
  2. - platform: template
  3. sensors:
  4. wakeup_start_time_lights:
  5. friendly_name: 'Start time'
  6. value_template: >
  7. {% set starttime = states.input_datetime.wakeup_alarm_time.attributes.timestamp - (states.input_number.wakeup_duration.state | int) * 60 %}
  8. {{ starttime | timestamp_custom('%H:%M', False) }}
  9. icon_template: 'mdi:clock-start'
  10. input_boolean:
  11. wakeup:
  12. name: 'Wakeup light'
  13. icon: mdi:power
  14. initial: off
  15. wakeup_weekends:
  16. name: 'Wakeup Weekend'
  17. icon: mdi:calendar-clock
  18. initial: off
  19. input_number:
  20. wakeup_duration:
  21. name: Dauer
  22. icon: mdi:clock-in
  23. initial: 20
  24. min: 5
  25. max: 60
  26. step: 5
  27. unit_of_measurement: 'min'
  28. input_datetime:
  29. wakeup_alarm_time:
  30. name: 'Alarm time'
  31. #icon: mdi:clock-end
  32. has_date: false
  33. has_time: true
  34. initial: '06:30'
  35. group:
  36. wakeuplight:
  37. name: Wakeup Light
  38. control: hidden
  39. entities:
  40. - input_datetime.wakeup_alarm_time
  41. - input_number.wakeup_duration
  42. - sensor.wakeup_start_time_lights
  43. - input_boolean.wakeup
  44. - input_boolean.wakeup_weekends
  45. automation:
  46. - action:
  47. - service: script.wakeup_bedroom
  48. alias: 'Wakeup Bedroom'
  49. hide_entity: true
  50. condition:
  51. condition: and
  52. conditions:
  53. - condition: state
  54. entity_id: input_boolean.wakeup
  55. state: 'on'
  56. - condition: or
  57. conditions:
  58. - condition: state
  59. entity_id: input_boolean.wakeup_weekends
  60. state: 'on'
  61. - condition: time
  62. weekday:
  63. - mon
  64. - tue
  65. - wed
  66. - thu
  67. - fri
  68. trigger:
  69. platform: template
  70. value_template: '{{ states.sensor.time.state == states.sensor.wakeup_start_time_lights.state }}'
  71. script:
  72. wakeup_bedroom:
  73. alias: 'Wakeup Light'
  74. sequence:
  75. - service: light.turn_on
  76. data_template:
  77. entity_id: light.bedroom
  78. brightness: 1
  79. xy_color: [0.5016, 0.4151]
  80. - delay:
  81. seconds: 1
  82. - service: light.turn_on
  83. data_template:
  84. entity_id: light.bedroom
  85. brightness: 255
  86. transition: '{{ states.input_number.wakeup_duration.state | multiply(60) | int }}'