Automation based on Google Agenda event

Hi All,

I have an automation which works perfectly when there is an agenda item with only VAZA16, VAZA17, VAZA18, VAZA19, VAZA20 or VAZA21 in the title or subject.

alias: Heating room - zone override
description: Control heating for room based on calendar events
trigger:
  - platform: calendar
    event: start
    offset: "0:0:0"
    entity_id: calendar.grote_zaal_toneel
condition:
  - condition: template
    value_template: >
      {{ trigger.calendar_event.summary in ['VAZA16', 'VAZA17', 'VAZA18',
      'VAZA19', 'VAZA20', 'VAZA21'] }}
action:
  - variables:
      target_temperature: |
        {% set temp_map = {
          'VAZA21': 21,
          'VAZA20': 20,
          'VAZA19': 19,
          'VAZA18': 18,
          'VAZA17': 17,
          'VAZA16': 16
        } %} {{ temp_map.get(trigger.calendar_event.summary, 0) }}
  - condition: template
    value_template: "{{ target_temperature != 0 }}"
  - service: evohome.set_zone_override
    metadata: {}
    data:
      entity_id: climate.3_grote_zaal
      setpoint: "{{ target_temperature }}"
mode: single

But is there a way to put in an agenda item where anywhere in the subject or title the words VAZA16, VAZA17, VAZA18, VAZA19, VAZA20 or VAZA21 can be placed and that the automation will search for that in stead of only these words in the subject or title. As an example I want an event in the agenda like this

Party VAZA17 and that the automation out of these event title extracts the VAZA17 and based on that controls the heating of the room.

Thanks a lot for your suggestions.
Mark

could you please format your yaml so that it is readable and editable for us?

see this:

Thanks @armedad , I changed this. It’s one of my first posts :slight_smile:

great. thanks.

take a look at the below. caveat: i’m not able to test it. so apologies if it’s not perfect, but i hope the framework works for you.

instead of hardcoding the list of vaza16 through 21, i parsed for vaza followed by any 2 digit number. so vaza15 will set the temperature to 15. vaza02 will set the temperature to 02…

you didn’t say what should happen if there are more than 2 vaza in the text, so i simply picked the first occurance and used just the first.

in my implementation if you have vaza in the middle of a word, e.g. hellovazaworld, it will pick the vaza out and fail unless it says something like hellovaza19world.

it only look in summary for vaza.

in any case, take a look at what i did and let me know if this does or doesn’t work for you.

you had a condition check in your code for temp==0, but it wasn’t in an if/then, so i’m not sure what it was doing. was that working for you? i changed and put it in an if/then that i think is what you intended (??)

alias: Heating room - zone override
description: Control heating for room based on calendar events
trigger:
  - platform: calendar
    event: start
    offset: "0:0:0"
    entity_id: calendar.grote_zaal_toneel
condition:
  - condition: template
    value_template: |
      {{ (trigger.calendar_event.summary.split('VAZA') | list | length) > 1 }}
action:
  - variables:
      target_temperature: >
        {{ (trigger.calendar_event.summary.split('VAZA')[1][:2]) | int(0)
        }}       
  - if:
      - condition: template
        value_template: "{{ target_temperature != 0 }}"
    then:
      - service: evohome.set_zone_override
        data:
          entity_id: climate.3_grote_zaal
          setpoint: "{{ target_temperature }}"

Thanks a lot @armedad you really helped me out!!! It’s working.
Is it also possible to limit that the value only can be between 16 and 21 so that only those temperatures can be used?
It seems you are really a scripting guy :slight_smile: Which I’am not…

Greetings Mark

something like this?

alias: Heating room - zone override
description: Control heating for room based on calendar events
trigger:
  - platform: calendar
    event: start
    offset: "0:0:0"
    entity_id: calendar.grote_zaal_toneel
condition:
  - condition: template
    value_template: |
      {{ (trigger.calendar_event.summary.split('VAZA') | list | length) > 1 }}
action:
  - variables:
      target_temperature: >
        {{ (trigger.calendar_event.summary.split('VAZA')[1][:2]) | int(0)
        }}       
  - if:
      - condition: template
        value_template: "{{ 15 < target_temperature < 22 }}"
    then:
      - service: evohome.set_zone_override
        data:
          entity_id: climate.3_grote_zaal
          setpoint: "{{ target_temperature }}"
1 Like

You are great!!! Thanks a lot!
Have a nice weekend.