How to set condition based on calendar event

Hello community,
I’m trying to create an automation with a condition based on a calendar event, but do not know how to do. Could someone point me out a solution, Thanks in advance.

My problem is the following:
I have in the calendar an event going from Date1 to Date2.
I would like to set a condition which returns true when the current date is between Date1 and Date2 but with an offset of 1 day, i.e. is between Date1 -1 and Date2 -1.

Without this 1 day offset, it would be very simple

    - condition: state
      entity_id: calendar.mycalendar
      state: 'on'

but how to add this 1 day offset ?

Try this sensor:


It’s available in HACS.

I use a modification that is in on the github page and it gives me this:

So eta is when the event starts (minutes from now).
And timeleft is when it ends.

@Heila68
Thanks a lot for the solution.
I just can’t find the modification you mention. Because I only see the Eta attribute but not the Timeleft attribute

The sensor.zip posted here:

Thanks. Unfortunately, the modified sensor.zip creates for me an error and the sensors are not created anymore by the integration :frowning:
But the integration you suggest gives me a very good idea to create a sensor by myself.
As follow,

sensor:
  - platform: template
      oneday_before_event:
        value_template: >-
          {% if as_timestamp(now()) > as_timestamp(state_attr('calendar.mycalendar', 'start_time')) - 86400 
             and as_timestamp(now()) < as_timestamp(state_attr('calendar.mycalendar', 'end_time')) - 86400 %}
            'on'
          {% else %}
            'off'
          {% endif %}

and it works ! :slight_smile: