Timing automation with an array variable?

Nob here…just trying to figure out some stuff with automation. I wrote my first one copied below.

I want to have Google Home devices speak out the time at the hour. I was able to get it to work at one time period being “11:clock1138:”. I want to know the following

  1. In the Triggers parameters if I can put in an “OR” function to say something like “11:00 || 12:00 || 1:00…” etc. is this possible?
  • Or maybe have an array of all the Timings into a variable say “timingarray” and just call the variable in the trigger?
  1. Once the array variable is called send it into the Action type to speak out the time with Google Home?

  2. Is timing a 24 hour format in HA? or I can specify 11:54pm or 11:54am?

  3. I have multiple Google Home. If I want to target just one how can I do that?

`- action:

  • data:
    message: the time is 11:38
    service: tts.google_say
  • data:
    message: the time is 11:38
    service: telegram_bot.send_message
    alias: New Automation 1
    condition: []
    id: ‘15195XXXXXXXX’
    trigger:
  • at: ‘11:38’
    platform: time
    `
    BTW the above code worked at 11:38. I heard Google home speak the phrase I had setup for it.

TIA.

Hi @BnvS !

From what I read here:

You should be able to set a simple trigger for every hour using

  trigger:
  - platform: time
    minutes: '/60'
    seconds: 00

You can make things easier for yourself by making a sensor that has the time as its state. You can then use this sensor in a template to have your Google Home say the time.

sensor:
- platform: time_date
  display_options:
    - 'time'

As for your Google Homes, you can find each of their names on the States page under Developer Tools.
For example, the google home in my kitchen is called media_player.kitchen_home.

So your full automation would look like

- alias: Hour Chime
  trigger:
  - platform: time
    minutes: '/60'
    seconds: 00
  action:
  - service: tts.google_say
    entity_id: media_player.your_google_homes_name
    data_template:
      message: 'The time is {{states.sensor.time.state}}. Jivesinger is thirsty. Buy him a beer.'
      cache: false

You just need to replace the name of your Google Home.

1 Like

This is a good suggestion. I was doing as you suggest but since I am a noob. I didn’t know how to customize this via the “Automation” menu. I tried several times but it didnt really work. I am sure you are likely using a auto script to run this program. Can you point me in the direction of how to set this up?

Additionally, How do I have it speak between 6am to 11pm but not at from 12am to 5am? as no one would want a time prompt during these times. At least not me.

Thanks