2021-05-15 11:13:13 +00:00
|
|
|
{ lib, ... }:
|
|
|
|
#uses:
|
|
|
|
# notify.signal
|
|
|
|
# binary_sensor.badezimmer_fenster_contact
|
|
|
|
# binary_sensor.dusche_fenster_contact
|
2021-03-09 21:17:00 +00:00
|
|
|
let
|
2022-09-23 21:41:30 +00:00
|
|
|
hlib = import ../lib;
|
|
|
|
say = hlib.say.office;
|
|
|
|
draussen = "sensor.wohnzimmer_temp_temperature";
|
|
|
|
draussen_diff = "sensor.unterschied_draussen_drinnen";
|
|
|
|
draussen_heiss = 23;
|
2021-03-09 21:17:00 +00:00
|
|
|
min = 20;
|
|
|
|
fenster_offen = name: entity:
|
|
|
|
{ alias = "${name} seit ${toString min} Minuten offen";
|
|
|
|
trigger = [
|
|
|
|
{
|
|
|
|
platform = "state";
|
|
|
|
entity_id = entity;
|
|
|
|
to = "on";
|
|
|
|
for.minutes = min;
|
|
|
|
}
|
|
|
|
];
|
2021-08-27 20:45:16 +00:00
|
|
|
condition = [
|
|
|
|
];
|
2021-03-09 21:17:00 +00:00
|
|
|
action =
|
|
|
|
[
|
|
|
|
{
|
2021-05-15 11:13:13 +00:00
|
|
|
service = "notify.signal_home";
|
2021-06-06 11:18:24 +00:00
|
|
|
data_template = {
|
|
|
|
message = "${name} seit ${toString min} Minuten offen und draussen ist es gerade {{states.sensor.dark_sky_temperature.state}}°C bei {{states.sensor.dark_sky_humidity.state}}% Luftfeuchte";
|
2021-03-09 21:17:00 +00:00
|
|
|
};
|
|
|
|
}
|
2021-05-15 11:13:13 +00:00
|
|
|
{
|
|
|
|
service = "input_boolean.turn_on";
|
|
|
|
target.entity_id = "input_boolean.${lib.toLower name}_lang_offen";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
fenster_geschlossen_lang = name: entity:
|
|
|
|
{ alias = "${name} wieder geschlossen";
|
|
|
|
trigger = [
|
|
|
|
{
|
|
|
|
platform = "state";
|
|
|
|
entity_id = entity;
|
|
|
|
to = "off";
|
2021-05-25 07:52:28 +00:00
|
|
|
for.seconds = 10;
|
2021-05-15 11:13:13 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
condition = [
|
|
|
|
{ condition = "state";
|
|
|
|
entity_id = "input_boolean.${lib.toLower name}_lang_offen";
|
|
|
|
state = "on";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
action =
|
|
|
|
[
|
|
|
|
{
|
|
|
|
service = "notify.signal_home";
|
|
|
|
data = {
|
|
|
|
message= "${name} ist wieder geschlossen, Danke!";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
service = "input_boolean.turn_off";
|
|
|
|
target.entity_id = "input_boolean.${lib.toLower name}_lang_offen";
|
|
|
|
}
|
2021-03-09 21:17:00 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
in {
|
2021-05-15 11:13:13 +00:00
|
|
|
services.home-assistant.config = {
|
2022-09-23 21:41:30 +00:00
|
|
|
template = [
|
|
|
|
{ sensor = {
|
|
|
|
name = "Unterschied Draussen Drinnen";
|
|
|
|
unit_of_measurement = "°C";
|
|
|
|
state = ''
|
|
|
|
{% set inside = states("${draussen}") | float | round(2) -%}
|
|
|
|
{% set outside = states("sensor.dark_sky_temperature") | float | round(2) -%}
|
|
|
|
{{ ((outside - inside) | round(1) )}}'';
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
2021-08-27 20:45:16 +00:00
|
|
|
sensor = [
|
|
|
|
{ platform = "season"; type = "meteorological";}
|
|
|
|
];
|
|
|
|
|
2021-05-15 11:13:13 +00:00
|
|
|
input_boolean = {
|
2021-05-17 08:49:40 +00:00
|
|
|
badezimmerfenster_lang_offen.name = "Badezimmer lange offen";
|
2021-05-15 11:13:13 +00:00
|
|
|
duschfenster_lang_offen.name = "Duschfenster lange offen";
|
2021-08-27 20:45:16 +00:00
|
|
|
ist_sommer = {
|
|
|
|
name = "Es ist Sommer";
|
|
|
|
initial = true; # TODO
|
|
|
|
};
|
2021-05-15 11:13:13 +00:00
|
|
|
};
|
2021-08-27 20:45:16 +00:00
|
|
|
|
2021-05-15 11:13:13 +00:00
|
|
|
automation = [
|
|
|
|
(fenster_geschlossen_lang "Badezimmerfenster" "binary_sensor.badezimmer_fenster_contact")
|
2021-05-25 07:52:28 +00:00
|
|
|
(fenster_geschlossen_lang "Duschfenster" "binary_sensor.dusche_fenster_contact")
|
|
|
|
|
2021-05-15 11:13:13 +00:00
|
|
|
(fenster_offen "Badezimmerfenster" "binary_sensor.badezimmer_fenster_contact")
|
|
|
|
(fenster_offen "Duschfenster" "binary_sensor.dusche_fenster_contact")
|
2022-09-23 21:41:30 +00:00
|
|
|
|
|
|
|
{ alias = "Draussen ist wieder kaelter";
|
|
|
|
trigger = [
|
|
|
|
{
|
|
|
|
platform = "numeric_state";
|
|
|
|
entity_id = draussen_diff;
|
|
|
|
below = 0;
|
|
|
|
for.minutes = 20;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
condition = [
|
|
|
|
{ condition = "numeric_state";
|
|
|
|
entity_id = draussen;
|
|
|
|
above = draussen_heiss;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
action = (say "Draussen ist es endlich kühler, jetzt kann man die Fenster auf machen");
|
|
|
|
}
|
|
|
|
{ alias = "Draussen ist zu warm";
|
|
|
|
trigger = [
|
|
|
|
{
|
|
|
|
platform = "numeric_state";
|
|
|
|
entity_id = draussen_diff;
|
|
|
|
above = 0;
|
|
|
|
for.minutes = 20;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
condition = [
|
|
|
|
{ condition = "numeric_state";
|
|
|
|
entity_id = draussen;
|
|
|
|
above = draussen_heiss;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
action = (say "Draussen wird es jetzt zu warm, besser das fenster schliessen");
|
|
|
|
}
|
2021-05-15 11:13:13 +00:00
|
|
|
];
|
|
|
|
};
|
2021-03-09 21:17:00 +00:00
|
|
|
}
|