Swedish calendar

@Miicroo where has the repo gone? Have you killed the project?

Edit: nevermind! I had lost the repo in hacs and the one in the first post was wrong. Found the repo again.

1 Like

Updated the link in the first post in case anyone else gets the same problem :slight_smile:

1 Like

Hi! Next version will end your component if not updated.
2021-05-16 23:44:11 ERROR (MainThread) [homeassistant.loader] No ‘version’ key in the manifest file for custom integration ‘swedish_calendar’. As of Home Assistant 2021.6, this integration will no longer be loaded. Please report this to the maintainer of ‘swedish_calendar’

1 Like

Thanks! I had completely missed it. Fix available on master now! :slight_smile:

1 Like

@Miicroo are the project still alive? Last update killed the component för me.

@Christian_Hollbjar Yes, still alive! I just haven’t updated to 2022.6 yet so hadn’t noticed. Will look into it soon :slight_smile:

1 Like

@Christian_Hollbjar Ah, I had missed a deprecation notice for the loop keyword. Should probably update my dev environment for python more often :smiley: Pushed a fix, if you download the latest version I hope it should work!

1 Like

It did! Awesome :metal:

1 Like

Thanx for this integration it works great! except for the “reason for flagging” does anybody else have the same problem? mine just say “Unknown” even if its a flagday.

i have installed it via HACS and enabled it in the config without any exceptions
/M

@malogic I will look into it! :slight_smile: Is there any specific day you have noticed is missing? There doesn’t seem to be that many flagdays according to Flaggdagar i Sverige - Riksarkivet, and I dont have data as old as the last one stored in my HA (8th of Aug). I checked the API that the calendar is using and for the next day (valdagen) the flagging reason is there: https://sholiday.faboul.se/dagar/v2.1/2022/09/11. I will keep an extra eye out to see if it updates accordingly :smiley:

Yesterday was FN-dagen, a reason for flagging, and it seems to have been reported correctly in the integration :slightly_smiling_face:

1 Like

Same for me. FN-dagen was displayed and visible in the history, strange that it was not working when i tried a few months ago. I have a new possibility to test my automation in a few days. Nobeldagen.

I have a new problem though. I wish to be reminded in advanced. the same morning is a bit tight for the most part. better than nothing but i wish that i could get a reminder the day before.

i guess that its not in the scope of this integration… il have to make something of my own or use a birthday reminder like this. Create a "Birthday Reminder" Lovelace Card using Google Calendar integration

btw. why do we keep this thread in English?

1 Like

@malogic There is actually a possibility to be reminded in advance soon. I am working on a fix for Add to my calendars where it seems reasonable to view more than todays events in the calendar. Have just finished re-organising the project to support more complex features such as this one so no real feature work yet, but hopefully soon :slight_smile:

Hehe, threads have to be in English here, even though I doubt that other people than Swedes would care about Kanelbullens dag :wink:

General update, a version 2.0.0 is live and kicking on Github!

Major rewrite to follow HomeAssistant’s way of updating entities using a DataUpdateCoordinator which will make it easier to add more extensive config and features! :tada:

Read before updating!

When upgrading from a version pre-v2, note that you have to change your configuration.yaml. Instead of defining config for sensor:, use swedish_calendar:. Storing the config under an own domain will help keep the code clean, especially for features like #11 and #13 .

Clarification, an example of the new format looks like this:

swedish_calendar:
  special_themes_dir: /config/custom_components/swedish_calendar
  exclude:
    - day_of_week

The old obsolete format looks like this:

sensor:
  - platform: swedish_calendar
    special_themes_dir: /config/custom_components/swedish_calendar
    exclude:
      - day_of_week

Edit: Version 2.0.2 which contains crucial bugfixes was released yesterday. v2.0.0 and v2.0.1 had problems updating the sensors each night, which is now fixed.

1 Like

