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
v1.0.0 and before
# 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
v2.0.0
# Example configuration.yaml entry, include all features as separate sensors
swedish_calendar:
You can also exclude the sensors you are not interested in
# Example configuration.yaml entry with exclusion
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
.
[2022-11-01] Version 2.0.0
Version 2.0.0 is now released, see this post: Swedish calendar - #82 by Miicroo