Code Monkey home page Code Monkey logo

ics_calendar's Introduction

ics_calendar

hacs_badge ics_calendar Coverage Maintained:yes License

Provides a component for ICS (icalendar) calendars for Home Assistant

NOTE: This component is intended for use with simple hosting of ICS files. If your server supports CalDAV, please use the caldav calendar platform instead. This one might work, but probably not well.

Installation

You can install this through HACS.

Otherwise, you can install it manually.

  1. Using the tool of choice open the directory (folder) for your HA configuration (where you find configuration.yaml).
  2. If you do not have a custom_components directory (folder) there, you need to create it.
  3. In the custom_components directory (folder) create a new folder called ics_calendar.
  4. Download all the files from the custom_components/ics_calendar/ directory (folder) in this repository.
  5. Place the files you downloaded in the new directory (folder) you created.
  6. Inside the new directory, run 'pip install -r requirements.txt'
  7. Restart Home Assistant
  8. Add ics_calendar: to your HA's configuration.

Using your HA configuration directory (folder) as a starting point you should now also have this:

custom_components/ics_calendar/__init__.py
custom_components/ics_calendar/manifest.json
custom_components/ics_calendar/calendar.py
custom_components/ics_calendar/icalendarparser.py
custom_components/ics_calendar/parsers/__init__.py
custom_components/ics_calendar/parsers/parser_ics.py
custom_components/ics_calendar/parsers/parser_rie.py

Authentication

This component supports HTTP Basic Auth and HTTP Digest Auth. It does not support more advanced authentication methods.

Example configuration.yaml

ics_calendar:
  calendars:
    - name: "Name of calendar"
      url: "https://url.to/calendar.ics"
    - name: "Name of another calendar"
      url: "https://url.to/other_calendar.ics"
      include_all_day: True
    - name: "Name of a calendar that requires authentication"
      url: "https://url.to/auth/calendar.ics"
      include_all_day: True
      username: True
      password: !secret auth_calendar

Configuration options

Key Type Required Description
calendars list True The list of remote calendars to check

Configuration options for calendar list

Key Type Required Description
name string True A name for the calendar
url string True The URL of the remote calendar
accept_header string An accept header for servers that are misconfigured, default is not set
connection_timeout float None Sets a timeout in seconds for the connection to download the calendar. Use this if you have frequent connection issues with a calendar
days positive integer False The number of days to look ahead (only affects the attributes of the calendar entity), default is 1
download_interval positive integer False The time between downloading new calendar data, in minutes, default is 15
exclude string False Allows for filtering of events, see below
include string False Allows for filtering of events, see below
include_all_day boolean False Set to True if all day events should be included
offset_hours int False A number of hours (positive or negative) to offset times by, see below
parser string False 'rie' or 'ics', defaults to 'rie' if not present
prefix string False Specify a string to prefix every event summary with, see below
username string False If the calendar requires authentication, this specifies the user name
password string False If the calendar requires authentication, this specifies the password
user_agent string False Allows setting the User-agent header. Only specify this if your server rejects the normal python user-agent string. You must set the entire and exact user agent string here.

Download Interval

The download interval should be a multiple of 15 at this time. This is so downloads coincide with Home Assistant's update interval for the calendar entities. Setting a value smaller than 15 will increase both CPU and memory usage. Higher values will reduce CPU usage. The default of 15 is to keep the same behavior with regards to downloads as in the past.

Home Assistant does two types of queries. One is the 15 minute calendar entity update, the other is a query every time the calendar.list_events service is called. This interval limit applies to both. On top of that there can be globally only one download in progress for all calendars. This might be an issue with lots of calendars and slow server response.

Offset Hours

This feature is to aid with calendars that present incorrect times. If your calendar has an incorrect time, e.g. it lists your local time, but indicates that it's the time in UTC, this can be used to correct for your local time. This affects all events, except all day events. All day events do not include time information, and so the offset will not be applied. Use a positive number to add hours to the time, and a negative number to subtract hours from the time.

Prefix

This feature prefixes each summary with the given string. You might want to have some whitespace between the prefix and original event summary. You must include whatever whitespace you want in your configuration, so be sure to quote the string. E.g.:

ics_calendar:
  calendars:
    - name: "Name of calendar"
      url: "https://url.to/calendar.ics"
      prefix: 'ICS Prefix '

Parsers

ics_calendar uses one of two parsers for generating events from calendars. These parsers are written and maintained by third parties, not by me. Each comes with its own sets of problems.