@malogic I am looking into configuring days ahead, do you need it for data related to Swedish calendar (such as flaggdag, röd dag, namnsdag etc) or is it more of a birthday scenarion where you know the date(s) and want to be notified a few days before said date?

I wish to know at least the day before so that i can have homeassistant to remind me at 20:00 “tomorrow its the flaggday nobeldagen, go get the flag and put it in the kitchen.” and a reminder on the actual day 07:30 “don’t forget to raise the flag”.

i wish to have this feature for personal flagdays aswell. “tomorrow its the flaggday wife birthday, go get the flag and put it in the kitchen.”

Ah, I see. I think that the solution you linked with the Google Calendar will be your best bet as it will be tricky to add your own custom “flag days” into this integration. It will probably also be easy to manage, since you can use your own calendar UI to create tasks instead of re-configuring the HA component (probably through yaml), restart the system and so on.

i dont mind the edit of a yaml/json file so much. I think that the “Special themes” function (edit the specialThemes.json" file) is a good one. but i don’t have any insights if its possible to do the same for flagdays.

would it be possible to add a sensor that is “day_before_flagday” like a copy of the first function and subtract one day from the API/Json list?

i dont know anything about python and i have not had a look at the code. (yes i have to learn. but the time…)
But in powershell i would have done it like this. (i have not botherd to write the code in a functioning way. :wink: but i guess that you get the idea)

$vardatesapi = get-api -https:someapi
$vardatesjson = get-content customflagdays.json
$var =   $vardatesapi + $vardatesjson

foreach ($line in $var)
{
$a = compare date.(adddays -1) -like $line.date
if ($a){its a day before flagday!}
}

Ah okay, now I understand what you mean! The main problem here is probably that each day in the current code is independent from the previous (and next) day. The code to parse flag day is here. As you can see the ApiData class just maps one day, without any knowledge of the rest of the days. This is to make sure that it works for those who only would like to see the current state (a.k.a calendar feature is turned off). In those cases you only have access to today’s data, and not yesterday. It is of course possible for you to do a short rewrite and run a custom custom component (very meta \o/), but that would probably be hard and cumbersome to maintain.

Updating specialThemes.json is probably a better solution, especially since we only have 3 or 4 flag days that move around each year, the rest are on static dates. The only thing to keep in mind here is to not use the auto_update-feature, and be sure to check when next year’s update is posted to github so it doesn’t overwrite your custom themes (usually around November/December). Maybe we can add a feature for like “own custom special themes” that never updates?

1 Like

Some updates have been rolled out during the autumn/winter! Note that some versions contained bugs, thus the patch version (last number in the version tag) might have been increased, like 2.2.1 instead of 2.2.0. Some versions also changed the configuration layout, so make sure to read the documentation/release notes when updating.

2.1.0 Support for the HomeAssistant calendar view

Config allows you to include which sensors to show in the calendar, and how many days in the past+future you would like to see.

2.2.1 Download latest specialThemes.json automatically every night

Option to download latest specialThemes.json automatically every night so you don’t have to keep track of when the file has been updated (especially around the new year).

2.3.1 Theme day is treated the same way as other sensors

Special themes sensor is included by default. No longer needed to specify directory where the specialThemes.json is stored, by default the installation directory will be tried. The config option to specify directory can still be used if the file is moved elsewhere.

2.3.1+ Improved development quality

Improved the quality of the code by adding automatic tests and validations so that the releases are less likely to contain bugs. This is only part of the development process though, so no change in behaviour for running installations.

2.4.0 Cache support

Optional config for caching sensor data, disabled by default. Helps if internet access is down a lot plus it makes boot times around 10x faster. If enabled, the cache is updated every 7 days, but can be configured.

2.4.1 Bug where the sensors did not update at midnight but at random times

Fixed bug where the sensors did not update at midnight but at random times introduced in 2.3.1

There are a few more enhancement coming, for instance config_flow support where the integration can be set up using the UI.

1 Like