Hello everyone
I’m new to Home Assistant, and I’m trying to create my first automations, but it’s not easy (the HA docs are difficult to understand sometimes…)
Despite my searches and several attempts to write an automation script, I cannot make a boolean input state change according to a calendar event.
I want that, when I’m not at work (therefore there is a whole day event in my Google calendar named « Absence », or on week-ends or on public holiday, the boolean input «Repos» (« rest » in english) is activated, else (when I’m at work, in working days or regular days), the boolean input is deactivated.
Here are the automations I tried :
1st, based on calendar event :
alias: "Evènement: Absence"
description: ""
trigger:
- platform: time
at: "00:00:00"
- platform: calendar
event: start
entity_id: calendar.agenda_perso
condition:
- condition: or
conditions:
- condition: state
entity_id: calendar.agenda_perso
attribute: message
state: Absence
- condition: state
entity_id: binary_sensor.workday_sensor
state: "off"
- condition: state
entity_id: calendar.france
state: "on"
action:
- target:
entity_id: input_boolean.absence
data: {}
action: input_boolean.turn_on
- metadata: {}
data:
message: Jour non travaillé
action: notify.info
mode: single
2nd, consisting in 2 single automations ( based on a template according to calendar event summary / 2nd based on workday status or on french public holiday status), each one activating the boolean input :
alias: "Evènement: présence"
description: ""
trigger:
- platform: calendar
event: start
entity_id: calendar.agenda_perso
condition:
- condition: template
value_template: "{{ 'absence' in trigger.calendar_event.summary }}"
action:
- target:
entity_id: input_boolean.absence
data: {}
action: input_boolean.turn_off
mode: single
alias: "Evènement: week-end ou jour férié"
description: ""
trigger:
- platform: time
at: "00:00:00"
condition:
- condition: or
conditions:
- condition: state
entity_id: calendar.france
state: "on"
- condition: state
entity_id: binary_sensor.workday_sensor
state: "off"
action:
- target:
entity_id: input_boolean.wejf
data: {}
action: input_boolean.turn_on
mode: single
I really thought the 2nd strategy would work, but it’s not the case…
Moreover, how can I force the boolean input deactivated when none of the conditions are met ?
Thank you for your help…