Advertisement
artpc

package_alarm

Apr 27th, 2023
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.74 KB | None | 0 0
  1. homeassistant:
  2. customize:
  3.  
  4. ################################################
  5. ## Node Anchors
  6. ################################################
  7.  
  8. package.node_anchors:
  9. customize: &customize
  10. package: 'alarmclock'
  11.  
  12. exposed: &exposed
  13. <<: *customize
  14. emulated_hue_hidden: true
  15. homebridge_hidden: false
  16. critical: true
  17.  
  18. not_exposed: &not_exposed
  19. <<: *customize
  20. emulated_hue_hidden: false
  21. homebridge_hidden: true
  22. critical: false
  23.  
  24. hidden: &hidden
  25. <<: *customize
  26. hidden: true
  27. critical: false
  28.  
  29. automation.alarm_clock:
  30. icon: mdi:alarm-check
  31.  
  32. input_number:
  33. slider_hours:
  34. name: Godziny
  35. initial: 4
  36. min: 0
  37. max: 11
  38. step: 1
  39.  
  40. slider_minutes:
  41. name: Minuty
  42. initial: 15
  43. min: 0
  44. max: 59
  45. step: 5
  46.  
  47. input_boolean:
  48. alarm_clock:
  49. name: Alarm On
  50. initial: on
  51. icon: mdi:alarm-multiple
  52.  
  53. week_day_only:
  54. name: Tylko W Dni Powszednie
  55. initial: on
  56. icon: mdi:calendar-check
  57.  
  58. am:
  59. name: AM
  60. initial: on
  61. icon: mdi:weather-sunny
  62.  
  63. pm:
  64. name: PM
  65. initial: off
  66. icon: mdi:weather-night
  67.  
  68. boolean_extra_work_day:
  69. name: Extra Workday
  70. initial: off
  71. icon: mdi:calendar-check
  72.  
  73. input_text:
  74. alarm_current_time:
  75. name: Aktualny Czas Alarmu
  76. icon: mdi:timer
  77.  
  78. sensor:
  79. - platform: time_date
  80. display_options:
  81. - 'time'
  82. - 'date'
  83. - 'date_time'
  84. - 'time_date'
  85. - 'time_utc'
  86. - 'beat'
  87.  
  88. binary_sensor:
  89. - platform: workday
  90. country: PL
  91. workdays: [mon, tue, wed, thu, fri, sat, sun]
  92. # excludes: [fri, sat, sun, holiday]
  93.  
  94. automation:
  95. - alias: update current alarm time
  96. initial_state: true
  97. # hide_entity: true
  98. trigger:
  99. - platform: homeassistant
  100. event: start
  101. - platform: state
  102. entity_id:
  103. - input_boolean.am
  104. - input_boolean.pm
  105. - input_number.slider_hours
  106. - input_number.slider_minutes
  107. action:
  108. - service: input_text.set_value
  109. entity_id: input_text.alarm_current_time
  110. data_template:
  111. value: >
  112. {%- if states.input_number.slider_hours.state | int < 10 -%}
  113. {%- if states.input_number.slider_hours.state|int == 0 %}
  114. 12
  115. {%- else -%}
  116. {{- 0 ~ states.input_number.slider_hours.state|int -}}
  117. {%- endif -%}
  118. {%- else -%}
  119. {{- states.input_number.slider_hours.state |int -}}
  120. {% endif -%}:
  121. {%- if states.input_number.slider_minutes.state | int < 10 -%}
  122. {{- 0 ~ states.input_number.slider_minutes.state |int -}}
  123. {%- else -%}
  124. {{- states.input_number.slider_minutes.state|int -}}
  125. {%- endif -%}{%- if states.input_boolean.am.state == "on" %} AM{%- else %} PM{%- endif -%}
  126.  
  127. - alias: am change off
  128. initial_state: true
  129. # hide_entity: true
  130. trigger:
  131. platform: state
  132. entity_id: input_boolean.am
  133. from: 'on'
  134. to: 'off'
  135. action:
  136. - service: input_boolean.turn_on
  137. entity_id: input_boolean.pm
  138. - service: input_boolean.turn_off
  139. entity_id: input_boolean.am
  140.  
  141. - alias: am change on
  142. initial_state: true
  143. # hide_entity: true
  144. trigger:
  145. platform: state
  146. entity_id: input_boolean.am
  147. from: 'off'
  148. to: 'on'
  149. action:
  150. - service: input_boolean.turn_off
  151. entity_id: input_boolean.pm
  152. - service: input_boolean.turn_on
  153. entity_id: input_boolean.am
  154.  
  155. - alias: pm change off
  156. initial_state: true
  157. # hide_entity: true
  158. trigger:
  159. platform: state
  160. entity_id: input_boolean.pm
  161. from: 'on'
  162. to: 'off'
  163. action:
  164. - service: input_boolean.turn_on
  165. entity_id: input_boolean.am
  166. - service: input_boolean.turn_off
  167. entity_id: input_boolean.pm
  168.  
  169. - alias: pm change on
  170. initial_state: true
  171. # hide_entity: true
  172. trigger:
  173. platform: state
  174. entity_id: input_boolean.pm
  175. from: 'off'
  176. to: 'on'
  177. action:
  178. - service: input_boolean.turn_off
  179. entity_id: input_boolean.am
  180. - service: input_boolean.turn_on
  181. entity_id: input_boolean.pm
  182.  
  183. - alias: alarm clock
  184. initial_state: true
  185. # hide_entity: true
  186. trigger:
  187. platform: time_pattern
  188. minutes: '/1'
  189. seconds: 00
  190. condition:
  191. - condition: template
  192. value_template: >-
  193. {{ is_state('binary_sensor.workday_sensor', 'on') or is_state('input_boolean.boolean_extra_work_day', 'on') }}
  194. - condition: template
  195. value_template: '{{ states.input_boolean.alarm_clock.state == "on" }}'
  196. - condition: template
  197. value_template: >
  198. {% if states.input_boolean.am.state == "on" %}
  199. {% set hour = (states.input_number.slider_hours.state | int) %}
  200. {% else %}
  201. {% set hour = (states.input_number.slider_hours.state | int) + 12 %}
  202. {% endif %}
  203. {{ 'true' if states.sensor.time.state.split(':')[0] |int == hour else 'false' }}
  204. - condition: template
  205. value_template: "{{ 'true' if (states.sensor.time.state.split(':')[1] |int == states.input_number.slider_minutes.state |int) else 'false' }}"
  206. action:
  207. - service: tts.google_say
  208. data:
  209. entity_id: media_player.googlehome4300
  210. message: 'Dzień Dobry Pora Wstawać'
  211. wait: 00:00:05
  212. - service: light.turn_on
  213. data:
  214. entity_id: light.downlight_z_komputer
  215. transition: 90
  216. - delay: '00:00:90'
  217. - service: script.start_playlist2
  218.  
  219.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement