home-assistant: add holidays

This commit is contained in:
Ingolf Wagner 2020-06-11 18:08:14 +02:00
parent 6cd2b63d35
commit 0054694bdf
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B

View file

@ -1,7 +1,19 @@
{ config, ... }: { { config, lib, ... }:
let
holiday-range = month: dayA: dayB:
map (day: "${month}-${toString day}")
(map (lib.fixedWidthNumber 2) (lib.range dayA dayB));
privateHolidays = import <secrets/home-assistant/holidays>;
# for example :
# holidays = lib.flatten [
# (holiday-range "2020-06" 7 24)
# (holiday-range "2020-10" 10 16)
#];
holidays = lib.flatten (privateHolidays holiday-range);
in {
services.homeAssistantConfig = { services.homeAssistantConfig = {
# todo: add holidays package to home-assiatnt
binary_sensor = [ binary_sensor = [
{ {
name = "before_workday"; name = "before_workday";
@ -10,6 +22,7 @@
province = "NW"; province = "NW";
workdays = [ "mon" "tue" "wed" "thu" "fri" ]; workdays = [ "mon" "tue" "wed" "thu" "fri" ];
days_offset = 1; days_offset = 1;
add_holidays = holidays;
} }
{ {
name = "workday"; name = "workday";
@ -17,6 +30,7 @@
country = "DE"; country = "DE";
province = "NW"; province = "NW";
workdays = [ "mon" "tue" "wed" "thu" "fri" ]; workdays = [ "mon" "tue" "wed" "thu" "fri" ];
add_holidays = holidays;
} }
]; ];