Google Calender

Hi, hope someone can help a noob!

I’m trying to get my up & coming events to be broadcast to google home & have setup as below though it’s not working. To be truthful I’m a little out of my depth here & would really appreciate some pointers/help?

I can see the next coming event on the home assistant webpage though when the time is due nothing happens.

Cheers

configuration.yaml

google:
  client_id: !secret client_id
  client_secret: !secret client_secret

- platform: template
    sensors:

     event_title:
       friendly_name: 'Next Event'
       value_template: "{{ states.calendar.xxxxx.attributes.message }}"

     event_description:
       friendly_name: 'Description'
       value_template: "{{ states.calendar.xxxx.attributes.description }}"

     event_allday:
       friendly_name: 'All Day?'
       value_template: "{{ states.calendar.xxxxx.attributes.all_day }}"

     event_start:
       friendly_name: 'Event Time Start'
       value_template: "{{ states.calendar.xxxxx.attributes.start_time }}"

     event_end:
       friendly_name: 'Event Time' End'
       value_template: "{{ states.calendar.xxxxx.attributes.end_time }}"

group.yaml

Kalendar:
- sensor.event_title
- sensor.event_description
- sensor.event_allday
- sensor.event_start
- sensor.event_end

automation.yaml

- alias: 'Upcoming events'
     trigger:
       platform: state
       entity_id: sensor.event_start
       to: 'on'
     action:
       service: tts.google_say
       data_template:
        message: 'Hi {{ states.calendar.xxxxxx.attributes.message }}'
        entity_id: media_player.kitchen_home

When you test this in the template dev tool, do you get the expected result?

See “The dev tools are your friend” at:

Does service: tts.google_say work for you in other circumstances?

What happens when you trigger te automation using automation.trigger in the Services part of the dev tools in the front end?

Tried to though I get an “invalid json” & yes tts.google works for other automations I have setup
Just tested the automation trigger in the dev tools & that worked

What about the following in the dev tool?

{{ states.calendar.xxxxxx.attributes.message }}

Still states “invalid json”

Does the calendar definitely exist, and you['re putting the right trhing in in repalcement of xxxxxx?

Sure & just tested the automation trigger in the dev tools & that worked where I heard the next event correctly

So,m what is the value of the sensor.event_start ?

I just looked back at what you’ve got in the first post.

The trigger is wrong.

The trigger will run when sensor.event_start has a value of ‘on’ but the sensor.event_Start takes a value of the time that the event starts, it isn’t ‘on’/‘off’

Sure, so do I need to change my trigger to ‘event’? (not sure)

Yes. What value does the actual calendar (not the attributes) take before an event? “Off”? And then when the event starts the calendar itself (again, NOT the attributes), turns to “on”?

I have not used this component so I’m not sure?

- alias: 'Upcoming events'
  trigger:
    platform: state
    entity_id: calendar.xxxxxx
    to: 'on'
    from: 'off'

Not sure, but maybe try the above?

Cheers, I’ll give it a go & let you know - Thanks

(my spacing is wrong above so be careful - I’ll fix it now).

Well I tried but it just won’t accept the below no matter how I place the code (what a right PIA)

   - alias: 'Upcoming events'
     trigger:
       platform: event
       entity_id: calendar.xxxxxxxx
       to: 'on'
       from: 'off'
     action:
      service: tts.google_say
      data_template:
        message: 'Hi, {{ states.calendar.xxxxxxx.attributes.message }}'
        entity_id: media_player.kitchen_home

EDIT:

Just realised that I had ‘event’ instead of ‘state’

Unfortunately it still doesn’t work -

- alias: 'Upcoming events'
     trigger:
       platform: state
       entity_id: calendar.xxxxxxxx
       to: 'on'
       from: 'off'
     action:
      service: tts.google_say
      data_template:
        message: 'Hi, {{ states.calendar.xxxxxxx.attributes.message }}'
        entity_id: media_player.kitchen_home

Your spacing is off there. That might be it? All the lines below “action:” need an extra space.

Try running it through automation.trigger in the front end again?

Also, remove “from: ‘off’” as I don’t think that’s needed and it’s just over-complicating things whilst we are trying to sort this.

Finally, can you cvonfirm that if you look at states in dev tools, the calendar state is either on or off?

Changed spacing, removed “from: ‘off’”, automation.trigger runs fine where I hear the event gtom GH & the calendar shows ‘off’ in the dev tools. At a lost really even took a look at the homeassistant.log which doesn’t show much.

The logbook shows that the event ran fine

   - alias: 'Upcoming events'
     trigger:
       platform: state
       entity_id: calendar.xxxxxxgmailcom
       to: 'on'
     action:
        service: tts.google_say
        data_template:
           message: 'Hi, {{ states.calendar.xxxxxxgmailcom.attributes.message }}'
           entity_id: media_player.kitchen_home

Tried once again this time running in debug mode for the calendar which doesn’t show any issues

Just wanted to say ‘Thanks’ JamesKing for your assistance which has helped my resolve this issue.

Turns out that once I had the correct syntax (cheers) I had to create calendar entries that were longer than 0 minutes. After trial and error creating entries for 5 minutes or longer worked as expected.

:slight_smile: