stockholm/krebs/2configs/shack/glados/multi/wasser.nix

63 lines
1.3 KiB
Nix
Raw Normal View History

2020-07-28 21:59:32 +00:00
# uses:
# switch.crafting_giesskanne_relay
let
2020-01-07 15:52:31 +00:00
glados = import ../lib;
2020-09-01 21:25:17 +00:00
seconds = 20;
2020-07-28 21:59:32 +00:00
wasser = "switch.crafting_giesskanne_relay";
in
{
2020-09-16 20:21:53 +00:00
sensor = map ( entity_id: {
platform = "statistics";
name = "Statistics for ${entity_id}";
inherit entity_id;
max_age.minutes = "60";
}) ["sensor.crafting_brotbox_soil_moisture"];
2020-01-07 15:52:31 +00:00
automation =
[
2019-09-19 19:31:21 +00:00
{ alias = "Water the plant for ${toString seconds} seconds";
trigger = [
{ # trigger at 20:00 no matter what
# TODO: retry or run only if switch.wasser is available
platform = "time";
at = "20:00:00";
}
];
action =
[
{
service = "homeassistant.turn_on";
entity_id = [
2020-07-28 21:59:32 +00:00
wasser
];
}
2019-09-19 19:31:21 +00:00
{ delay.seconds = seconds; }
{
service = "homeassistant.turn_off";
entity_id = [
2020-07-28 21:59:32 +00:00
wasser
];
}
];
}
2019-09-19 19:31:21 +00:00
{ alias = "Always turn off water after ${toString (seconds * 2)}seconds";
trigger = [
{
platform = "state";
2020-07-28 21:59:32 +00:00
entity_id = wasser;
to = "on";
2019-09-19 19:31:21 +00:00
for.seconds = seconds*2;
}
];
action =
[
{
service = "homeassistant.turn_off";
2020-07-28 21:59:32 +00:00
entity_id = [ wasser ];
}
];
}
];
}