Version 1.x used "ics" which does not handle recurring events, and has a few other problems (see issues #6, #8, and #18). The "ics" parser is also very strict, and will frequently give parsing errors for files which do not conform to RFC 5545. Some of the most popular calendaring programs produce files that do not conform to the RFC. The "ics" parser also tends to require more memory and processing power. Several users have noted that it's unusuable for HA systems running on Raspberry pi computers.

The Version 2.0.0 betas used "icalevents" which is a little more forgiving, but has a few problems with recurring event rules. All-day events which repeat until a specific date and time are a particular issue (all-day events which repeat until a specific date are just fine).

In Version 2.5 and later, a new parser, "rie" is the default. Like "icalevents", it's based on the "icalendar" library. This parser appears to fix both issues #8 and #36, which are problematic for "icalevents".

Starting with version 2.7, "icalevents" is no longer available. If you have specified icalevents as the parser, please change it to rie or ics.

As a general rule, I recommend sticking with the "rie" parser, which is the default. If you see parsing errors, you can try switching to "ics" for the calendar with the parsing errors.

Filters

The new exclude and include options allow for filtering events in the calendar. This is a string representation of an array of strings or regular expressions. They are used as follows:

The exclude filters are applied first, searching in the summary and description only. If an event is excluded by the exclude filters, the include filters will be checked to determine if the event should be included anyway.

Regular expressions can be used, by surrounding the string with slashes (/). You can also specify case insensitivity, multi-line match, and dotall matches by appending i, m, or s (respectively) after the ending slash. If you don't understand what that means, you probably just want to stick with plain string matching. For example, if you specify "['/^test/i']" as your exclude filter, then any event whose summary or description starts with "test", "Test", "TEST", etc. will be excluded.

For plain string matching, the string will be searched for in a case insensitive manner. For example, if you specify "['test']" for your exclude filter, any event whose summary or description contains "test", "Test", "TEST", etc. will be excluded. Since this is not a whole-word match, this means if the summary or description contains "testing" or "stesting", the event will be excluded.

You can also include multiple entries for exclude or include.

URL Templates

If your ICS url requires specifying the current year and/or month, you can now use templates to specify the current year and month. E.g. if you set your url to:

url: "https://www.a-url?year={year}&month={month}"

The "{year}" part will be replaced with the current 4 digit year, and the "{month}" will be replaced with the current 2 digit month. So in February 2023, the URL will be "https://www.a-url?year=2023&month=02", in November 2024, the URL will be "https://www.a-url?year=2024&month=11".

Examples

ics_calendar:
  calendars:
    - name: "Name of calendar"
      url: "https://url.to/calendar.ics"
      exclude: "['test', '/^regex$/']"
      include: "['keepme']"

This example will exclude any event whose summary or description includes "test" in a case insensitive manner, or if the summary or description is "regex". However, if the summary or description includes "keepme" (case insensitive), the event will be included anyway.

Development environment setup

$ python3 -m venv ./env
$ ./env/bin/pip install --upgrade setuptools
$ ./env/bin/pip install --upgrade wheel

$ ./env/bin/pip install -r ./requirements.txt
$ ./env/bin/pip install -r ./requirements.dev.txt
$ ./env/bin/pip install -r ./requirements.test.txt

$ source ./env/bin/activate

Buy me some pizza

ics_calendar's People

Contributors

agroszer avatar ccmatrix avatar dannytrigo avatar franc6 avatar iamjackg avatar jberrenberg avatar moritzb57 avatar robvanuden avatar romkabouter avatar rsnodgrass avatar wrt54g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ics_calendar's Issues

RRULE parsing error

On-prem exchange server 2016. I can curl the URL okay but this integration doesn't seem to like it.

...
  File "/opt/python-venvs/hass/lib/python3.7/site-packages/tatsu/grammars.py", line 733, in parse
    return rule()
  File "/opt/python-venvs/hass/lib/python3.7/site-packages/tatsu/grammars.py", line 782, in parse
    result = self._parse_rhs(ctx, self.exp)
  File "/opt/python-venvs/hass/lib/python3.7/site-packages/tatsu/grammars.py", line 790, in _parse_rhs
    result = ctx._call(ruleinfo)
  File "/opt/python-venvs/hass/lib/python3.7/site-packages/tatsu/contexts.py", line 519, in _call
    result = self._recursive_call(ruleinfo)
  File "/opt/python-venvs/hass/lib/python3.7/site-packages/tatsu/contexts.py", line 548, in _recursive_call
    return self._invoke_rule(ruleinfo, self.memokey)
  File "/opt/python-venvs/hass/lib/python3.7/site-packages/tatsu/contexts.py", line 595, in _invoke_rule
    ruleinfo.impl(self)
  File "/opt/python-venvs/hass/lib/python3.7/site-packages/tatsu/grammars.py", line 296, in parse
    return ctx._token(self.token)
  File "/opt/python-venvs/hass/lib/python3.7/site-packages/tatsu/contexts.py", line 632, in _token
    self._error(token, exclass=FailedToken)
  File "/opt/python-venvs/hass/lib/python3.7/site-packages/tatsu/contexts.py", line 453, in _error
    raise self._make_exception(item, exclass=exclass)
tatsu.exceptions.FailedToken: (1:172) expecting '\r\n' :
DESCRIPTION:\n-------------------------------------------------------\nTicket ...

Error on newest HA beta

On the beta from yesterday I saw this error

�[1;37mFailed config�[0m
  �[1;31mGeneral Errors:�[0m �[31m�[31m
    - Platform error calendar.ics_calendar - cannot import name 'calculate_offset' from 'homeassistant.components.calendar' (/usr/local/lib/python3.9/site-packages/homeassistant/components/calendar/__init__.py)
    - Platform error calendar.ics_calendar - cannot import name 'calculate_offset' from 'homeassistant.components.calendar' (/usr/local/lib/python3.9/site-packages/homeassistant/components/calendar/__init__.py)
    - Platform error calendar.ics_calendar - cannot import name 'calculate_offset' from 'homeassistant.components.calendar' (/usr/local/lib/python3.9/site-packages/homeassistant/components/calendar/__init__.py)
�[0m

Failed to open url: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)

Hi,

I tryed added a MS exchange 2016 calendar to hassio with the ICS Calendar intrgrations in HACS

  • MS exchange 2016 (onpremise) with lets encrypt SSL cert (valid cert date)
  • Hassio 0.115.6
  • ICS calendar v1.0.5

Hassio log
2020-10-06 15:15:09 ERROR (SyncWorker_57) [custom_components.ics.calendar] Familie Gerrits: Failed to open url: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)
2020-10-06 15:15:14 ERROR (SyncWorker_22) [custom_components.ics.calendar] Familie Gerrits: Failed to open url: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)
2020-10-06 15:15:18 ERROR (SyncWorker_41) [custom_components.ics.calendar] Familie Gerrits: Failed to open url: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)
2020-10-06 15:15:21 ERROR (SyncWorker_28) [custom_components.ics.calendar] Familie Gerrits: Failed to open url: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)
2020-10-06 15:15:23 ERROR (SyncWorker_17) [custom_components.ics.calendar] Familie Gerrits: Failed to open url: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)

I can download the ICS without problems from the URL and if needed i can send the file or URL with PM or so.

Greetings Barry

List future events

Hi there,
I was testing your integration and as far as I understood it only create an entity which will be "triggered" the day of an event, if "today" has no event, it will be set to "off"

I would like to ask if there is somehow the possibility to see future events so that I can use in combination with the Atomic Calendar Card to show a month worth of data.

If it is possible I guess I am doing something wrong? :D

Also, on one specific calendar I got this error:

2020-05-12 14:46:05 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.serie_a fails
Traceback (most recent call last):
  File "/home/ha/.homeassistant/custom_components/ics/calendar.py", line 120, in _downloadAndParseCalendar
    calendar = Calendar(urlopen(self.url).read().decode().replace('\0', ''))
  File "/home/ha/homeassistant/lib/python3.7/site-packages/ics/icalendar.py", line 68, in __init__
    self._populate(containers[0])  # Use first calendar
  File "/home/ha/homeassistant/lib/python3.7/site-packages/ics/component.py", line 51, in _populate
    .format(container.name, line_name))
ValueError: A VCALENDAR must have at least one PRODID

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ha/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/home/ha/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 472, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/ha/.homeassistant/custom_components/ics/calendar.py", line 97, in update
    self.data.update()
  File "/home/ha/homeassistant/lib/python3.7/site-packages/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/home/ha/.homeassistant/custom_components/ics/calendar.py", line 167, in update
    calendar = self._downloadAndParseCalendar()
  File "/home/ha/.homeassistant/custom_components/ics/calendar.py", line 131, in _downloadAndParseCalendar
    except Error as error:
NameError: name 'Error' is not defined

This is the calendar config:

  - name: Serie A
    url: https://p01-calendars.icloud.com/published/2/2ItkHf_qlcSRk1rj3BefBc2TFdW65b9B-Nc5rqHtYBs4QV1YQBjJzOygJtGLPzptlPTqqQiO2oV0mT1hIbwVI9o3X8yv9PLC4fp95dPymLM
    includeAllDay: true

Thanks :)

Failed to open url: Service Unavailable for outlook.com

I trying to use this extension with Outlook.com (not office 365). In log Failed to open url: Service Unavailable. But url is woking well, it download ics file to my computer without any authorization. What can be wrong?

dont see items after 1-1-2022 and Please report it to the custom component author.

For me it doesnt see any calender items after 1-1-2022

also i get this error:

Entity calendar.kalender (<class 'custom_components.ics_calendar.calendar.ICSCalendarEventDevice'>) implements device_state_attributes. Please report it to the custom component author.
Entity calendar.vakantie (<class 'custom_components.ics_calendar.calendar.ICSCalendarEventDevice'>) implements device_state_attributes. Please report it to the custom component author.

Warning log entries regarding I/O inside event loop

I'm getting this recurring log entry that appears any time the card displaying my calendar is loaded:

2020-05-02 21:30:16 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for ics doing I/O at custom_components/ics/calendar.py, line 120: calendar = Calendar(urlopen(self.url).read().decode().replace('\0', ''))
2020-05-02 21:30:17 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for ics doing I/O at custom_components/ics/calendar.py, line 120: calendar = Calendar(urlopen(self.url).read().decode().replace('\0', ''))

The code leading up to the offending line is this:

class ICSCalendarData:
    """Calss to use the calendar ICS client object to get next event."""
...
    def _downloadAndParseCalendar(self):
        calendar = None
        try:
            calendar = Calendar(urlopen(self.url).read().decode().replace('\0', ''))
            ^^^

The calendars all appear to still be working, so it isn't fatal.

High CPU usage

Hello everyone!

First of all, thanks @franc6 for creating this great tool :)

I was wondering: is it possible to change how often the calendar gets updated? After adding a couple of calendars, I can see a huge increase in CPU usage:

image

The arrow shows when I've disabled all calendars from the integrations menu.

Thanks!

0.98.1 Error importing arrow

Just installed on the latest home assistant 0.98.1 and get the following error:

2019-09-01 21:27:52 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.ics. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 355, in _load_file
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/ics/__init__.py", line 2, in <module>
    from .calendar import VERSION
  File "/config/custom_components/ics/calendar.py", line 8, in <module>
    import arrow
ModuleNotFoundError: No module named 'arrow'

tatsu.exceptions.FailedToken: (1:22) expecting '\r\n'

I have installed the component on Hass.io with HACL but I receive and error when I try to use it.

2020-01-14 18:35:20 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.lillemor2 fails
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/ics/grammar/parse.py", line 76, in parse
ast = GRAMMAR.parse(line + CRLF)
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 1042, in parse
**kwargs
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 226, in parse
raise self._furthest_exception
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 218, in parse
result = rule()
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 782, in parse
result = self._parse_rhs(ctx, self.exp)
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 790, in _parse_rhs
result = ctx._call(ruleinfo)
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 519, in _call
result = self._recursive_call(ruleinfo)
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 548, in _recursive_call
return self._invoke_rule(ruleinfo, self.memokey)
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 595, in _invoke_rule
ruleinfo.impl(self)
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 390, in parse
ctx.last_node = [s.parse(ctx) for s in self.sequence]
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 390, in
ctx.last_node = [s.parse(ctx) for s in self.sequence]
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 733, in parse
return rule()
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 782, in parse
result = self._parse_rhs(ctx, self.exp)
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 790, in _parse_rhs
result = ctx._call(ruleinfo)
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 519, in _call
result = self._recursive_call(ruleinfo)
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 548, in _recursive_call
return self._invoke_rule(ruleinfo, self.memokey)
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 595, in _invoke_rule
ruleinfo.impl(self)
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 390, in parse
ctx.last_node = [s.parse(ctx) for s in self.sequence]
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 390, in
ctx.last_node = [s.parse(ctx) for s in self.sequence]
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 733, in parse
return rule()
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 782, in parse
result = self._parse_rhs(ctx, self.exp)
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 790, in _parse_rhs
result = ctx._call(ruleinfo)
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 519, in _call
result = self._recursive_call(ruleinfo)
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 548, in _recursive_call
return self._invoke_rule(ruleinfo, self.memokey)
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 595, in _invoke_rule
ruleinfo.impl(self)
File "/usr/local/lib/python3.7/site-packages/tatsu/grammars.py", line 296, in parse
return ctx._token(self.token)
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 632, in _token
self._error(token, exclass=FailedToken)
File "/usr/local/lib/python3.7/site-packages/tatsu/contexts.py", line 453, in _error
raise self._make_exception(item, exclass=exclass)
tatsu.exceptions.FailedToken: (1:22) expecting '\r\n' :
TZID:Europe/Stockholm
^
CRLF
contentline
start

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 281, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update
await self.hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/ics/calendar.py", line 97, in update
self.data.update()
File "/usr/src/homeassistant/homeassistant/util/init.py", line 240, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/ics/calendar.py", line 159, in update
calendar = Calendar(urlopen(self.url).read().decode())
File "/usr/local/lib/python3.7/site-packages/ics/icalendar.py", line 63, in init
containers = calendar_string_to_containers(imports)
File "/usr/local/lib/python3.7/site-packages/ics/grammar/parse.py", line 200, in calendar_string_to_containers
return string_to_container(string)
File "/usr/local/lib/python3.7/site-packages/ics/grammar/parse.py", line 183, in string_to_container
return lines_to_container(txt.splitlines())
File "/usr/local/lib/python3.7/site-packages/ics/grammar/parse.py", line 179, in lines_to_container
return parse(tokenize_line(unfold_lines(lines)))
File "/usr/local/lib/python3.7/site-packages/ics/grammar/parse.py", line 172, in parse
res.append(Container.parse(line.value, tokenized_lines))
File "/usr/local/lib/python3.7/site-packages/ics/grammar/parse.py", line 126, in parse
items.append(Container.parse(line.value, tokenized_lines))
File "/usr/local/lib/python3.7/site-packages/ics/grammar/parse.py", line 124, in parse
for line in tokenized_lines:
File "/usr/local/lib/python3.7/site-packages/ics/grammar/parse.py", line 165, in tokenize_line
yield ContentLine.parse(line)
File "/usr/local/lib/python3.7/site-packages/ics/grammar/parse.py", line 78, in parse
raise ParseError()
ics.grammar.parse.ParseError

Your custom component isn't working when using release version.

I'm trying your release_version because I wanted to solve #40

Config ics parser

calendar:
  - platform: ics_calendar
    calendars:
      - name: "RAFC2"
        parser: ics
        url: "https://www.voetbalkrant.com/soccer/calendar/team/team_2_nl.ics"

  - platform: ics_calendar
    calendars:
      - name: "RAFC"
        parser: ics
        url: "https://ics.maak-agenda.nl/v2/rafc-antwerp.ics?85029616d9c3ec7e"

  - platform: ics_calendar
    calendars:
      - name: "Belgie Verlof"
        parser: ics
        includeAllDay: True
        url: "https://www.google.com/calendar/ical/feestdagenbelgie%40gmail.com/public/basic.ics"

I have enabled debugging

logger:
  default: error
  logs:
    homeassistant.components.script: debug
    homeassistant.components.shelly: critical
    custom_components.ics_calendar: debug
    ics: debug
    icalevents: debug

This gives me as error

2021-12-13 15:00:09 DEBUG (SyncWorker_2) [custom_components.ics_calendar.calendar] Setting up ics calendars
2021-12-13 15:00:09 DEBUG (SyncWorker_2) [custom_components.ics_calendar.calendar] Initializing calendar: RAFC2
2021-12-13 15:00:09 DEBUG (SyncWorker_1) [custom_components.ics_calendar.calendar] Setting up ics calendars
2021-12-13 15:00:09 DEBUG (SyncWorker_1) [custom_components.ics_calendar.calendar] Initializing calendar: RAFC
2021-12-13 15:00:09 DEBUG (SyncWorker_4) [custom_components.ics_calendar.calendar] Setting up ics calendars
2021-12-13 15:00:09 DEBUG (SyncWorker_4) [custom_components.ics_calendar.calendar] Initializing calendar: Belgie Verlof
2021-12-13 15:01:10 ERROR (SyncWorker_4) [custom_components.ics_calendar.calendar] RAFC2: Failed to parse ICS!
2021-12-13 15:01:11 ERROR (SyncWorker_0) [custom_components.ics_calendar.calendar] RAFC: Failed to parse ICS!
2021-12-13 15:01:13 ERROR (SyncWorker_3) [custom_components.ics_calendar.calendar] Belgie Verlof: Failed to parse ICS!

Now I tried to use

calendar:
  - platform: ics_calendar
    calendars:
      - name: "RAFC2"
        # parser: ics
        url: "https://www.voetbalkrant.com/soccer/calendar/team/team_2_nl.ics"

  - platform: ics_calendar
    calendars:
      - name: "RAFC"
        # parser: ics
        url: "https://ics.maak-agenda.nl/v2/rafc-antwerp.ics?85029616d9c3ec7e"

  - platform: ics_calendar
    calendars:
      - name: "Belgie Verlof"
        # parser: ics
        includeAllDay: True
        url: "https://www.google.com/calendar/ical/feestdagenbelgie%40gmail.com/public/basic.ics"

so I should parse as ical and it gives me this errors

2021-12-13 14:50:13 DEBUG (SyncWorker_2) [custom_components.ics_calendar.calendar] Setting up ics calendars
2021-12-13 14:50:13 DEBUG (SyncWorker_2) [custom_components.ics_calendar.calendar] Initializing calendar: RAFC2
2021-12-13 14:50:13 DEBUG (SyncWorker_0) [custom_components.ics_calendar.calendar] Setting up ics calendars
2021-12-13 14:50:13 DEBUG (SyncWorker_0) [custom_components.ics_calendar.calendar] Initializing calendar: RAFC
2021-12-13 14:50:13 DEBUG (SyncWorker_4) [custom_components.ics_calendar.calendar] Setting up ics calendars
2021-12-13 14:50:13 DEBUG (SyncWorker_4) [custom_components.ics_calendar.calendar] Initializing calendar: Belgie Verlof
2021-12-13 14:50:45 ERROR (MainThread) [custom_components.ics_calendar.calendar] RAFC2: Failed to parse ICS!
2021-12-13 14:50:45 ERROR (MainThread) [custom_components.ics_calendar.calendar] RAFC: Failed to parse ICS!
2021-12-13 14:50:45 ERROR (MainThread) [custom_components.ics_calendar.calendar] Belgie Verlof: Failed to parse ICS!
2021-12-13 14:51:13 ERROR (SyncWorker_1) [custom_components.ics_calendar.calendar] RAFC2: Failed to parse ICS!
2021-12-13 14:51:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.rafc2 fails
Traceback (most recent call last):
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/core/config/custom_components/ics_calendar/calendar.py", line 139, in update
    self._attr_extra_state_attributes = { "offset_reached": is_offset_reached(event) }
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 129, in is_offset_reached
    start = get_date(event["start"])
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 66, in get_date
    if "date" in date:
TypeError: argument of type 'datetime.datetime' is not iterable
2021-12-13 14:51:13 ERROR (SyncWorker_4) [custom_components.ics_calendar.calendar] Belgie Verlof: Failed to parse ICS!
2021-12-13 14:51:13 ERROR (SyncWorker_3) [custom_components.ics_calendar.calendar] RAFC: Failed to parse ICS!
2021-12-13 14:51:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.rafc fails
Traceback (most recent call last):
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/core/config/custom_components/ics_calendar/calendar.py", line 139, in update
    self._attr_extra_state_attributes = { "offset_reached": is_offset_reached(event) }
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 129, in is_offset_reached
    start = get_date(event["start"])
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 66, in get_date
    if "date" in date:
