Once again a problem with all-day calendar entries not working

Hi community,
my name is Fritz. This is my first post in this forum.
I feel that I have read my question here many times, but always in a different variation and I have never been able to implement the answer correctly so that my problem keeps unresolved.
A brief description of my situation: I have a radiator thermostat controlled by Home Assistant (current version, Raspberry 4 installation, Hass.io). I control this thermostat with a weekday and weekend automation. Very simple.

YAML code for weekday automation - just to show you. This works

alias: automation heating workday
description: ""
triggers:
  - trigger: time
    at: "04:00:00"
    id: Trigger ID automation heating workday ON
  - trigger: time
    at: "06:00:00"
    id: Trigger ID automation heating workday OFF
  - trigger: time
    at: "19:00:00"
    id: Trigger ID automation heating workday evening ON
  - trigger: time
    at: "20:30:00"
    id: Trigger ID automation heating workday evening OFF
conditions:
  - condition: state
    state: "on"
    entity_id: binary_sensor.workday_sensor
actions:
  - if:
      - condition: trigger
        id:
          - Trigger ID automation heating workday ON
    then:
      - action: climate.set_temperature
        metadata: {}
        data:
          temperature: 23
        target:
          entity_id: climate.thermostat1
  - if:
      - condition: trigger
        id:
          - Trigger ID automation heating workday OFF
    then:
      - action: climate.set_temperature
        metadata: {}
        data:
          temperature: 19.5
        target:
          entity_id: climate.thermostat1
  - if:
      - condition: trigger
        id:
          - Trigger ID automation heating workday evening ON
    then:
      - action: climate.set_temperature
        metadata: {}
        data:
          temperature: 23
        target:
          entity_id: climate.thermostat1
  - if:
      - condition: trigger
        id:
          - Trigger ID automation heating workday evening OFF
    then:
      - action: climate.set_temperature
        metadata: {}
        data:
          temperature: 19.5
        target:
          entity_id: climate.thermostat1
mode: single

Now I would like to add another automation to extend the heating for individual days. I would like to enter these days, weekdays, in the local calendar as an all-day appointment with the designation “Free”. On these days, the automation should also trigger an additional heating period. I have created this automation separately from the weekday automation.

The following automation does not work because

  • if I enter “Free” in the calendar on the next day, the calendar condition is still fulfilled.
  • The same behavior occurs if I enter “Free” a few days in the future.
  • If I delete “Free” from the calendar, the condition is not fulfilled
    I have the impression that the condition is fulfilled as soon as there is some entry with “Free” in the calendar.
alias: automation heating workday free
description: ""
triggers:
  - trigger: time
    at: "07:30:00"
    id: "0730"
  - trigger: time
    at: "09:30:00"
    id: "0930"
conditions:
  - condition: state
    entity_id: binary_sensor.workday_sensor
    state: "on"
  - condition: state
    entity_id: calendar.free_days
    attribute: message
    state: Free
actions:
  - if:
      - condition: trigger
        id:
          - "0730"
    then:
      - action: climate.set_temperature
        metadata: {}
        data:
          temperature: 23
        target:
          entity_id: climate.thermostat1
  - if:
      - condition: trigger
        id:
          - "0930"
    then:
      - action: climate.set_temperature
        metadata: {}
        data:
          temperature: 19.5
        target:
          entity_id: climate.thermostat1
mode: single

It would be great to find a simple solution for this as I would also like to be able to create controls with additional keywords for all-day calendar entries.

I hope for your support.
many thanks Fritz

As I recall, when you are inbetween events in the calendar, the calendar’s attributes will not be blank but reflect the next upcoming calendar event. This is super easy to verify by simply looking at the calendar state and attributes in the Developer Tools panel. The solution probably is to add a condition that the state of the calendar itself must be “on”, i.e. you are actually in the event.

Hi Magnus,
thank you for your reply. I think you are right. In the developer tools, the second tab “states” show the state “off” from the entity of my calendar when the entry “Free” is not today. It shows “on” when “Free” is noted in the calendar today.
The question is how I can use this “on” or “off” information of the calendar entity in the developer tools?
An additional condition in the automation for the heating, does not give the selection ‘State’ in the entity of the calendar.

Exactly the same as you already do in your other condition for the sensor. Do not specify an attribute, only the desired state.

- condition: state
  entity_id: calendar.free_days
  state: "on"

Just FYI, if the calendar in question has (or will have in the future) events that overlap with your all-day “Free” events, you will need to use the calendar.get_events action to query the calendar rather than simple conditions.

can you please explain this in more detail? perhaps with the steps I need to change? thank you very much

This really only matters if your calendar contains overlapping/contemporaneous events.

As Magnus has already stated above, the state of a calendar entity will be “on” as long as it has at least one active event. The calendar entity’s other attributes represent the values from the active event if there is one, otherwise the values from the next upcoming event.

However, when there are more than one active events, the values of the attributes will only reflect one of those events.

I don’t know if you need to change anything, because I don’t know if your calendar has overlapping events. If it doesn’t, use the condition Magnus shared previously.

The use of the action is covered in the Calendar integration docs:

There are dozens of threads available on this forum showing ways to use and manipulate the response data from the action.

Thank you @Didgeridrew for your input. I know that there are dozens of threads about calendar triggers. That is my problem that I mostly try to understand with copying the code but it does not work for me. That was the reason why I opend this topic. The solution of @Mayhem_SWE seems to work. Yesterday evening I changed the automation. I need to wait the coming days if it is really working. I do not know unfortunately how to simulate the behaviour of calendar days, so i need to wait.
I guess I will close the topic for now.
thank you all and best regards
Fritz