nixos-config/configs/pepe/home-assistant/workday.nix

56 lines
1.3 KiB
Nix
Raw Normal View History

2020-06-11 18:08:14 +02:00
{ 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 {
2020-04-12 13:36:15 +02:00
services.homeAssistantConfig = {
binary_sensor = [
{
name = "before_workday";
platform = "workday";
country = "DE";
province = "NW";
workdays = [ "mon" "tue" "wed" "thu" "fri" ];
days_offset = 1;
2020-06-11 18:08:14 +02:00
add_holidays = holidays;
2020-04-12 13:36:15 +02:00
}
{
name = "workday";
platform = "workday";
country = "DE";
province = "NW";
workdays = [ "mon" "tue" "wed" "thu" "fri" ];
2020-06-11 18:08:14 +02:00
add_holidays = holidays;
2020-04-12 13:36:15 +02:00
}
];
homeassistant.customize = {
"binary_sensor.workday" = {
icon = "mdi:calendar";
2020-04-12 14:04:15 +02:00
friendly_name = "Workday?";
2020-04-12 13:36:15 +02:00
};
"binary_sensor.before_workday" = {
icon = "mdi:calendar";
2020-04-12 14:04:15 +02:00
friendly_name = "Workday Tomorrow?";
2020-04-12 13:36:15 +02:00
};
};
group = {
2020-04-12 14:04:15 +02:00
today.entities =
[ "binary_sensor.before_workday" "binary_sensor.workday" ];
2020-04-12 13:36:15 +02:00
};
};
}