Cinigua
(Cinigua)
December 27, 2024, 9:54am
1
Hi I subscribe an ICS calendar which is shown in Home Assistant correct.
Now I try to run an automation every time if there is an event with Titel: Homeoffice recognized.
I created the following condition which isn’t working correct.
condition: state
entity_id: calendar.kalender_arbeit
attribute: message
state: Homeoffice
enabled: true
In my eyes the main conditions are correct but the trigger fails every time.
Any suggestions?
Tamsy
(Tamsy)
December 27, 2024, 11:07am
2
Instead of using a state condition try by using a template condition like so:
condition:
- condition: template
value_template: "{{ 'Homeoffice' in state_attr('calendar.kalender_arbeit', 'message') }}"
koying
(Chris B)
December 27, 2024, 2:06pm
3
According to your trace, the attribute has ending blanks.
I’m surprised this is syntactically valid, though. Normally, you’d use to:
instead of state:
Anyways, keep in mind that if you have 2 consecutive “Homeoffice” events, the second one won’t trigger because the value of the message attribute won’t change.
Cinigua
(Cinigua)
December 28, 2024, 9:37am
4
Hi thanks but unfortunately this doesn’t work.
Tamsy
(Tamsy)
December 28, 2024, 9:41am
5
Show us the whole automation you have so far. Just posting snippets are not enough to evaluate.
Cinigua
(Cinigua)
December 28, 2024, 7:09pm
6
Hey this is the full automation for trails so far. I tested today a lot and now it seams to work. Next step is to trigger the automation with an all_day event. which I didn’t test so far, therefore it is disabled.
Any suggestions are welcome, thanks for your support
alias: Heizung EIN bei Homeoffice
description: ""
triggers:
- trigger: calendar
entity_id: calendar.kalender_arbeit
event: start
offset: "-1:0:0"
id: StartHomeoffice
- trigger: calendar
entity_id: calendar.kalender_arbeit
event: end
offset: "-1:0:0"
id: StopHomeoffice
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- StartHomeoffice
- condition: template
value_template: "{{ states.calendar.kalender_arbeit.attributes.all_day }}"
enabled: false
- condition: state
entity_id: calendar.kalender_arbeit
attribute: message
enabled: true
state: Homeoffice
sequence:
- action: telegram_bot.send_message
metadata: {}
data:
message: Homeoffice EIN
- conditions:
- condition: trigger
id:
- StopHomeoffice
- condition: state
entity_id: calendar.kalender_arbeit
attribute: message
enabled: true
state: Homeoffice
- condition: template
value_template: "{{ states.calendar.kalender_arbeit.attributes.all_day }}"
enabled: false
sequence:
- action: telegram_bot.send_message
metadata: {}
data:
message: Homeoffice AUS
mode: single
For it to work reliably you should base your template condition off the trigger
variable data not of the state of the calendar
entity.
Cinigua
(Cinigua)
December 28, 2024, 7:35pm
8
Sorry didn’t get this. Could you make an example, please?
There are examples in the Calendar integration docs , but esentially… instead of:
condition: state
entity_id: calendar.kalender_arbeit
attribute: message
state: Homeoffice
Use:
condition: template
value_template: "{{ trigger.calendar_event.summary == 'Homeoffice' }}"