Swedish calendar

Inspired by the Jewish calendar sensor I decided to create a sensor for a Swedish calendar. The sensor contains data regarding days and holidays. The API that is used returns values that are in Swedish (such as names for weekdays), but the sensor descriptions and entity ids are all in English.

Supported features (all are based on today):

  • Date (e.g. 2019-01-16)
  • Week (e.g. 03)
  • Weekday (e.g. Onsdag)
  • Day of week (e.g. 3)
  • Workfree day (Ja/Nej)
  • Day before workfree holiday (Ja/Nej, if tomorrow is a workfree holiday)
  • Red day (Ja/Nej, holidays + Sundays are considered red days, but a lot of the eves are not)
  • Eve (eve before holiday)
  • Holiday (e.g. Julafton, name of holiday)
  • Reason for flagging (e.g. the king’s birthday)
  • Celebrated names (each day a number of names are celebrated (namnsdag))

Configuration

# Example configuration.yaml entry, include all features as separate sensors
sensor:
  - platform: swedish_calendar

You can also exclude the sensors you are not interested in

# Example configuration.yaml entry with exclusion
sensor:
  - platform: swedish_calendar
    exclude:
      - date
      - day_before_workfree_holiday

The following sensor types are supported/can be excluded:

  • date
  • week
  • day_of_week
  • weekday
  • workfree_day
  • day_before_workfree_holiday
  • red_day
  • eve
  • holiday
  • flag_day
  • name_day

Push notification for celebrated names

To send a push when someone you know celebrates their name, you can use the following automation

- alias: 'Send push on important namnsdag'
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: sensor.swedish_calendar_name_day
  condition:
    - condition: template
      value_template: >-
        {% set names_of_today = states.sensor.swedish_calendar_name_day.state.split(",") %}
        {% set wanted_names = ['Lisa', 'Kalle', 'Johan', 'Anna'] %}
        {% for name in names_of_today %}
          {% if (name in wanted_names) %}
            true
          {% endif %}
        {% endfor %}
  action:
    service: notify.pushbullet
    data_template:
      title: 'Namnsdag!'
      message: "Idag firas {{ states.sensor.swedish_calendar_name_day.state }} "

Source code and installation

The source code and more documentation can be found here.
To install, download the swedish_calendar.py and put it in my-ha-config-dir/custom_components/sensor/swedish_calendar.py.

6 Likes

I get this message from hass.io after the update to 0.90.2:
Integrations need to be in their own folder. Change sensor/swedish_calendar.py to swedish_calendar/sensor.py. This will stop working soon.

Do I just need to rename swedish_calendar.py and copy to a new folder according to the above?

Ah yes, I have forgotten to restructure my git project! Changing folder and name to swedish_calendar/sensor.py fixes the warning :slight_smile:

Great addon, this will make me able to ask Google Home what namesday it is or what week it is. But one thing more would be cool. If it would contain “special” days like Kanelbullens dag, Mors dag, Menlösa barns dag and so on. I think every day of the year has this kind of “special” day and it would be fun to have this implemented in this.

1 Like

Awesome that you like it!
I’ll look into a special days variable, but it might take some time. Currently I use the API from https://api.dryg.net which has no info about custom events. It is certainly possible to solve anyway but there are so many days to consider that it will take some time. Cheers! :slight_smile:

I am getting an error as of hass.io 0.92.0 (the first release that demands a sensor.py in a separate folder).
I have created a folder named …/custom_components/swedish_calendar/ and created a new file with the content from sensor.py to a file with the same name in my folder. I have the lines

sensor:
  - platform: swedish_calendar

in my config, but I don’t get any swedish calendar sensors at all and no error in the home-assistant.log either.

Anybody else got it working in 0.92.0?

Same problem for me…
Cant get it to start…

You should also have an empty file _init_.py

Thanks, that worked!

Thanks, I haven’t updated to 0.92 yet so had missed that part. I will add it to the docs :slight_smile:

A manifest.json file to.

could you add support for custom updater? https://github.com/custom-components/custom_updater/tree/master/docs

Ooh, this has been on my backlog for a while. Finally got around to do it, but have not tested it yet. I have added everything that I could find in the docs but haven’t actually run it on my own system. Everything is available in the repo though, and I’ll update it if I find any errors. :slight_smile:

1 Like

it wont show up in my updater. i did som comparing with other components and yours dont look the same way.

example: https://github.com/twrecked/hass-aarlo/blob/master/custom_components.json
example: https://github.com/Limych/media_player.linkplay/blob/master/custom_components.json

1 Like

it still wont show up in custom updater…

Agreed, I updated the jsonconfig for custom_updater but still nothing. I made the smooth move to update HA, and now I dont even get a UI, but hopinf to fix both that and the updater-confif this weekend :slight_smile:

1 Like

Finally got it working! I only used the new files from the repo (updated a while ago), but it also seems like you have to manually install custom_components and not just define the custom_update.json-url. Found the how-to here: https://github.com/pnbruckner/homeassistant-config/blob/master/docs/custom_updater.md#Installing

Yes you need the custom updater component to. Mine still won’t show up, but I will take a look at it tomorrow again.

Edit: aah now I see what you mean, I have never done that with any other custom Component… What did you specify: sensor.???
Becaus you mean this?

Yes exactly. Not sure if that was the trick, or if I got it working another way (I had another custom component that was messing with HA, might be because I removed it from the custom_updater config). I used “sensor.swedish_calendar” as input, with the latest files from the swedish_calendar repo freshly downloaded.

1 Like

was just playing around with it :slight_smile:

1 Like