nixos-config/nixos/machines/pepe/home-assistant/workday.nix
2022-09-20 21:48:36 +02:00

56 lines
1.3 KiB
Nix

{ 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 = {
binary_sensor = [
{
name = "before_workday";
platform = "workday";
country = "DE";
province = "NW";
workdays = [ "mon" "tue" "wed" "thu" "fri" ];
days_offset = 1;
add_holidays = holidays;
}
{
name = "workday";
platform = "workday";
country = "DE";
province = "NW";
workdays = [ "mon" "tue" "wed" "thu" "fri" ];
add_holidays = holidays;
}
];
homeassistant.customize = {
"binary_sensor.workday" = {
icon = "mdi:calendar";
friendly_name = "Workday?";
};
"binary_sensor.before_workday" = {
icon = "mdi:calendar";
friendly_name = "Workday Tomorrow?";
};
};
group = {
today.entities =
[ "binary_sensor.before_workday" "binary_sensor.workday" ];
};
};
}