From 0054694bdf4b317bac9a6dc5ff20f26a8b600776 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Thu, 11 Jun 2020 18:08:14 +0200 Subject: [PATCH] home-assistant: add holidays --- configs/pepe/home-assistant/workday.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/configs/pepe/home-assistant/workday.nix b/configs/pepe/home-assistant/workday.nix index 9424231..1ac918a 100644 --- a/configs/pepe/home-assistant/workday.nix +++ b/configs/pepe/home-assistant/workday.nix @@ -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 ; + # 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; } ];