home-assistant: add holidays
This commit is contained in:
parent
6cd2b63d35
commit
0054694bdf
1 changed files with 16 additions and 2 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue