Miicroo / ha-birthdays

Birthday integration for HomeAssistant
24 stars 8 forks source link

How to trigger automation #1

Closed ranrinc closed 2 years ago

ranrinc commented 4 years ago

Hi there,

Is there away to trigger birthday wishes via google home on specific time (for example at 7'oclock in the morning) rather then after midnight?

and add RIP symbol next to the name of bday if he or she have been pass away?

rikardronnkvist commented 4 years ago

Something like this would probably work:

some_id:
  trigger:
    - platform: time
      at: "07:00:00"
  sequence:
    - service: tts.google_translate_say
      entity_id: media_player.some_player
      data_template:
        message: >
          {% for state in states.birthdays -%}
            {% if state.state == "0" -%}
              Today it's {{ state.name }} {{ state_attr(state.entity_id, "age_at_next_birthday")  }} birthday.
            {%- endif %}
          {%- endfor %}

(Cant get a code-block to work... but I think you can figure out how to use it :) )

Miicroo commented 2 years ago

@ranrinc I agree with @rirofal s solution, the best solution is to utilize HomeAssistant's time-platform for time based triggers! 👍 (also updated the code example in his comment with 3 front-ticks to fix the code block)