summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/ham/automation
diff options
context:
space:
mode:
Diffstat (limited to 'makefu/2configs/ham/automation')
-rw-r--r--makefu/2configs/ham/automation/firetv_restart.nix37
-rw-r--r--makefu/2configs/ham/automation/giesskanne.nix102
-rw-r--r--makefu/2configs/ham/automation/light_buttons.nix44
-rw-r--r--makefu/2configs/ham/automation/moodlight.nix46
-rw-r--r--makefu/2configs/ham/automation/urlaub.nix44
-rw-r--r--makefu/2configs/ham/automation/wohnzimmer_rf_fernbedienung.nix135
6 files changed, 0 insertions, 408 deletions
diff --git a/makefu/2configs/ham/automation/firetv_restart.nix b/makefu/2configs/ham/automation/firetv_restart.nix
deleted file mode 100644
index 12e0e845a..000000000
--- a/makefu/2configs/ham/automation/firetv_restart.nix
+++ /dev/null
@@ -1,37 +0,0 @@
-let
- cmd = command: {
- service = "androidtv.adb_command";
- data = {
- entity_id = "media_player.firetv_stick";
- inherit command;
- };
- };
- sec = seconds: { delay.seconds = seconds; };
-in
-{
- services.home-assistant.config.automation =
- [
- {
- alias = "Nightly reboot of firetv";
- trigger = {
- platform = "time";
- at = "03:00:00";
- };
- action = [
- (cmd "reboot")
- (sec 90) # go to my music because apparently select_source does not seem to always work
- (cmd "HOME")
- (sec 2)
- (cmd "DOWN")
- (sec 2)
- (cmd "DOWN")
- (sec 2)
- (cmd "ENTER")
- (sec 4)
- (cmd "RIGHT")
- (sec 2)
- (cmd "RIGHT")
- ];
- }
- ];
-}
diff --git a/makefu/2configs/ham/automation/giesskanne.nix b/makefu/2configs/ham/automation/giesskanne.nix
deleted file mode 100644
index 4b0fb61dd..000000000
--- a/makefu/2configs/ham/automation/giesskanne.nix
+++ /dev/null
@@ -1,102 +0,0 @@
-# uses:
-# switch.crafting_giesskanne_relay
-let
- cam = {
- name = "chilicam";
- camera = "camera.espcam_02";
- light = "light.espcam_02_light";
- seconds = 60; # default shutoff to protect the LED from burning out
- };
- seconds = 60;
- pump = "switch.arbeitszimmer_giesskanne_relay";
- # 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
- { alias = "Water the plant for ${toString seconds} seconds";
- trigger = [
- { # trigger at 23:15 no matter what
- # TODO: retry or run only if switch.wasser is available
- platform = "time";
- at = "23:15:00";
- }
- ];
- action =
- [
- { # take a snapshot before watering
- service = "homeassistant.turn_on";
- entity_id = [ cam.light ];
- }
- { # 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";
- };
- }
-
- { # 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";
- entity_id = [ pump ];
- }
- { delay.seconds = seconds; }
- {
- service = "homeassistant.turn_off";
- entity_id = [ pump cam.light ];
- }
- ];
- }
- { alias = "Always turn off the light after ${toString (cam.seconds)}s";
- trigger = [
- {
- platform = "state";
- entity_id = cam.light;
- to = "on";
- for.seconds = cam.seconds;
- }
- ];
- action =
- [
- {
- service = "homeassistant.turn_off";
- entity_id = [ pump cam.light ];
- }
- ];
- }
-
- { 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";
- entity_id = [ pump cam.light ];
- }
- ];
- }
- ];
- };
-}
diff --git a/makefu/2configs/ham/automation/light_buttons.nix b/makefu/2configs/ham/automation/light_buttons.nix
deleted file mode 100644
index 32d134ecc..000000000
--- a/makefu/2configs/ham/automation/light_buttons.nix
+++ /dev/null
@@ -1,44 +0,0 @@
-# light.wohnzimmerbeleuchtung
-# light.wohnzimmer_deko
-# light.arbeitszimmerbeleuchtung
-# light.arbeitszimmer_deko
-# light.schlafzimmerbeleuchtung
-
-let
- toggle = light: btn:
- {
- alias = "Toggle Light ${light} via ${btn}";
- trigger = {
- platform = "state";
- entity_id = "sensor.${btn}_click";
- to = "single";
- };
- action = {
- service = "light.toggle";
- data.entity_id = light;
- data.transition = 0;
- };
- };
- turn_off_all = btn:
- {
- alias = "Turn of all lights via ${btn} double click";
- trigger = {
- platform = "state";
- entity_id = "sensor.${btn}_click";
- to = "double";
- };
- action = {
- service = "light.turn_off";
- entity_id = "all";
- };
- };
-in {
- services.home-assistant.config.automation = [
- (toggle "light.arbeitszimmerbeleuchtung" "arbeitszimmer_btn1")
- (toggle "light.schlafzimmerbeleuchtung" "schlafzimmer_btn2")
- (toggle "light.wohnzimmerbeleuchtung" "wohnzimmer_btn3")
- (turn_off_all "arbeitszimmer_btn1")
- (turn_off_all "schlafzimmer_btn2")
- (turn_off_all "wohnzimmer_btn3")
- ];
-}
diff --git a/makefu/2configs/ham/automation/moodlight.nix b/makefu/2configs/ham/automation/moodlight.nix
deleted file mode 100644
index d0e336851..000000000
--- a/makefu/2configs/ham/automation/moodlight.nix
+++ /dev/null
@@ -1,46 +0,0 @@
-# uses:
-
-let
- wohnzimmer = "light.wohnzimmer_fenster_lichterkette_licht";
- arbeitszimmer = "light.box_led_status";
- final_off = "01:00";
-
- turn_on = entity_id: at: extra:
- { alias = "Turn on ${entity_id} at ${at}";
- trigger = [
- { platform = "time"; inherit at; }
- ];
- action =
- [
- ({ service = "light.turn_on";
- data = {
- inherit entity_id;
-
- } // extra;
- })
- ];
- };
-in
-{
- services.home-assistant.config =
- {
- automation =
- [
- # (turn_on wohnzimmer "17:30")
- (turn_on arbeitszimmer "9:00" { effect = "Slow Random Twinkle";})
-
- { alias = "Always turn off the lights at ${final_off}";
- trigger = [
- { platform = "time"; at = final_off; }
- ];
- action =
- [
- {
- service = "light.turn_off";
- entity_id = [ wohnzimmer arbeitszimmer];
- }
- ];
- }
- ];
- };
-}
diff --git a/makefu/2configs/ham/automation/urlaub.nix b/makefu/2configs/ham/automation/urlaub.nix
deleted file mode 100644
index a6b9be96f..000000000
--- a/makefu/2configs/ham/automation/urlaub.nix
+++ /dev/null
@@ -1,44 +0,0 @@
-# uses:
-# light.wohnzimmer_schrank_osram
-# light.wohnzimmer_fernseher_led_strip
-# "all" lights
-
-let
- schranklicht = "light.wohnzimmer_schrank_osram";
- fernsehlicht = "light.wohnzimmer_fernseher_led_strip";
- final_off = "01:00";
-
- turn_on = entity_id: at:
- { alias = "Turn on ${entity_id} at ${at}";
- trigger = [
- { platform = "time"; inherit at; }
- ];
- action =
- [
- { service = "light.turn_on"; inherit entity_id; }
- ];
- };
-in
-{
- services.home-assistant.config =
- {
- automation =
- [
- (turn_on schranklicht "17:30")
- (turn_on fernsehlicht "19:00")
-
- { alias = "Always turn off the urlaub lights at ${final_off}";
- trigger = [
- { platform = "time"; at = final_off; }
- ];
- action =
- [
- {
- service = "light.turn_off";
- entity_id = [ schranklicht fernsehlicht ];
- }
- ];
- }
- ];
- };
-}
diff --git a/makefu/2configs/ham/automation/wohnzimmer_rf_fernbedienung.nix b/makefu/2configs/ham/automation/wohnzimmer_rf_fernbedienung.nix
deleted file mode 100644
index 4303cdfa5..000000000
--- a/makefu/2configs/ham/automation/wohnzimmer_rf_fernbedienung.nix
+++ /dev/null
@@ -1,135 +0,0 @@
-# This module maps the RF433 Remote Control to zigbee and wifi lights
-let
- rf_turn_off = code: light:
- {
- alias = "Turn off ${light} via rf code ${code}";
- trigger = {
- platform = "event";
- event_type = "esphome.rf_code_received";
- event_data.code = code;
- };
- action = {
- service = "light.turn_off";
- data.entity_id = light;
- };
- };
- rf_turn_on = code: light:
- {
- alias = "Turn on ${light} via rf code ${code}";
- trigger = {
- platform = "event";
- event_type = "esphome.rf_code_received";
- event_data.code = code;
- };
- action = {
- service = "light.turn_on";
- data.entity_id = light;
- };
- };
- rf_state = code: light: halfbright:
- let
- maxbright = 255;
- transition = 0.2; # seconds
- in
- # this function implements a simple state machine based on the state and brightness of the light (light must support brightness
- {
- alias = "Cycle through states of ${light} via rf code ${code}";
- trigger = {
- platform = "event";
- event_type = "esphome.rf_code_received";
- event_data.code = code;
- };
- action = {
- choose = [
- {
- # state 0: off to half
- conditions = {
- condition = "template";
- value_template = ''{{ states("${light}") == "off" }}'';
- };
- sequence = [
- {
- service = "light.turn_on";
- data = {
- entity_id = light;
- brightness = halfbright;
- };
- }
- ];
- }
- {
- # state 1: half to full
- conditions = {
- condition = "template";
- value_template = ''{{ states('${light}') == 'on' and ( ${toString (halfbright - 1)} <= state_attr("${light}","brightness") <= ${toString (halfbright + 1)})}}'';
- };
- sequence = [
- {
- service = "light.turn_on";
- data = {
- entity_id = light;
- brightness = maxbright;
- };
- }
- ];
- }
- {
- # state 2: full to off
- conditions = {
- condition = "template";
- # TODO: it seems like the devices respond with brightness-1 , maybe off-by-one somewhere?
- value_template = ''{{ states("${light}") == "on" and state_attr("${light}","brightness") >= ${toString (maxbright - 1)}}}'';
- };
- sequence = [
- {
- service = "light.turn_off";
- data = {
- entity_id = light;
- };
- }
- ];
- }
- ];
- # default: on to off
- # this works because state 0 checks for "state == off"
- default = [{
- service = "light.turn_off";
- data = {
- entity_id = light;
- };
- }];
- };
- }
-;
- rf_toggle = code: light:
- {
- alias = "Toggle ${light} via rf code ${code}";
- trigger = {
- platform = "event";
- event_type = "esphome.rf_code_received";
- event_data.code = code;
- };
- action = {
- service = "light.toggle";
- data.entity_id = light;
- };
- };
-in
-{
- services.home-assistant.config.automation = [
- (rf_toggle "400551" "light.wohnzimmer_fernseher_led_strip") # A
- (rf_state "401151" "light.wohnzimmer_stehlampe_osram" 128) # B
- (rf_state "401451" "light.wohnzimmer_komode_osram" 128) # C
- (rf_state "401511" "light.wohnzimmer_schrank_osram" 128) # D
-
- # OFF Lane
- (rf_turn_off "400554" "all") # A
- (rf_toggle "401154" "light.wohnzimmer_fenster_lichterkette_licht") # B
- (rf_toggle "401454" "light.wohnzimmer_fernsehwand_led") # C
- # (rf_toggle "401514" "") # D
- ];
- # "400554" # A OFF
- # "401154" # B OFF
- # "401454" # C OFF
- # "401514" # D OFF
-}