Edit Calendar Entry

Is there a way to move a local calendar event forward one day based on a google calendar entry calendar.holidays_in_united_states that equals for example memorial day?

I have a recurring entry for my trash and recycles in the local calendar. On 6 different Holidays the pickup date moves to the next day.

There are currently no services to edit, move, or delete existing calendar events so your only option is to make the modification at the time of creating the event.

We have a similar set up with our trash pickup so I run a script once a year that creates all the events in Local Calendar and handles the offset for the holidays.

Populate trash calendar script
alias: Calendar - Populate Trash Calendar
sequence:
  - variables:
      date_list: >
        {%- set ns = namespace(trash_nights= [], hol_start=[] ) %} 
        {%- set holiday= expand(label_entities('Trash Collection Holidays')) %}
        {# Loop through holiday sensor state objects, find the dates that will affect
        trash collection,  and create a list of dicts with required calendar event data#}
        {%- for each in holiday %}
          {%- set date = each.state|as_datetime|as_local%}
          {%- set isoweekday = (date).isoweekday() %}
          {%- if isoweekday not in [5, 6, 7] %}
              {%- set day_offset = 4 - isoweekday %}
             {%- set ns.trash_nights=ns.trash_nights +[
              {"summary": "Trash Night",
              "description": "Offset due to " ~ each.attributes.friendly_name,
             "start_datetime": (date + timedelta(days=day_offset)).replace(hour=18)|replace(" ","T")|string,
              "end_datetime": (date + timedelta(days=day_offset)).replace(hour=20)|replace(" ","T")|string}] %}
          {# Create a reference list of the dates trash night would have been on #}
              {%- set ns.hol_start = ns.hol_start + [ (date + timedelta(days=day_offset-1)).replace(hour=18)|replace(" ","T")|string ]%}
          {%- endif %}
        {%- endfor %}
        
        {# Determine number of weeks in the year and date of first trash collection #} 
        {%- set last = now().replace(month=12,day=31).isocalendar().week+1 %} 
        {% set last = 52 if last < 50 else last %}
        {%- set week_range = (range(1,last))|list%}
        {%- set d = today_at().replace(day=1, month=1) %}
        {%- set first = d +
timedelta(days = 2-d.weekday() ) %}
        
        {# Loop through all weeks of the year and create a list of dicts with required calendar event data#}
        {%- for i in week_range %}
          {%- set date = first + timedelta(days = 7 * (i)) %}
          {%- set ns.trash_nights = ns.trash_nights + 
          [{"summary": "Trash Night",
          "description": "",
          "start_datetime": date.replace(hour=18)|replace(" ","T")|string,
          "end_datetime": date.replace(hour=20)|replace(" ","T")|string }]-%}
        {%-endfor%}
        {# Combine the two lists of calendar event dicts,  reject those that fall on any of the times in the reference list from the end of the first loop and any that have already happened #}
        {{ ns.trash_nights | sort(attribute="start_datetime") | rejectattr("start_datetime", "in", ns.hol_start)| rejectattr("start_datetime", "lt", today_at()|string) | list }}
  - repeat:
      for_each: "{{date_list}}"
      sequence:
        - service: calendar.create_event
          data:
            summary: "{{ repeat.item.summary }}"
            description: "{{ repeat.item.description }}"
            start_date_time: "{{ repeat.item.start_datetime }}"
            end_date_time: "{{ repeat.item.end_datetime }}"
          target:
            entity_id: calendar.trash_night
        - delay: 2
mode: single
icon: mdi:calendar-edit-outline
1 Like

I see you calendar is called calendar.trash_night but I’m unclear how you populate the holidays. Thanks for sharing.

I have template sensors that store the date of upcoming holidays in their state. Holidays that affect trash collection are labeled “Trash Collection Holidays”. The second line {%- set holiday= expand(label_entities('Trash Collection Holidays')) %} saves a list of the state objects of all those sensors to a variable. The loop that follows checks if the dates are on days that will affect our trash pick up on Thursday and constructs a list of dictionaries with the necessary data to use in the calendar.create_event service and creates a list of datetimes when trash night would normally be so that those events can be delete from the results of the second loop.

Could you show me an example of you template sensors?

Here’s the old version:

https://gist.github.com/Didgeridrew/b3e6ec256d21cfb154fc224874b0a0c6

I’ve updated them in the last year to use the Easy Time Macros.

Easy Time Versions

# Trash Holidays: new years, independ, memorial, labor, christ, thanks
template:
  - trigger:
      - platform: time
        at: "00:01:00"
      - platform: state
        entity_id: input_button.update_holiday_sensors
      - platform: homeassistant
        event: start

# FIXED DATE

    sensor:
      - name: "New Years Day"
        unique_id: "37319374975705055206"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(1, 1)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(1, 1)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Dia de Los Reyes"
        unique_id: "1984497531937520705056"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(1, 6)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(1, 6)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Valentines Day"
        unique_id: "22719844595073910047"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(2, 14)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(2, 14)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Saint Patricks Day"
        unique_id: "44595073912271980047"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(3, 17)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(3, 17)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Halloween
        unique_id: "947396278926815041"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(10, 31)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(10, 31)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Dia de Muertos
        unique_id: "9750858485431103467"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(11, 2)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(11, 2)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Rex Manning Day
        unique_id: "4690662543745975107"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(4, 8)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(4, 8)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Christmas
        unique_id: "14318885502034384968"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(12, 25)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(12, 25)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Veterans Day"
        unique_id: "31975705053740693752"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(11, 11)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(11, 11)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Independence Day
        unique_id: "9084317551034684857"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(7,4)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(7, 4)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"


# VARIABLE DATE

  ## MONTH WEEK DAY

      - name: "Martin Luther King Jr"
        unique_id: "496217893819475026"
        state: >
          {% from 'easy_time.jinja' import month_week_day %}
          {{ (month_week_day(1, 3, 1)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_week_day %}
            {%- set x = ((month_week_day(1, 3, 1)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Mothers Day"
        unique_id: "749819475062189326"
        state: >
          {% from 'easy_time.jinja' import month_week_day %}
          {{ (month_week_day(5, 2, 7)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_week_day %}
            {%- set x = ((month_week_day(5, 2, 7)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Fathers Day"
        unique_id: "962741899473268150"
        state: >
          {# third Sunday of June #}
          {% from 'easy_time.jinja' import month_week_day %}
          {{ (month_week_day(6, 3, 7)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_week_day %}
            {%- set x = ((month_week_day(6, 3, 7)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Thanksgiving
        unique_id: "69425309251060427914"
        state: >
          {# 3rd Thursday in November #}
          {% from 'easy_time.jinja' import month_week_day %}
          {{ (month_week_day(11, 4, 4)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_week_day %}
            {%- set x = ((month_week_day(11, 4, 4)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Memorial Day
        unique_id: "20611770923315821822"
        state: >
          {# last Monday in May #}
          {% from 'easy_time.jinja' import last_day_in_month %}
          {{ (last_day_in_month(5, 1)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import last_day_in_month %}
            {%- set x = ((last_day_in_month(5, 1)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
          availability: "{{ now() is defined }}"

      - name: Labor Day
        unique_id: "78754309251267813130"
        state: >
          {# 1st Monday in September #}
          {% from 'easy_time.jinja' import month_week_day %}
          {{ (month_week_day(9, 1, 1)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_week_day %}
            {%- set x = ((month_week_day(9, 1, 1)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

  ## LUNAR-DERIVED

      - name: "Mardi Gras"
        unique_id: "734459509122779462132"
        state: >
          {% from 'easy_time.jinja' import easter %}
          {{ (easter()|as_datetime - timedelta(days=47)).date() }}
        attributes:
          days_until: >
            {% from 'easy_time.jinja' import easter %}
            {% set x = ((easter()|as_datetime 
            - timedelta(days=47)) - today_at()).days%}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Easter"
        unique_id: "189497506268132794"
        state: >
          {% from 'easy_time.jinja' import easter %}
          {{ easter() }}
        attributes:
          days_until: >
            {% from 'easy_time.jinja' import easter %}
            {% set x = ((easter()|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

# SEASONS
    binary_sensor:
      - name: Christmas Season
        unique_id: christmas_season_0001
        state: |
          {% set n = now() %}
          {% set offset = 'T00:00:00-05:00' %}
          {{  (states('sensor.thanksgiving')~offset)|as_datetime <= n or 
          n < (states('sensor.dia_de_los_reyes')~offset)|as_datetime }}

EDIT: There were a couple errors in the “Variable Date” section of the Easy Time version.

I’m not sure what the issue is. I added the lines

sensor: !include sensors.yaml
template: !include template.yaml

to my config.yaml file. Then added to the template.yaml file.

# Trash Holidays: new years, independ, memorial, labor, christ, thanks
template:
  - trigger:
      - platform: time
        at: "00:01:00"
      - platform: state
        entity_id: input_button.update_holiday_sensors
      - platform: homeassistant
        event: start

Finally added to the sensors.yaml file

# FIXED DATE

sensor:
  - name: "New Years Day"
    unique_id: "37319374975705055206"
    state: >
      {% from 'easy_time.jinja' import month_day %}
      {{ (month_day(1, 1)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_day %}
        {%- set x = ((month_day(1, 1)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: "Dia de Los Reyes"
    unique_id: "1984497531937520705056"
    state: >
      {% from 'easy_time.jinja' import month_day %}
      {{ (month_day(1, 6)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_day %}
        {%- set x = ((month_day(1, 6)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: "Valentines Day"
    unique_id: "22719844595073910047"
    state: >
      {% from 'easy_time.jinja' import month_day %}
      {{ (month_day(2, 14)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_day %}
        {%- set x = ((month_day(2, 14)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: "Saint Patricks Day"
    unique_id: "44595073912271980047"
    state: >
      {% from 'easy_time.jinja' import month_day %}
      {{ (month_day(3, 17)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_day %}
        {%- set x = ((month_day(3, 17)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: Halloween
    unique_id: "947396278926815041"
    state: >
      {% from 'easy_time.jinja' import month_day %}
      {{ (month_day(10, 31)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_day %}
        {%- set x = ((month_day(10, 31)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: Dia de Muertos
    unique_id: "9750858485431103467"
    state: >
      {% from 'easy_time.jinja' import month_day %}
      {{ (month_day(11, 2)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_day %}
        {%- set x = ((month_day(11, 2)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: Rex Manning Day
    unique_id: "4690662543745975107"
    state: >
      {% from 'easy_time.jinja' import month_day %}
      {{ (month_day(4, 8)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_day %}
        {%- set x = ((month_day(4, 8)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: Christmas
    unique_id: "14318885502034384968"
    state: >
      {% from 'easy_time.jinja' import month_day %}
      {{ (month_day(12, 25)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_day %}
        {%- set x = ((month_day(12, 25)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: "Veterans Day"
    unique_id: "31975705053740693752"
    state: >
      {% from 'easy_time.jinja' import month_day %}
      {{ (month_day(11, 11)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_day %}
        {%- set x = ((month_day(11, 11)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: Independence Day
    unique_id: "9084317551034684857"
    state: >
      {% from 'easy_time.jinja' import month_day %}
      {{ (month_day(7,4)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_day %}
        {%- set x = ((month_day(7, 4)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  # VARIABLE DATE

  ## MONTH WEEK DAY

  - name: "Martin Luther King Jr"
    unique_id: "496217893819475026"
    state: >
      {% from 'easy_time.jinja' import month_week_day %}
      {{ (month_week_day(1, 3, 0)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_week_day %}
        {%- set x = ((month_week_day(1, 3, 0)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: "Mothers Day"
    unique_id: "749819475062189326"
    state: >
      {% from 'easy_time.jinja' import month_week_day %}
      {{ (month_week_day(5, 2, 6)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_week_day %}
        {%- set x = ((month_week_day(5, 2, 6)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: "Fathers Day"
    unique_id: "962741899473268150"
    state: >
      {% from 'easy_time.jinja' import month_week_day %}
      {{ (month_week_day(6, 3, 6)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_week_day %}
        {%- set x = ((month_week_day(6, 3, 6)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: Thanksgiving
    unique_id: "69425309251060427914"
    state: >
      {% from 'easy_time.jinja' import month_week_day %}
      {{ (month_week_day(11, 4, 3)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_week_day %}
        {%- set x = ((month_week_day(11, 4, 3)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: Memorial Day
    unique_id: "20611770923315821822"
    state: >
      {% from 'easy_time.jinja' import month_week_day %}
      {{ (month_week_day(5, 5, 0)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_week_day %}
        {%- set x = ((month_week_day(5, 5, 0)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
      availability: "{{ now() is defined }}"

  - name: Labor Day
    unique_id: "78754309251267813130"
    state: >
      {% from 'easy_time.jinja' import month_week_day %}
      {{ (month_week_day(9, 1, 0)|as_datetime).date() }}
    attributes:
      days_until: >
        {%- from 'easy_time.jinja' import month_week_day %}
        {%- set x = ((month_week_day(9, 1, 0)|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  ## LUNAR-DERIVED

  - name: "Mardi Gras"
    unique_id: "734459509122779462132"
    state: >
      {% from 'easy_time.jinja' import easter %}
      {{ (easter()|as_datetime - timedelta(days=47)).date() }}
    attributes:
      days_until: >
        {% from 'easy_time.jinja' import easter %}
        {% set x = ((easter()|as_datetime 
        - timedelta(days=47)) - today_at()).days%}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

  - name: "Easter"
    unique_id: "189497506268132794"
    state: >
      {% from 'easy_time.jinja' import easter %}
      {{ easter() }}
    attributes:
      days_until: >
        {% from 'easy_time.jinja' import easter %}
        {% set x = ((easter()|as_datetime) - today_at()).days %}
        {{ iif(x < 1, x + 365, x) }}
    availability: "{{ now() is defined }}"

# SEASONS
binary_sensor:
  - name: Christmas Season
    unique_id: christmas_season_0001
    state: |
      {% set n = now() %}
      {% set offset = 'T00:00:00-05:00' %}
      {{  (states('sensor.thanksgiving')~offset)|as_datetime <= n or 
      n < (states('sensor.dia_de_los_reyes')~offset)|as_datetime }}

When I check my configuration in developer tools I get
“Invalid config for ‘sensor’ at configuration.yaml, line 31: required key ‘platform’ not provided”

More or less all of that should be in template.yaml.


#For use in template.yaml
  - trigger:
      - platform: time
        at: "00:01:00"
      - platform: homeassistant
        event: start    
    sensor:
      # HOLIDAYS WITH FIXED DATE
      - name: "New Years Day"
        unique_id: "37319374975705055206"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(1, 1)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(1, 1)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Dia de Los Reyes"
        unique_id: "1984497531937520705056"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(1, 6)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(1, 6)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Valentines Day"
        unique_id: "22719844595073910047"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(2, 14)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(2, 14)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Saint Patricks Day"
        unique_id: "44595073912271980047"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(3, 17)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(3, 17)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Halloween
        unique_id: "947396278926815041"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(10, 31)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(10, 31)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Dia de Muertos
        unique_id: "9750858485431103467"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(11, 2)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(11, 2)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Christmas
        unique_id: "14318885502034384968"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(12, 25)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(12, 25)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Veterans Day"
        unique_id: "31975705053740693752"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(11, 11)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(11, 11)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Independence Day
        unique_id: "9084317551034684857"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {{ (month_day(7,4)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(7, 4)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      # VARIABLE DATE: MONTH WEEK DAY      
      - name: "Martin Luther King Jr"
        unique_id: "496217893819475026"
        state: >
          {% from 'easy_time.jinja' import month_week_day %}
          {{ (month_week_day(1, 3, 1)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_week_day %}
            {%- set x = ((month_week_day(1, 3, 1)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Mothers Day"
        unique_id: "749819475062189326"
        state: >
          {% from 'easy_time.jinja' import month_week_day %}
          {{ (month_week_day(5, 2, 7)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_week_day %}
            {%- set x = ((month_week_day(5, 2, 7)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: "Fathers Day"
        unique_id: "962741899473268150"
        state: >
          {# third Sunday of June #}
          {% from 'easy_time.jinja' import month_week_day %}
          {{ (month_week_day(6, 3, 7)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_week_day %}
            {%- set x = ((month_week_day(6, 3, 7)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Thanksgiving
        unique_id: "69425309251060427914"
        state: >
          {# 3rd Thursday in November #}
          {% from 'easy_time.jinja' import month_week_day %}
          {{ (month_week_day(11, 4, 4)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_week_day %}
            {%- set x = ((month_week_day(11, 4, 4)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      - name: Labor Day
        unique_id: "78754309251267813130"
        state: >
          {# 1st Monday in September #}
          {% from 'easy_time.jinja' import month_week_day %}
          {{ (month_week_day(9, 1, 1)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_week_day %}
            {%- set x = ((month_week_day(9, 1, 1)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

      #VARIABLE DATE: LAST DAY
      - name: Memorial Day
        unique_id: "20611770923315821822"
        state: >
          {# last Monday in May #}
          {% from 'easy_time.jinja' import last_day_in_month %}
          {{ (last_day_in_month(5, 1)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import last_day_in_month %}
            {%- set x = ((last_day_in_month(5, 1)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
          availability: "{{ now() is defined }}"
 
      #VARIABLE DATE: LUNAR-DERIVED
      - name: "Easter"
        unique_id: "189497506268132794"
        state: >
          {% from 'easy_time.jinja' import easter %}
          {{ easter() }}
        attributes:
          days_until: >
            {% from 'easy_time.jinja' import easter %}
            {% set x = ((easter()|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"
      
      - name: "Mardi Gras"
        unique_id: "734459509122779462132"
        state: >
          {% from 'easy_time.jinja' import easter %}
          {{ (easter()|as_datetime - timedelta(days=47)).date() }}
        attributes:
          days_until: >
            {% from 'easy_time.jinja' import easter %}
            {% set x = ((easter()|as_datetime 
            - timedelta(days=47)) - today_at()).days%}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

If you are using these, you also need to install Easy Time Macro for them to work.

I believe I have Easy Time Macros install.


and all of your code from “Easy Time Versions” in the template.yaml. Rebooted . How do I check if the template sensors are working?

Look for them in the Entities list or in the States tool of Developer Tools.

They are not there. My Easy time macro must not be working

Test one of the templates using the macros in the Template editor tool…

{% from 'easy_time.jinja' import easter %}
{{ easter() }}

That correctly returns 3/31/24. I was trying to use the friendly name like “New Years Day” in the states tab. So I could run the Trash script to create the calendar entries?

Have you confirmed that the sensors exist?

If the sensors don’t exist, your next step is to figure out why and correct it.

If they do exist, the next step is to add the label to each of the sensors that affect your trash pickup.

The sensors do exist as it returns 3/31/24 for easter.
Do I add the label to the holidays in the template.yaml see code below 2nd line below state: >

# Trash Holidays: new years, independ, memorial, labor, christ, thanks
template:
  - trigger:
      - platform: time
        at: "00:01:00"
      - platform: state
        entity_id: input_button.update_holiday_sensors
      - platform: homeassistant
        event: start

    # FIXED DATE

    sensor:
      - name: "New Years Day"
        unique_id: "37319374975705055206"
        state: >
          {% from 'easy_time.jinja' import month_day %}
          {%- set holiday= expand(label_entities('Trash Collection Holidays')) %}
          {{ (month_day(1, 1)|as_datetime).date() }}
        attributes:
          days_until: >
            {%- from 'easy_time.jinja' import month_day %}
            {%- set x = ((month_day(1, 1)|as_datetime) - today_at()).days %}
            {{ iif(x < 1, x + 365, x) }}
        availability: "{{ now() is defined }}"

No, labels are handled through the frontend.

Appreciate your patience. I think the issue is I don’t have any sensors. Can you explain what the difference between the template.yaml file and sensor.yaml file? Do I need both? Putting your code in the template.yaml file does not create a sensor but does allow the developer tools/template editor to show that easy time jinja is working by returning 3/31/24 for easter with the code

{% from 'easy_time.jinja' import easter %}
{{ easter() }}

How do I create your custom sensors?
Once I create the custom sensors I can label them with “Trash Collection Holidays” with the new feature in HA UI that allows organization.

Not for this. Technically, you don’t need either of them; they are just an organizational tool.
There are a number of ways to split the configuration. Personally, I prefer Packages.

Assuming you have properly merged them in your configuration.yaml file, the sensor.yaml file is for configuring entities under the Sensor integration and template.yaml is for entities under the Template integration. While it is possible to create template sensors under the Sensor integration, this is not the preferred method and it they do not support all the current features and abilities. The sensor configuration I shared uses a trigger (which is not supported by the Sensor integration) and follows the syntax for the Template integration.

You copy the entire configuration in Post #8 and paste it into you template.yaml file.

Then you need to go to the Server Controls and either Restart Home Assistant or reload Template Entities. If you haven’t restarted since you first added anything into that file, you need to restart. If there are other things in that file that have already been properly loaded, you can just scroll down the list to Template Entities and click to reload just the Template integration.

The sensors do not exist despite placing your code in Post #8 in template.yaml and rebooting Home Assistant. Easy Time Jinja is in config/custom_template/easy_time.jinja.

I decided to start over and restore my proxmox backup to a date before I started messing with this. I added experimental to HACS and then installed the easy_time.jinja with the link vs manually installing. Added you template.yaml file code and added it the config.yaml file. By some miracle the sensors showed up and I can now label them.

After enabling the experimental setting in HACS I noticed my Frigate, Mushroom and Battery Card frontends don’t load. I get the error You have 3 Lovelace elements that are not loaded properly in Lovelace. I can redownload the frontends and the error goes away but comes back after a reboot. Any ideas on how to fix it.

The HACS errors are gone don’t know what I did to fix it.

Now that I have sensors created I was thinking about other use cases.
Labeling holidays that are days off from work and then send notification to turn my alarm off and then back on again the next day.

Do you have a script that I could modify that would add holidays to a calendar with a certain label? I’ve tried to adapt your current script but by jinja is very limited at this time. Thanks