Entities Calendar - turn your entities into a calendar

Hi Steven,

Can you show an example how we can set a date entry to have it occurred on a yearly basis? I have tried your suggested config setup buy it is not working when I set the ‘nextoccur’ as a timestamp_attribute as per your suggestion. Here a copy of my config

sensor:
  - platform: template
    sensors:
       birthday_lisa:
         friendly_name_template: Lisa's Birthday
         value_template: '2020-11-09'
         device_class: timestamp



calendar:
  - platform: entities_calendar
    calendars:
      - name: Key Dates
        #icon: 'mdi:cake-variant'
        entities:
          - entity: sensor.birthday_lisa
            name: "Lisa's Birthday"
            all_day: true
            #start_time:
            #  timestamp_attribute: nextoccur

Thanks for your help.

You can use something like this:

sensor:
  - platform: template
    sensors:
      birthday_lisa:
        friendly_name: "Lisa's Birthday"
        device_class: timestamp
        value_template: > 
          {% set bday_lisa = {
          "thisyear": strptime(now().year | string + '1109', '%Y%m%d'),
          "nextyear": strptime((now().year+1) | string + '1109', '%Y%m%d')
          } %}        
          {% if (bday_lisa.thisyear | as_timestamp() > now() | as_timestamp()) %}
          {{ bday_lisa.thisyear }}
          {% else %}
          {{ bday_lisa.nextyear }}
          {% endif %}

When the current date is before the birthday, the sensor value will be this year, if not then next year’s birthday

Thanks Rom, appears to work very well. Smart use of template scripting :slight_smile:

Kudos to you. Grateful for your help/

2 Likes

Hello, strange but I get 4 hours back on calendar.

Sensor template:

  - platform: template
    sensors:
      event_appointments_echo:
        friendly_name: "Vlad Lenox Hill Echo"
        value_template: "2021-04-09"
        device_class: "timestamp"
        attribute_templates:
          start_time: '2021-04-09 09:25:00'
          end_time: '2021-04-09 10:25:00'
  - platform: entities_calendar
    calendars:
      - name: Appointments
        entities:
          - entity: sensor.event_appointments_echo
            all_day: false
            start_time:
              timestamp_attribute: start_time
            end_time:
              timestamp_attribute: end_time

In “Developer Tools” time is correct:

But on Calendar:
sensor1

Any suggestions? What I’m doing wrong?

I did study your calendar.py file and after adding “-04:00” to start_time and end_time everything is good. Solved

Is it possible to dynamically create the name? I’m pulling my last 20 cards from ClickUp and trying to get them in a calendar but no matter what I do, it won’t actually evaluate the expression. I’ve tried all sorts of combinations like below, but the name is always just whatever I put in (in this case: {{ state_attr(‘sensor.clickup’,‘name’) }}). It evaluates fine in Developer tools, just not here. Any ideas?

I’m pretty new to this so this is probably something obvious.

calendar:
  - platform: entities_calendar
    calendars:
      - name: Entities
        entities:
          - entity: sensor.clickup
            name: "{{ state_attr('sensor.clickup','name') }}"
            start_time:
              timestamp_in_state: true
            end_time:
              timestamp_in_state: true

Please forgive what is probably a stupid question but where exactly (which .yaml) do I add this “calendar” data ??

calendar:
  - platform: entities_calendar
    calendars:
      name: My Entities
      entities:
        - sensor.first_entity
        - sensor.second_entity
        - sensor.third_entity

I have installed the integration thru HACS (0.08) and restarted HA, but I can find no evidence of this integration and have no idea where to add any configs :slight_smile:

I tried adding this as a sensor:

  - platform: entities_calendar
    calendars:
      - name: Appointments
        entities:
          - entity: sensor.event_appointments_echo
            all_day: false
            start_time:
              timestamp_attribute: start_time
            end_time:
              timestamp_attribute: end_time

But the validation failed:

Platform error sensor.entities_calendar - No module named 'custom_components.entities_calendar.sensor'

Is there a getting started guide for dummies like me :slight_smile:

OK, firat part solved:

configuration.yaml:

calendar: !include my_calendar.yaml

my_calendar.yaml:

- platform: entities_calendar
  calendars:
    - name: Bin Collection
      entities:
        - entity: sensor.bin_collection_general
          name: General Waste Collection
        - entity: sensor.bin_collection_recycling
          name: Recycling Collection
        - entity: sensor.bin_collection_garden
          name: Garden Waste Collection
    - name: Other Calendar
      entities:
        - entity: sensor.date
          name: Today

And then a new menu “Calendar” appears in the left panel.

EDIT

Hmm, there does not seem to be any activity with this thread, is this integration still active / supported ?

How can I create calendar entities from a json source ?

I have a REST sensor that returns the Refuse collection in the following format:

{
  "20220509": [ "GARDEN" ],
  "20220514": [ "RECYCLING", "REFUSE" ],
  "20220519": [ "RECYCLING" ],
  "20220523": [ "GARDEN" ],
  "20220526": [ "RECYCLING" ]
}

I know how to iterate through dictionaries using templating, but how would I go about converting multiple calendar entities from a sensor / template that returns a JSON object as per the sample above ?

Any update on support for entities which are a specific time during a day?
@Steven_Rollason

After October update - this Addon stopped working :frowning:

The system cannot restart because the configuration is not valid: Platform error calendar.entities_calendar - cannot import name ‘CalendarEventDevice’ from ‘homeassistant.components.calendar’ (/usr/src/homeassistant/homeassistant/components/calendar/init.py)

A fix for this was in a beta version (0.0.9b0) but I’ve just pushed this as a non-beta release.

made a template for the afvalinfo HACS integration
and i was wondering if i is possible to have multiple events based on a comma seperated attribute

attribute info;

year_month_day_date: 2023-03-29
whole_year_dates: 2023-03-29, 2023-04-12, 2023-04-26, 2023-05-10, 2023-05-24, 2023-06-07, 2023-06-21, 2023-07-05, 2023-07-19, 2023-08-02, 2023-08-16, 2023-08-30, 2023-09-13, 2023-09-27, 2023-10-11, 2023-10-25, 2023-11-08, 2023-11-22, 2023-12-06, 2023-12-20

changing year_month_day_date to whole_year_dates will break the calender
now it will make an event on 2023-03-29
but then it will make one on 2023-03-29, 2023-04-12, 2023-04-26, 2023-05-10 etc

calendar:
  platform: entities_calendar
  calendars:
    name: Omrin Afval
    entities:
      - entity: sensor.gft
        name: GFT
        start_time:
           timestamp_attribute: year_month_day_date
      - entity: sensor.kerstboom
        name: Kerstboom
        start_time:
           timestamp_attribute: year_month_day_date
      - entity: sensor.papier
        name: Papier
        start_time:
           timestamp_attribute: year_month_day_date        
      - entity: sensor.pbd
        name: Plastic
        start_time:
           timestamp_attribute: year_month_day_date
      - entity: sensor.restafval
        name: Rest
        start_time:
           timestamp_attribute: year_month_day_date
      - entity: sensor.textiel
        name: Textiel
        start_time:
           timestamp_attribute: year_month_day_date