2020-07-28 21:59:32 +00:00
|
|
|
# uses:
|
|
|
|
# switch.crafting_giesskanne_relay
|
2019-09-05 23:07:20 +00:00
|
|
|
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";
|
2020-09-28 08:18:12 +00:00
|
|
|
brotbox = {
|
|
|
|
minutes = 10;
|
|
|
|
pump = "switch.crafting_brotbox_pumpe";
|
|
|
|
sensor = "sensor.statistics_for_sensor_crafting_brotbox_soil_moisture";
|
|
|
|
};
|
2019-09-05 23:07:20 +00:00
|
|
|
in
|
|
|
|
{
|
2020-12-01 22:20:31 +00:00
|
|
|
services.home-assistant.config =
|
|
|
|
{
|
|
|
|
sensor = map ( entity_id: {
|
|
|
|
platform = "statistics";
|
|
|
|
name = "Statistics for ${entity_id}";
|
|
|
|
inherit entity_id;
|
|
|
|
max_age.minutes = "60";
|
|
|
|
sampling_size = 1000;
|
|
|
|
}) ["sensor.crafting_brotbox_soil_moisture"];
|
2020-09-16 20:21:53 +00:00
|
|
|
|
2020-01-07 15:52:31 +00:00
|
|
|
|
2020-12-01 22:20:31 +00:00
|
|
|
automation =
|
|
|
|
[
|
|
|
|
### Brotbox #####
|
|
|
|
#{ alias = "Brotbox: water for ${toString brotbox.minutes} minutes every hour";
|
|
|
|
# trigger =
|
|
|
|
# { # Trigger once every hour at :42
|
|
|
|
# platform = "time_pattern";
|
|
|
|
# minutes = 42;
|
|
|
|
# };
|
|
|
|
# condition = {
|
|
|
|
# condition = "numeric_state";
|
|
|
|
# entity_id = brotbox.sensor;
|
|
|
|
# value_template = "{{ state_attr('${brotbox.sensor}', 'median') }}";
|
|
|
|
# below = 75;
|
|
|
|
# };
|
|
|
|
# action =
|
|
|
|
# [
|
|
|
|
# {
|
|
|
|
# service = "homeassistant.turn_on";
|
|
|
|
# entity_id = brotbox.pump;
|
|
|
|
# }
|
|
|
|
# { delay.minutes = brotbox.minutes; }
|
|
|
|
# {
|
|
|
|
# service = "homeassistant.turn_off";
|
|
|
|
# entity_id = brotbox.pump ;
|
|
|
|
# }
|
|
|
|
# ];
|
|
|
|
#}
|
|
|
|
{ alias = "Brotbox: Always turn off water after ${toString (brotbox.minutes * 2)} minutes";
|
|
|
|
trigger =
|
2019-09-05 23:07:20 +00:00
|
|
|
{
|
|
|
|
platform = "state";
|
2020-12-01 22:20:31 +00:00
|
|
|
entity_id = brotbox.pump;
|
2019-09-05 23:07:20 +00:00
|
|
|
to = "on";
|
2020-12-01 22:20:31 +00:00
|
|
|
for.minutes = brotbox.minutes*2;
|
|
|
|
};
|
|
|
|
action =
|
2019-09-05 23:07:20 +00:00
|
|
|
{
|
|
|
|
service = "homeassistant.turn_off";
|
2020-12-01 22:20:31 +00:00
|
|
|
entity_id = brotbox.pump;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
##### Kaffeemaschine
|
|
|
|
{ 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 = [
|
|
|
|
wasser
|
|
|
|
];
|
|
|
|
}
|
|
|
|
{ delay.seconds = seconds; }
|
|
|
|
{
|
|
|
|
service = "homeassistant.turn_off";
|
|
|
|
entity_id = [
|
|
|
|
wasser
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
{ alias = "Always turn off water after ${toString (seconds * 2)}seconds";
|
|
|
|
trigger = [
|
|
|
|
{
|
|
|
|
platform = "state";
|
|
|
|
entity_id = wasser;
|
|
|
|
to = "on";
|
|
|
|
for.seconds = seconds*2;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
action =
|
|
|
|
[
|
|
|
|
{
|
|
|
|
service = "homeassistant.turn_off";
|
|
|
|
entity_id = [ wasser ];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2019-09-05 23:07:20 +00:00
|
|
|
}
|