I have events that I would like to show from my google calendar that I have.
I have a 3rd party calendar imported to google account that is working great but my main email calendar is proving difficult.
I am want to search my calendar for the NEXT School Holidays event and for another sensor I would like to know when the parents and inlaws are on holiday too that I have down.
I can see the school holidays OK now after some playing about
I have the below in google_calnedars.yaml
- cal_id: ********************.apps.googleusercontent.com
entities:
- device_id: schoolhols
name: School Hols
track: true
search: "#School Holidays"
From here I have some template sensors in sensors.yaml and this shows the lovelace card the name of the event and then the start and end date.
I have tried to add another entity in Google_calendars.yaml but it doesnt seem to pull the events out matching the name of the search.
I have the below in google_calendars.yaml
- device_id: rjhols
name: Parent Holidays
track: true
search: "#Parent Holidays"
Here is the working text I have for getting the external calendar for rugby into HA.
- platform: template
sensors:
next_school_holidays_start:
value_template: >
{%- macro ordinal(num) %}
{%- set d = {1:'st',2:'nd',3:'rd'} %}
{%- set num = num | int %}
{%- if 10 < num % 100 <= 20 %}
{{- num }}th
{%- else %}
{{- num }}{{ d.get(num % 10, 'th') }}
{%- endif %}
{%- endmacro %}
{% set d = as_timestamp(strptime(state_attr('calendar.******_gmail_com', 'start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom(' %d') %}
{% set day = as_timestamp(strptime(state_attr('calendar.*******_gmail_com', 'start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom('%A ' ) %}
{% set end = as_timestamp(strptime(state_attr('calendar.******_gmail_com', 'start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom(' %B %Y') %}
{{ (day) ~ ordinal(d) ~ end }}
friendly_name: "Start"
- platform: template
sensors:
next_school_holidays_finish:
value_template: >
{%- macro ordinal(num) %}
{%- set d = {1:'st',2:'nd',3:'rd'} %}
{%- set num = num | int %}
{%- if 10 < num % 100 <= 20 %}
{{- num }}th
{%- else %}
{{- num }}{{ d.get(num % 10, 'th') }}
{%- endif %}
{%- endmacro %}
{% set d = as_timestamp(strptime(state_attr('calendar.******_gmail_com', 'end_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom(' %d') %}
{% set day = as_timestamp(strptime(state_attr('calendar.******_gmail_com', 'end_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom('%A ' ) %}
{% set end = as_timestamp(strptime(state_attr('calendar.*****_gmail_com', 'end_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom(' %B %Y') %}
{{ (day) ~ ordinal(d) ~ end }}
friendly_name: "Finish"
- platform: template
sensors:
next_rnj_holidays_finish:
value_template: >
{%- macro ordinal(num) %}
{%- set d = {1:'st',2:'nd',3:'rd'} %}
{%- set num = num | int %}
{%- if 10 < num % 100 <= 20 %}
{{- num }}th
{%- else %}
{{- num }}{{ d.get(num % 10, 'th') }}
{%- endif %}
{%- endmacro %}
{% set d = as_timestamp(strptime(state_attr('calendar.*****_gmail_com', 'end_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom(' %d') %}
{% set day = as_timestamp(strptime(state_attr('calendar.*****_gmail_com', 'end_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom('%A ' ) %}
{% set end = as_timestamp(strptime(state_attr('calendar.*****_gmail_com', 'end_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom(' %B %Y') %}
{{ (day) ~ ordinal(d) ~ end }}
friendly_name: "Finish"
So why cants I add the 2nd event to search and find the dates ?
Thanks
Martyn