TypeError: argument of type 'datetime.datetime' is not iterable
2021-12-13 14:52:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.rafc2 fails
Traceback (most recent call last):
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/core/config/custom_components/ics_calendar/calendar.py", line 139, in update
    self._attr_extra_state_attributes = { "offset_reached": is_offset_reached(event) }
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 129, in is_offset_reached
    start = get_date(event["start"])
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 66, in get_date
    if "date" in date:
TypeError: argument of type 'datetime.datetime' is not iterable
2021-12-13 14:52:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.rafc fails
Traceback (most recent call last):
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/core/config/custom_components/ics_calendar/calendar.py", line 139, in update
    self._attr_extra_state_attributes = { "offset_reached": is_offset_reached(event) }
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 129, in is_offset_reached
    start = get_date(event["start"])
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 66, in get_date
    if "date" in date:
TypeError: argument of type 'datetime.datetime' is not iterable
2021-12-13 14:53:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.rafc2 fails
Traceback (most recent call last):
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/core/config/custom_components/ics_calendar/calendar.py", line 139, in update
    self._attr_extra_state_attributes = { "offset_reached": is_offset_reached(event) }
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 129, in is_offset_reached
    start = get_date(event["start"])
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 66, in get_date
    if "date" in date:
TypeError: argument of type 'datetime.datetime' is not iterable
2021-12-13 14:53:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.rafc fails
Traceback (most recent call last):
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/core/config/custom_components/ics_calendar/calendar.py", line 139, in update
    self._attr_extra_state_attributes = { "offset_reached": is_offset_reached(event) }
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 129, in is_offset_reached
    start = get_date(event["start"])
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 66, in get_date
    if "date" in date:
TypeError: argument of type 'datetime.datetime' is not iterable
2021-12-13 14:54:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.rafc2 fails
Traceback (most recent call last):
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/core/config/custom_components/ics_calendar/calendar.py", line 139, in update
    self._attr_extra_state_attributes = { "offset_reached": is_offset_reached(event) }
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 129, in is_offset_reached
    start = get_date(event["start"])
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 66, in get_date
    if "date" in date:
TypeError: argument of type 'datetime.datetime' is not iterable
2021-12-13 14:54:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.rafc fails
Traceback (most recent call last):
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/core/config/custom_components/ics_calendar/calendar.py", line 139, in update
    self._attr_extra_state_attributes = { "offset_reached": is_offset_reached(event) }
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 129, in is_offset_reached
    start = get_date(event["start"])
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 66, in get_date
    if "date" in date:
TypeError: argument of type 'datetime.datetime' is not iterable
2021-12-13 14:55:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.rafc2 fails
Traceback (most recent call last):
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/core/config/custom_components/ics_calendar/calendar.py", line 139, in update
    self._attr_extra_state_attributes = { "offset_reached": is_offset_reached(event) }
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 129, in is_offset_reached
    start = get_date(event["start"])
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 66, in get_date
    if "date" in date:
TypeError: argument of type 'datetime.datetime' is not iterable
2021-12-13 14:55:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.rafc fails
Traceback (most recent call last):
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/core/config/custom_components/ics_calendar/calendar.py", line 139, in update
    self._attr_extra_state_attributes = { "offset_reached": is_offset_reached(event) }
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 129, in is_offset_reached
    start = get_date(event["start"])
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 66, in get_date
    if "date" in date:
TypeError: argument of type 'datetime.datetime' is not iterable
2021-12-13 14:56:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.rafc2 fails
Traceback (most recent call last):
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/core/config/custom_components/ics_calendar/calendar.py", line 139, in update
    self._attr_extra_state_attributes = { "offset_reached": is_offset_reached(event) }
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 129, in is_offset_reached
    start = get_date(event["start"])
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 66, in get_date
    if "date" in date:
TypeError: argument of type 'datetime.datetime' is not iterable
2021-12-13 14:56:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.rafc fails
Traceback (most recent call last):
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/Users/giel/Github/core/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/core/config/custom_components/ics_calendar/calendar.py", line 139, in update
    self._attr_extra_state_attributes = { "offset_reached": is_offset_reached(event) }
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 129, in is_offset_reached
    start = get_date(event["start"])
  File "/Users/giel/Github/core/homeassistant/components/calendar/__init__.py", line 66, in get_date
    if "date" in date:
TypeError: argument of type 'datetime.datetime' is not iterable

new calendar events are not added to calendar view

When I add new calendar event in the original calendar, I can see that the integration retrieves it (calendar.<calendar_name> entity returns something like this:

offset_reached: false
friendly_name: <calendar_name>
hide_attributes:
  - templates
message: Busy
all_day: false
start_time: '2022-06-25 12:45:00'
end_time: '2022-06-25 13:30:00'
location: ''
description: ''

).

However, the calendar view is not updated with this newly received event. It's also not recognized by automations. Is it expected behavior?

Some event titles not showing up in Home Assitant calendar screen

