Publish the local calendar to an ICS file

I’m using the local calendar of Home Assistant for triggering automations and storing important dates using the anniversary integration. I would love to see the events stored in the local calendar, in Google Calendar or Outlook. Therefore I would like to request an option to publish a calendar to an ics file, so a mail client can connect to the local calendar of my Home Assistant instance and import the events.

The local calendar is an ICS file, it’s located in your config/.storage folder.

I use the anniversary integration and this does not store info in a ics file. It generates a calender based in entity info in the hass.data (see code below). So an option to connect to al local calendar is still a wish for me

 async def async_get_events(
        self, hass: HomeAssistant, start_datetime: datetime, end_datetime: datetime
    ) -> list[CalendarEvent]:
        """Get all events in a specific time frame."""
        events: list[CalendarEvent] = []
        _LOGGER.debug("Anniversaries Calendar - Get Events")
        if SENSOR_PLATFORM not in hass.data[DOMAIN]:
            return events
        start_date = start_datetime.date()
        end_date = end_datetime.date()
        for ent in self.entities:
            _LOGGER.debug("Get Events: Entity Name: " + str(ent))
            if (ent not in hass.data[DOMAIN][SENSOR_PLATFORM]):
                continue
            entity = self._hass.data[DOMAIN][SENSOR_PLATFORM][ent]
            if (
                entity
                and entity.name
                and entity._next_date.date()
                and start_date <= entity._next_date.date() <= end_date
            ):
                event = CalendarEvent(
                    summary=entity.name,
                    start=entity._next_date.date(),
                    end=entity._next_date.date() + timedelta(days=1),
                    description=entity.extra_state_attributes["description"]
                    if "description" in entity.extra_state_attributes
                    else None,
                )
                events.append(event)
        return events

Make an automation that moves the events to local calendar

It made an Python script which creates an ICS file from all the anniversary integration sensors in Home Assistant and stores it in the www folder, so you can connect to it with an client (like Google Calendar)

This fixes my issue. Feel free to use it:Anniversaries/export_anniversaries_ics.py at f5044bd334d3c6c42045b785d124ebb2a84f1be6 · MdB-Gryphon/Anniversaries · GitHub

1 Like