time_of_day.yaml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. automation:
  2. - mode: restart
  3. id: "period_of_day_notify"
  4. alias: "Period of day: Notify"
  5. trigger:
  6. platform: state
  7. entity_id:
  8. - sensor.period_of_day
  9. action:
  10. - service: script.turn_on
  11. target:
  12. entity_id: script.notify_device
  13. data:
  14. variables:
  15. notify_device: notify.mobile_app_pixel_7_pro
  16. data:
  17. message: >-
  18. It is {{ states(trigger.entity_id) }}. {% if states(trigger.entity_id) not in ['day', 'night'] %}
  19. {{ state_attr(trigger.entity_id, 'twilight')|title }} twilight
  20. {% endif %}
  21. {% if state_attr(trigger.entity_id, 'dusk_dawn') != false %}
  22. {{ state_attr(trigger.entity_id, 'dusk_dawn')|title }} dusk
  23. {% endif %}
  24. data:
  25. notification_icon: "{{ state_attr(trigger.entity_id, 'icon') }}"
  26. color: '#ebb1bb'
  27. actions:
  28. - action: DISMISS_PERIOD_OF_DAY
  29. title: "Dismiss"
  30. channel: "Tests"
  31. group: "period-of-day"
  32. tag: "period-of-day"
  33. timeout: "{{ 60 * 2 }}"
  34. persistent: true
  35. importance: high