Added the check if the calendar entry is on tomorrow

I have a markdown output with which I check whether tomorrow is a working day and whether my alarm clock is set. If both apply, I give the set alarm time

This is my currently code:

{% if is_state('binary_sensor.arbeitstag_morgen', 'on') %} {% if is_state('input_boolean.wakestatus_1', 'on') %}  ## <font color="#7B3F00"><ha-icon icon="mdi:alarm"></ha-icon></font> gestellt morgen {{ states('input_datetime.waketime_1') }} {% else %}{% endif %}{% endif %}  

Now I would like to add to the query whether there is no entry in calendar.arbeit_urlaub tomorrow

I have currently no idea how to add this if in my code.

have anyone an idea?

This is not super easy at the moment, but i am thinking about this problem as an extension of calendar triggers.

My impression is the way to do this is:

  • (A) Have a calendar setup just dedicated to the event you want to check e.g. “Trash day” calendar
  • (B) Then have another separate calendar that can be used to trigger the check, e.g. an event at 7am that’s called “Trash day Trigger”
  • (C) Write an automation that fires on (B) then looks at the state of entity (A) and looks at the attribtues on the entity to determine if its tomorrow, then run the automation

I haven’t tried this, but this is the idea discussed in the livestream for the release this week when discussing calendar offsets.

There are also some examples in Calendar - Home Assistant of using calendar trigger. You may be able to just get away with an offset added to the trigger for an all day event.

I’m just not sure if we’re talking about the same thing. I don’t want to do automation. But only a text output in a markdown

My calendar state shows on or off. But I would linke to check the calendar state for tomorrow.

Maybe I’m a step further now. I have

I have add in the configuration.yaml at the calendar days: 7. So in the calendar entitie the next date appears 7 days in advance.

But now I need your support again.

The attributes stat_time look:
start_time: ‘2022-06-06 00:00:00’

How can I check if states.calendar.arbeit_urlaub.attributes.start_time is now()+1

in my currently

{% if is_state('binary_sensor.arbeitstag_morgen', 'on') %} {% if is_state('input_boolean.wakestatus_1', 'on') %}  ## <font color="#7B3F00"><ha-icon icon="mdi:alarm"></ha-icon></font> gestellt morgen {{ states('input_datetime.waketime_1') }} {% else %}{% endif %}{% endif %}  

I have create this code:

{{ (now().date() + timedelta(days=1)) | string == 
                             as_timestamp(states.calendar.arbeit_urlaub.attributes.start_time) | timestamp_custom('%Y-%m-%d') }}

With this code I get true (if tomorrow is an vocation day) and false (if tomorrow is no vocation day).

Now I try with this code an if around

{% if (now().date() + timedelta(days=1)) | string == 
                             as_timestamp(states.calendar.arbeit_urlaub.attributes.start_time) | timestamp_custom('%Y-%m-%d') == "True" %} 
yes
{% else %}
no
{% endif %}

But I got a no back, although start_time is the date of tomorrow.

You can use the automation triggers to capture the state and set them, e.g. using a binary sensor template that sets the state based on the calendar event trigger. I think trying to do everything in a single template is too difficult IMO.

I have found a solution:

{% if as_timestamp(now() + timedelta(days=1)) | timestamp_custom('%Y-%m-%d') != as_timestamp(states.calendar.arbeit_urlaub.attributes.start_time) | timestamp_custom('%Y-%m-%d') %}

And this is the complete code:

{% if is_state('binary_sensor.arbeitstag_morgen', 'on') %} {% if is_state('input_boolean.wakestatus_1', 'on') %} {% if as_timestamp(now() + timedelta(days=1)) | timestamp_custom('%Y-%m-%d') != as_timestamp(states.calendar.arbeit_urlaub.attributes.start_time) | timestamp_custom('%Y-%m-%d') %} ## <font color="#7B3F00"><ha-icon icon="mdi:alarm"></ha-icon></font> gestellt morgen {{ states('input_datetime.waketime_1') }} {% else %}{% endif %}{% endif %}{% endif %} 

Is your work schedule the typical Monday to Friday? I am guessing that it might not be; hence the calendar usage.

If it is, then checking “if tomorrow is a workday” is super easy using the Workday Integration with days_offset: 1

Yes my work schedule is monday to friday. And I use the workday integration for the working days. But my lust isue was to add vocationsdaays from a calander.

But now it works fine.

This is what I was afraid of after initial reading of the Calendar Integration. Calendar sprawl :frowning:

Being able to parse a single calendar w/ all the things you want seems to be the common goal atm.

And maybe it’s there, and we just don’t have enough examples yet using the trigger options…

[edit] wait a minute, why didn’t I see this before!? → Automation trigger variables - Home Assistant
All the trigger definitions!

Yeah this is all somewhat new. I added a few recipes on the calendar integration page, but definitely more we can do here.

Can you make a Blueprint of the Tomorrow automation ?

OK the other way is to just have a time based trigger instead of the 7am separate event.