Triggering an action based on Google Calendar entry containing a certain text

Hi there,

Am a very new user, so please forgive if this is a daft question!

I want to trigger a hue light based on whether a meeting room is …

  1. Booked for a private meeting - hue light is red
  2. Booked, but not for a private meeting - hue light is amber
  3. Free - hue light is green

I have successfully created automatons that get some of the way there …

  1. Room is booked (at all) - hue to red
  2. Room is Free - hue to green

I need to add a condition that tests the calendar entry for containing the text “[PRIVATE]” for the red light of the word “[OPEN]” for the amber light …

This snippet works for an exact match of the word “purple” as the meeting topic, but how do I get to the contains words element of what i want?

    value_template: '{{is_state_attr(''calendar.futurenetworkslab_calendar_digicatapult_org_uk'',
      ''message'', ''purple'') }}'

Try this:

    value_template: "{{ 'purple' in state_attr('calendar.futurenetworkslab_calendar_digicatapult_org_uk',
      'message') }}"

Wow, if that works it’s going to be fantastic. Thanks so much !! Really appreciate it.

This is how I have mine setup:

value_template: >-
  {{ 'no school' in states.calendar.summer_vacation.attributes.message.lower() }}

which would translate yours into:

value_template: >-
 {{ 'purple' in states.calendar.futurenetworkslab_calendar_digicatapult_org_uk.attributes.message.lower() }}

I like to use the .lower() to ensure that capitalization doesn’t mess with me :wink:

Fab, I am testing now!

I think it’s working :slight_smile: As it happens, there are actually 4 states in total that I need to deal with.

  1. No room booking => Green
  2. Room booking with text “[OPEN]” => Amber
  3. Room booking with text “[PRIVATE]” => Red
  4. Room booking without ("[OPEN]" or “[PRIVATE”]) => Amber

I’ll fool around to see if I can get this to work. Where can I find documentation on how to construct these boolean-like operations? i.e. “in” and “.lower” etc …

I’ve also noticed that there seems to be several minutes of tolerance on the triggers … i.e. a room is booked from 15:00 will not trigger until several minutes later … do I have any control over this??

I guess I would like to flip the status 5 minutes before a meeting starts and 5 minutes after it ends. I have a feeling this will cause some other nastiness if meetings are adjacent!

Thanks so much for the most excellent help.

Pat

Sorry to revive such an old thread but it contains a snippet of what I’m trying to do.
I’m very new to this coming from Webcore/Smartthings

I’m trying to figure out if this is right and also to add functionality to modify the message sent to Vicky depending on which property she has a clean for.

  1. We check Vicky.calendar to see if there is a match for ‘cleaning’
    We then need to check which property the clean is for, so I somehow need to add a if statement to modify the message_text XYZ…
    If contains OhakuneLot1 then XYZ = 30 my street
    if contains OhakuneLot2 then XYZ = 31 my street
    if contains ChaletGryon then XYZ = 21 Jump street
  2. We then notify the cleaner 2hrs before the clean as a reminder.

Trying to work out if this will work, without having to wait for the next event

alias: Notify Vicky of clean Today
description: ''
trigger:
  - platform: calendar
    event: start
    offset: '-2:0:0'
    entity_id: calendar.vicki_calendar
condition:
  - condition: template
    value_template: >-
      {{ 'cleaning' in states.calendar.vicki_calendar.attributes.message.lower()
      }}
action:
  - if:
      - condition: template
        value_template: >-
          {{ 'OhakuneLot1' in
          states.calendar.vicki_calendar.attributes.message.lower() }}
    then:
      - service: rest_command.websms_txt
        data:
          message_to: 64271234567
          message_text: >-
            This is a friendly reminder that you have a clean at 30c xxx Dr
            today
  - if:
      - condition: template
        value_template: >-
          {{ 'OhakuneLot2' in
          states.calendar.vicki_calendar.attributes.message.lower() }}
    then:
      - service: rest_command.websms_txt
        data:
          message_to: 64271234567
          message_text: >-
            This is a friendly reminder that you have a clean at 30d xxx Dr
            today
  - if:
      - condition: template
        value_template: >-
          {{ 'ChaletGryon' in
          states.calendar.vicki_calendar.attributes.message.lower() }}
    then:
      - service: rest_command.websms_txt
        data:
          message_to: 64271234567
          message_text: >-
            This is a friendly reminder that you have a clean at 132c xxx st
            today
  - if:
      - condition: template
        value_template: >-
          {{ 'OhakuneLot3' in
          states.calendar.vicki_calendar.attributes.message.lower() }}
    then:
      - service: rest_command.websms_txt
        data:
          message_to: 64271234567
          message_text: >-
            This is a friendly reminder that you have a clean at 30e xxx Dr
            today
mode: queued

So its working, however the problem I have is there is two entries for tomorrow at 11am and its sending the same message twice, rather than one for 30e and one for 132c xxx st

So I’m getting two messages to my mobile phone saying “clean at 30e xxx Dr”.

I’m assuming because only a single state can be read / reported at a time.
If I go to developer tools for the calendar, it shows the 30e entry but not the 132c entry even though both happen at the same time.