If an event will start from my google calendar, I want home assistant to extract all the datas and send them to my android device, where Tasker with the help of AutoNotification, will capture these informations, add them to an array, then throw them into a tasker scene, showing the event as a full screen notification.
When a detail is not defined (like the location, title, description), tasker should not show that info. This is where I got stuck:
alias: Notify - Calendar Events
description: ""
triggers:
- trigger: state
entity_id:
- calendar.work
conditions:
- condition: state
entity_id: calendar.work
state: "on"
actions:
- if:
- condition: template
value_template: "{{ state_attr('trigger.entity_id','message') != '' }}"
then:
- variables:
summary: "{{ state_attr('trigger.entity_id','message') }}"
else:
- variables:
summary: " "
- if:
- condition: template
value_template: "{{ state_attr('trigger.entity_id','all_day') == false }}"
then:
- variables:
start: >-
{{ as_timestamp(state_attr('calendar.work','start_time')) |
timestamp_custom('%H:%M:%S, %d.%m.%Y') }}
else:
- variables:
start: " "
- if:
- condition: template
value_template: "{{ state_attr('trigger.entity_id','all_day') == false }}"
then:
- variables:
end: >-
{{ as_timestamp(state_attr('calendar.work','end_time')) |
timestamp_custom('%H:%M:%S, %d.%m.%Y') }}
else:
- variables:
end: " "
- if:
- condition: template
value_template: "{{ state_attr('trigger.entity_id','all_day') == true }}"
then:
- variables:
all_day: All Day
else:
- variables:
all_day: " "
- if:
- condition: template
value_template: "{{ state_attr('trigger.entity_id','location') != '' }}"
then:
- variables:
location: "{{ state_attr('trigger.entity_id','location') }}"
else:
- variables:
location: " "
- if:
- condition: template
value_template: "{{ state_attr('trigger.entity_id','description') != '' }}"
then:
- variables:
description: "{{ state_attr('trigger.entity_id','description') }}"
else:
- variables:
description: " "
- action: notify.mobile_app_entrance_tablet
metadata: {}
data:
title: Calendar Event
message: >-
{{ summary }}/{{ start }}/{{ end }}/{{ all_day }}/{{ location }}/{{
description }}
mode: single
The automation it is sending everything needed and if a detail will not be available, it will send " " (space), because tasker does not know about a variable with no value, it will fire an error, so, the character space, will help in this situation.
All good with this, it is working, but I have an event type “all_day”, the automation will not trigger anymore for other events (in that day), only after this “all_day” type event will finish, then, the automation will trigger again for the next events… So, it is not a good solution till now, I am still trying to make it work…
I know that summary attribute it is NOT optional, but doesn’t care so much. If you don’t trust me, test it. I created an event with no title, when the event will fire and home assistant request the needed infos, it will not care, not even an warning will appear, it will not give a value to that attribute, thats it…
Now, after more tests, I am aware that I was wrong thinking that those attributes arre useless… I thought that I can do everything with the entity attributes, but nope… as you can see my upper automation, that will not work for the case with all_day…