On the built-in Home Assistant calendar screen (https://[your-hostname]/calendar), some events have titles and others are blank (but their times still show up).

Looking at the code, I see an inconsistency between the names for the event title field.

'title': event.summary,

Solved by adding:

'summary': event.summary,

Not sure if this is an ideal solution, but it seems to work! Thank you for the excellent integration.

Special Character Lost From Titles

I have a multi day appointment with the title "Betws-y-Coed (Caravan Holiday)", but this comes through in the ics sensor with a description of "BetwsyCoed Caravan Holiday" (The dashes and brackets have been removed). It wasn't obvious to me where this was being done in the code, any idea?

Home Assistant Warning Issued

I have just installed this and noticed this in the logs.

Version core-2022.5.0
Installation Type Home Assistant OS

Logger: homeassistant.components.calendar
Source: components/calendar/__init__.py:197
Integration: Calendar ([documentation](https://www.home-assistant.io/integrations/calendar), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+calendar%22))
First occurred: 16:39:32 (1 occurrences)
Last logged: 16:39:32
CalendarEventDevice is deprecated, modify ICSCalendarEventDevice to extend CalendarEntity

Include the Description field from the ICS feed

Some calendars provide additional information, typically under a Notes section of the event when opening it in a calendar app. This is populated from the DESCRIPTION: xxx field of a VEVENT.

Eg:

BEGIN:VEVENT
DTSTAMP:20210508T160657Z
DTSTART;TZID=Europe/Stockholm:20200810T180657
SUMMARY:Matsedel
DESCRIPTION:Lunch\nUgnsgrillad kyckling korv med \nhemlagad potatismos och 
 ketchup.\n
UID:lunchmenu-33-0
TZID:Europe/Stockholm
END:VEVENT

It would be very useful if this field could be added to the ics_calendar component.

Installation problem

Just trying to setup calendar on my HA (latest)
installed ics_calendar latest from hacs.

and added the config like this:

calendar:
  - platform: ics_calendar
    calendars:
      - name: "Recycle"
        url: "https://cal.recyclecoach.com/admin/calendars/606-EDI-collection-1497-S12097.ics"

The calendar "recycle" shows in the calendar tab, but no entries in there

upon checking the log file i see this error:
2022-02-27 20:38:15 ERROR (MainThread) [custom_components.ics_calendar.calendar] Recycle: Failed to parse ICS!

all this calendar contains are my recycle days, nothing big.
wondering what the problem is.

update: XXXX: Failed to parse ICS!

I used to use the icalevent parser, now trying the tie parser for this config

- platform: ics_calendar
  calendars:
    - name: "RAFC2"
      # parser: icalevents
      days: 5
      url: "https://www.voetbalkrant.com/soccer/calendar/team/team_2_nl.ics"

It is giving me this error

Deze fout is ontstaan door een aangepaste integratie.

Logger: custom_components.ics_calendar.calendar
Source: custom_components/ics_calendar/parsers/parser_rie.py:56
Integration: ics_calendar (documentation, issues)
First occurred: 19:04:12 (1 occurrences)
Last logged: 19:04:12

update: RAFC2: Failed to parse ICS!
Traceback (most recent call last):
  File "/config/custom_components/ics_calendar/calendar.py", line 196, in update
    self.event = self.parser.get_current_event(
  File "/config/custom_components/ics_calendar/parsers/parser_rie.py", line 56, in get_current_event
    for event in rie.of(calendar).between(now, end):
  File "/usr/local/lib/python3.9/site-packages/recurring_ical_events.py", line 468, in of
    a_calendar = x_wr_timezone.to_standard(a_calendar)
  File "/usr/local/lib/python3.9/site-packages/x_wr_timezone.py", line 149, in to_standard
    return walker.walk(calendar)
  File "/usr/local/lib/python3.9/site-packages/x_wr_timezone.py", line 64, in walk
    subcomponent = self.walk_event(subcomponent)
  File "/usr/local/lib/python3.9/site-packages/x_wr_timezone.py", line 74, in walk_event
    attributes[name] = self.walk_value(value)
  File "/usr/local/lib/python3.9/site-packages/x_wr_timezone.py", line 85, in walk_value
    return walk(value)
  File "/usr/local/lib/python3.9/site-packages/x_wr_timezone.py", line 103, in walk_value_vDDDTypes
    dt = self.walk_value(value.dt)
  File "/usr/local/lib/python3.9/site-packages/x_wr_timezone.py", line 85, in walk_value
    return walk(value)
  File "/usr/local/lib/python3.9/site-packages/x_wr_timezone.py", line 126, in walk_value_datetime
    if self.is_UTC(dt):
  File "/usr/local/lib/python3.9/site-packages/x_wr_timezone.py", line 114, in is_UTC
    return dt.tzname().upper() == "UTC"
AttributeError: 'NoneType' object has no attribute 'upper'

Feature: Start of Week

Hi there,

awesome addon for HA so far. I noticed Weeks start on Sunday though.
Maybe it would be possible in a future release to set it to either Sunday or Monday?
Thx for the great work!

AttributeError: 'NoneType' object has no attribute 'start_datetime_local'

Hello to all !
I’m getting the following error.

First occurred: July 16, 2022, 8:23:44 PM (752 occurrences) 
Last logged: 8:54:43 AM

Update for calendar.icloud_calendar fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 514, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 709, in async_device_update
    raise exc
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/ics_calendar/calendar.py", line 198, in update
    self._event.start_datetime_local, self.data.offset
AttributeError: 'NoneType' object has no attribute 'start_datetime_local’

The configuration that i’m using is:

calendar:
- platform: ics_calendar
  calendars:
      - name: “Name"
        url: "https://<url>.ics”
        include_all_day: True

Any suggestions, please?
Thanks

Events over more Days

Hallo,
i have the problem that events that are longer than one day are only displayed on the first day.
Is this an "error" or is there an option for it and I just couldn't find it?

requirements not installed via HACS

I just installed this platform via HACS, but after restart I get exceptions 'ics' not found. I assume
pip install -r requirements.txt isn't executed. Why & how I can enforce this?

Parsing Error

Hello,

I have attempted to use both release and beta versions, but get this error;

2020-11-16 10:08:13 ERROR (SyncWorker_28) [custom_components.ics.calendar] FamilyCozi: Failed to parse ICS!

Ive PMed you on the HA forum with a copy of my ics file. thanks

Floating times not interpreted correctly

@franc6

I'm seeing the same problem

- platform: ics_calendar
  calendars:
      - name: "RAFC"
        parser: ics
        url: "https://www.voetbalkrant.com/soccer/calendar/team/team_2_nl.ics"
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//team_2_nl//NONSGML kigkonsult.se iCalcreator 2.20.2//
X-WR-TIMEZONE:Europe/Brussels
X-WR-CALNAME:Antwerp
X-WR-CALDESC:Bekijk de volledige kalender van voetbalploeg Antwerp uit Onbe
 kend.
...
BEGIN:VEVENT
UID:match_1025179
DTSTAMP:20210911T014015Z
DESCRIPTION:Wedstrijd van Speeldag 1 uit de Europa League  tussen Olympiako
 s Piraeus en Antwerp.\n\nOlympiakos Piraeus wint @ 1.76\nGelijk @ 4.00\nAn
 twerp wint @ 4.35\nWed op https://banners.livepartners.com/click.php?id=34
 9374&p=10&t=betslip&MasterEventID=24267084\n\nOnderlinge duels:\n\n09/12/2
 021 Antwerp - Olympiakos Piraeus: 0-0\n16/09/2021 Olympiakos Piraeus - Ant
 werp: 0-0
DTSTART:20210916T210000
DTEND:20210916T224500
SUMMARY:Olympiakos Piraeus - Antwerp
END:VEVENT

Schermafbeelding 2021-09-13 om 15 50 49

While the start time must be 21u

I've tried with and without parser: ics

homeassistant:
  # Name of the location where Home Assistant is running
  name: 79
  # Location required to calculate the time the sun rises and sets
  latitude: !secret latitude
  longitude: !secret longitude
  # Impacts weather/sunrise data (altitude above sea level)
  elevation: !secret elevation
  # 'metric' for Metric, 'imperial' for Imperial
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: Europe/Brussels

Originally posted by @gieljnssns in #6 (comment)

Option to change UserAgent

The current useragent is "Python-urllib/3.10" is good, but Cloudflare is marking it blocking becasuse this user agent such as commonly used by abusive bots, crawlers...

Can an option be added to set another value?

UnboundLocalError: local variable 'calendar_data' referenced before assignment

Hey i got this error when i upgraded to beta of today

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 471, in async_device_update
    await self.hass.async_add_executor_job(self.update)  # type: ignore
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/ics/calendar.py", line 102, in update
    self.data.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 239, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/ics/calendar.py", line 180, in update
    calendar_data = self._downloadAndParseCalendar()
  File "/config/custom_components/ics/calendar.py", line 148, in _downloadAndParseCalendar
    return calendar_data
UnboundLocalError: local variable 'calendar_data' referenced before assignment

Warnings in 2021.12b0

https://rc.home-assistant.io/blog/2021/12/03/release-202112/#updates-for-custom-integration-developers

2021-12-04 11:00:35 WARNING (MainThread) [homeassistant.helpers.entity] Entity calendar.rafc2 (<class 'custom_components.ics_calendar.calendar.ICSCalendarEventDevice'>) implements device_state_attributes. Please report it to the custom component author.
2021-12-04 11:00:35 WARNING (MainThread) [homeassistant.helpers.entity] Entity calendar.rafc (<class 'custom_components.ics_calendar.calendar.ICSCalendarEventDevice'>) implements device_state_attributes. Please report it to the custom component author.
2021-12-04 11:00:35 WARNING (MainThread) [homeassistant.helpers.entity] Entity calendar.belgie_verlof (<class 'custom_components.ics_calendar.calendar.ICSCalendarEventDevice'>) implements device_state_attributes. Please report it to the custom component author

All Events wrong time

Seems that all booking are 1 hour wrong, seems that something in the handle moves the event 1 hour forward

Like this event:
BEGIN:VEVENT
SUMMARY:Jobba
DTSTART;TZID=W. Europe Standard Time:20200121T070000
DTEND;TZID=W. Europe Standard Time:20200121T153000
UID:040000008200E00074C5B7101A82E00800000000B01768504EA0D501000000000000000
0100000001A9B2363ACC29B4A85D65E582DC139B7
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20191230T164515Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:0
LOCATION:KS Huddinge
X-MICROSOFT-CDO-APPT-SEQUENCE:0
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-CDO-INSTTYPE:0
X-MICROSOFT-DISALLOW-COUNTER:FALSE
END:VEVENT

is listed to start at 8 am and end 4.30pm

Unable to include 2 calendars

First, thanks for this awesome addon! 😄

I'm haveing some trouble adding the following calendars:

https://connect.garmin.com/modern/calendar/export/4ec9e47abf9447f19acd6a279823f3e7 results in:

hast_1             | 2021-01-07 21:56:46 ERROR (SyncWorker_16) [custom_components.ics.calendar] Joelstrening: Failed to open url: Forbidden
hast_1             | 2021-01-07 21:56:46 ERROR (MainThread) [custom_components.ics.calendar] Joelstrening: Failed to parse ICS!

and https://ukenr.no/ics/helligdager/no.ics results in:

hast_1             | 2021-01-07 21:56:46 ERROR (SyncWorker_2) [custom_components.ics.calendar] Helligdager: Failed to open url!
hast_1             | 2021-01-07 21:56:46 ERROR (MainThread) [custom_components.ics.calendar] Helligdager: Failed to parse ICS!

However both these parses fine in Nextcloud? I did an reference check with the iCalendar validator, and indeed they show some errors. I have 4 other ics calendars that works just fine so something with these two. The fact that NC parses them fine suggest the exception handling might a bit to strict?

Any way we could work around this @franc6 ?

Tested with 2.0.0-beta7 and 1.0.6 - both show the same error in the logs

FEATURE REQUEST - add additional attributes

HA calendar entities support additional attributes such as message, location, description, start_time and end_time attributes, etc.

Currently your component does not populate them. It would be awesome if you could add those. We could use this additional info to display calendar events start times, etc on dashboards.

(I only tested Google Calendar, but it appears to populate the start_ and end_time and the other attributes with the details of the current or next calendar event.)

Examples in documentation: CalDAV and Google.

Add "days" configuration (see also PR #33)

The rie and ics parsers don't automatically include the next future event, only what is current for the day.
The code should be restructured slightly and have this new parameter added.

Reoccurring events not shown

I got this working but I notice reoccurring events (a weekly Monday event in this case) don't show up. Does this handle reoccurring events? This is specifically from outlook.com if that makes a difference

Feature: Rate Limit

Hi,
I would propose a rate limit as a new feature.
At the moment, I have the problem, that if getting/parsing the ics causes an error, too many retries are made in a short timeframe.
I just got temporarly blocked from a 3rd party data provider, who complained about 16 requests per minute.

I would suggest something like: "min_interval: 1h" in the YAML-file.

Best regards
margau

No events after configuring calendar

Hi, thanks for the integration! Trying to avoid linking too much of HA to Google :)

I setup the integration via HACS and added the below to configuration.yaml per the README (including the actual source URL as well, it's just my trash pickup schedule, nothing sensitive 😛):

calendar:
  - platform: ics
    calendars:
      - name: "Trash Schedule"
        url: https://recollect.a.ssl.fastly.net/api/places/FAC93AA6-C940-11E5-8E68-AC5F07B87515/services/323/events.en-US.ics?client_id=B8D968D0-312A-11EB-8714-4152ED4F2F74

I get no errors of any sort in the logs, but no events are populating in the calendar. I peaked at the source and replicated it in the python REPL:

$ docker exec -it homeassistant bash
bash-5.0# python3
Python 3.8.9 (default, Apr 28 2021, 12:00:03) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ics
>>> from urllib.request import urlopen
>>> d = urlopen('https://recollect.a.ssl.fastly.net/api/places/FAC93AA6-C940-11E5-8E68-AC5F07B87515/services/323/events.en-US.ics?client_id=B8D968D0-312A-11EB-8714-4152ED4F2F74').read().decode().replace('\0', '')
>>> c = ics.Calendar(d)
>>> c.events
{<all-day Event 'Recycling' 2022-09-16>, <all-day Event 'Recycling, trash, and compost' 2022-01-21>, <all-day Event 'Recycling, trash, and compost' 2021-11-12>, <all-day Event 'Trash and compost' 2021-08-13>, <all-day Event 'Compost, recycling, and trash' 2022-05-27>, <all-day Event 'Compost and trash' 2022-02-11>, <all-day Event 'Recycling, trash, and compost' 2021-09-03>, <all-day Event 'Trash and compost' 2022-06-17>, <all-day Event 'Trash and compost' 2022-07-01>, <all-day Event 'Recycling' 2022-12-09>, <all-day Event 'Bulk item collection' 2021-12-13>, <all-day Event 'Compost, trash, and recycling' 2022-03-18>, <all-day Event 'Compost, recycling, and trash' 2021-12-24>, <all-day Event 'Trash and compost' 2022-04-08>, <all-day Event 'Recycling' 2022-10-28>, <all-day Event 'Compost and trash' 2022-05-20>, <all-day Event 'Trash and compost' 2022-07-29>, <all-day Event 'Large brush collection' 2021-11-22>, <all-day Event 'Recycling, trash, and compost' 2022-06-10>, <all-day Event 'Bulk item collection' 2021-07-05>, <all-day Event 'Recycling' 2022-08-19>, <all-day Event 'Recycling, trash, and compost' 2021-10-15>, <all-day Event 'Trash and compost' 2021-07-16>, <all-day Event 'Compost and trash' 2022-01-14>, <all-day Event 'Compost and trash' 2022-03-11>, <all-day Event 'Trash and compost' 2021-11-05>, <all-day Event 'Compost, trash, and recycling' 2021-08-06>, <all-day Event 'Compost, trash, and recycling' 2022-02-04>, <all-day Event 'Recycling, trash, and compost' 2022-04-01>, <all-day Event 'Trash and compost' 2021-09-24>, <all-day Event 'Compost, trash, and recycling' 2022-07-22>, <all-day Event 'Recycling' 2022-11-11>, <all-day Event 'Recycling, trash, and compost' 2021-11-27>, <all-day Event 'Recycling, trash, and compost' 2021-06-25>, <all-day Event 'Recycling' 2022-09-30>, <all-day Event 'Trash and compost' 2021-12-17>, <all-day Event 'Recycling' 2022-09-02>, <all-day Event 'Compost, trash, and recycling' 2022-04-29>, <all-day Event 'Compost, trash, and recycling' 2022-05-13>, <all-day Event 'Compost and trash' 2022-06-03>, <all-day Event 'Recycling' 2022-12-23>, <all-day Event 'Trash and compost' 2021-10-08>, <all-day Event 'Compost, trash, and recycling' 2021-07-09>, <all-day Event 'Compost, trash, and recycling' 2022-01-07>, <all-day Event 'Recycling, trash, and compost' 2022-03-04>, <all-day Event 'Compost and trash' 2022-02-25>, <all-day Event 'Trash and compost' 2022-04-22>, <all-day Event 'Compost, recycling, and trash' 2021-12-10>, <all-day Event 'Recycling, trash, and compost' 2021-09-17>, <all-day Event 'Compost and trash' 2021-08-27>, <all-day Event 'Recycling' 2022-10-14>, <all-day Event 'Trash and compost' 2022-07-15>, <all-day Event 'Trash and compost' 2021-06-18>, <all-day Event 'Trash, recycling, and compost' 2022-08-05>, <all-day Event 'Compost, trash, and recycling' 2021-10-01>, <all-day Event 'Trash and compost' 2021-07-30>, <all-day Event 'Compost and trash' 2021-07-02>, <all-day Event 'Compost, recycling, and trash' 2021-08-20>, <all-day Event 'Compost and trash' 2022-05-06>, <all-day Event 'Compost and trash' 2021-09-10>, <all-day Event 'Trash, recycling, and compost' 2022-06-24>, <all-day Event 'Compost, recycling, and trash' 2021-10-29>, <all-day Event 'Trash and compost' 2022-03-25>, <all-day Event 'Compost and trash' 2022-01-28>, <all-day Event 'Trash and compost' 2021-12-31>, <all-day Event 'Trash and compost' 2021-12-03>, <all-day Event 'Trash, recycling, and compost' 2022-02-18>, <all-day Event 'Trash, recycling, and compost' 2022-04-15>, <all-day Event 'Trash and compost' 2021-11-19>, <all-day Event 'Recycling' 2022-11-25>, <all-day Event 'Compost, trash, and recycling' 2022-07-08>, <all-day Event 'Trash and compost' 2021-10-22>, <all-day Event 'Trash, recycling, and compost' 2021-07-23>}

So the library seems to parse it just fine. Any idea on what's going on? Thanks!

Next event data attributes for use in sensor/automation

Hi,

In other calendar integrations I have seen (eg. google calendar), the data of the next event is exposed as attributes, such as start_time. I could use this to trigger automations, such as an alarm before the first meeting of the day.

However, this component doesn't seem to expose anything like that (at least not before the event starts). Is that by design? Or something that could be added? How are others achieving sensors/automation without it?

I can work on it if its something that would be accepted

Platform error calendar.ics - No module named 'arrow'

I'm not really sure waht the issue is, but I'm guessing.... missing import?

root@ha:/opt/hass-prod-cfg# hacheck
Testing configuration at /opt/hass-prod-cfg
Failed config
  General Errors:
    - Platform error calendar.ics - No module named 'arrow'

Successful config (partial)
root@ha:/opt/hass-prod-cfg# alias
alias hacheck='/opt/python-venvs/hass/bin/hass -c /opt/hass-prod-cfg --script check_config'

root@ha:/opt/hass-prod-cfg/custom_components/ics# grep -Ri ver
__init__.py:from .calendar import VERSION
calendar.py:VERSION = "1.0.5"

Office 365 ics

I get this error:
2021-09-17 14:06:14 ERROR (MainThread) [custom_components.ics_calendar.calendar] Egebaek: Failed to parse ICS!
2021-09-17 14:06:25 ERROR (SyncWorker_10) [custom_components.ics_calendar.calendar] Egebaek: Failed to parse ICS!

I have the calendar from my Office 365 work account

I can open it from any private browser

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.