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 = {
# todo: add holidays package to home-assiatnt
binary_sensor = [
{
name = "before_workday";
@ -10,6 +22,7 @@
province = "NW";
workdays = [ "mon" "tue" "wed" "thu" "fri" ];
days_offset = 1;
add_holidays = holidays;
}
{
name = "workday";
@ -17,6 +30,7 @@
country = "DE";
province = "NW";
workdays = [ "mon" "tue" "wed" "thu" "fri" ];
add_holidays = holidays;
}
];