2020-12-30 10:02:21 +00:00
|
|
|
# uses:
|
|
|
|
# switch.crafting_giesskanne_relay
|
|
|
|
let
|
|
|
|
cam = {
|
|
|
|
name = "chilicam";
|
|
|
|
camera = "camera.espcam_02";
|
|
|
|
light = "light.espcam_02_light";
|
2021-05-15 11:13:13 +00:00
|
|
|
seconds = 90; # default shutoff to protect the LED from burning out
|
2020-12-30 10:02:21 +00:00
|
|
|
};
|
2022-06-06 19:07:52 +00:00
|
|
|
seconds = 60*5; # time for giesskanne - 5 minutes
|
2020-12-30 10:02:21 +00:00
|
|
|
pump = "switch.arbeitszimmer_giesskanne_relay";
|
2022-06-06 19:07:52 +00:00
|
|
|
light = "switch.terrasse_plug_relay";
|
|
|
|
|
2020-12-30 10:02:21 +00:00
|
|
|
# sensor = "sensor.statistics_for_sensor_crafting_brotbox_soil_moisture";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
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" ];
|
|
|
|
|
|
|
|
automation =
|
|
|
|
[
|
|
|
|
|
|
|
|
##### brotbox
|
2022-06-06 19:07:52 +00:00
|
|
|
{ alias = "Water the plant for ${toString seconds} seconds and turn on the light";
|
2020-12-30 10:02:21 +00:00
|
|
|
trigger = [
|
|
|
|
{ # trigger at 23:15 no matter what
|
|
|
|
# TODO: retry or run only if switch.wasser is available
|
2022-06-06 19:07:52 +00:00
|
|
|
platform = "sun";
|
|
|
|
event = "sunrise";
|
2020-12-30 10:02:21 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
action =
|
|
|
|
[
|
|
|
|
|
|
|
|
{ # now turn on the pumping services
|
|
|
|
# i do not start hte pump and light before the snapshot because i do
|
|
|
|
# not know how long it takes (do not want to water the plants for too long)
|
|
|
|
service = "homeassistant.turn_on";
|
2022-06-06 19:07:52 +00:00
|
|
|
entity_id = [ pump light ];
|
2020-12-30 10:02:21 +00:00
|
|
|
}
|
|
|
|
{ delay.seconds = seconds; }
|
|
|
|
{
|
|
|
|
service = "homeassistant.turn_off";
|
|
|
|
entity_id = [ pump cam.light ];
|
|
|
|
}
|
2022-06-06 19:07:52 +00:00
|
|
|
{ # TODO: we could also create a recording with camera.record
|
|
|
|
service = "camera.snapshot";
|
|
|
|
data = {
|
|
|
|
entity_id = cam.camera;
|
|
|
|
# TODO: create /var/lib/hass/cam/ - now being done manually
|
|
|
|
filename = "/var/lib/hass/cam/${cam.name}_{{ now().strftime('%Y%m%d-%H%M%S') }}.jpg";
|
|
|
|
};
|
|
|
|
}
|
2020-12-30 10:02:21 +00:00
|
|
|
];
|
|
|
|
}
|
2022-06-06 19:07:52 +00:00
|
|
|
{ alias = "Turn off the light at sunset";
|
2020-12-30 10:02:21 +00:00
|
|
|
trigger = [
|
|
|
|
{
|
2022-06-06 19:07:52 +00:00
|
|
|
platform = "sun";
|
|
|
|
event = "sunset";
|
|
|
|
# offset = "+02:00:00";
|
2020-12-30 10:02:21 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
action =
|
|
|
|
[
|
|
|
|
{
|
|
|
|
service = "homeassistant.turn_off";
|
2022-06-06 19:07:52 +00:00
|
|
|
entity_id = [ light ];
|
2020-12-30 10:02:21 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
{ alias = "Always turn off water after ${toString (seconds * 2)}s";
|
|
|
|
trigger = [
|
|
|
|
{
|
|
|
|
platform = "state";
|
|
|
|
entity_id = pump;
|
|
|
|
to = "on";
|
|
|
|
for.seconds = seconds*2;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
action =
|
|
|
|
[
|
|
|
|
{
|
|
|
|
service = "homeassistant.turn_off";
|
2022-06-06 19:07:52 +00:00
|
|
|
entity_id = [ pump ];
|
2020-12-30 10:02:21 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|