summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/home/ham
diff options
context:
space:
mode:
Diffstat (limited to 'makefu/2configs/home/ham')
-rw-r--r--makefu/2configs/home/ham/automation/check-in.nix13
-rw-r--r--makefu/2configs/home/ham/automation/flurlicht.nix85
-rw-r--r--makefu/2configs/home/ham/automation/giesskanne.nix45
-rw-r--r--makefu/2configs/home/ham/automation/urlaub.nix26
-rw-r--r--makefu/2configs/home/ham/default.nix17
-rw-r--r--makefu/2configs/home/ham/light/tint_wohnzimmer.nix15
-rw-r--r--makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix107
-rw-r--r--makefu/2configs/home/ham/media/sonos.nix1
-rw-r--r--makefu/2configs/home/ham/person/default.nix20
9 files changed, 240 insertions, 89 deletions
diff --git a/makefu/2configs/home/ham/automation/check-in.nix b/makefu/2configs/home/ham/automation/check-in.nix
index 21040b409..3a7ebe9ac 100644
--- a/makefu/2configs/home/ham/automation/check-in.nix
+++ b/makefu/2configs/home/ham/automation/check-in.nix
@@ -3,7 +3,7 @@ let
light = "light.arbeitszimmer_onebutton_led";
at_work = "input_boolean.felix_at_work";
lib = import ../lib;
- say = lib.say.living_room;
+ say = lib.say.office;
in
{
services.home-assistant.config.input_boolean.felix_at_work.name = "Felix auf Arbeit";
@@ -37,7 +37,16 @@ in
{ service = "homeassistant.turn_on";
entity_id = at_work;
}
- ] ++ (say "Willkommen auf Arbeit");
+ ] ++ (say "Willkommen auf Arbeit") ++
+ [
+ { service = "media_player.play_media";
+ data = {
+ media_content_id = "https://radio.lassul.us/radio.mp3";
+ media_content_type = "music";
+ };
+ target.entity_id = "media_player.office";
+ }
+ ];
}
{
conditions = {
diff --git a/makefu/2configs/home/ham/automation/flurlicht.nix b/makefu/2configs/home/ham/automation/flurlicht.nix
index c26f7e3e0..aa62ab9e4 100644
--- a/makefu/2configs/home/ham/automation/flurlicht.nix
+++ b/makefu/2configs/home/ham/automation/flurlicht.nix
@@ -1,56 +1,57 @@
let
- licht = [ "light.flur_statuslight" "light.wohnzimmer_status_led" ];
- kehrwoche_color = [ 204 0 255 ]; # pink
- nachtlicht_color = [ 255 190 0 ]; # ein dunkles rot
+ nachtlicht = [ "light.flur_statuslight" "light.wohnzimmer_status_led" ];
+
+ # flurlicht an
+ lightcond = name: conditions: rgb_color: brightness:
+ {
+ inherit conditions;
+ sequence = {
+ service = "light.turn_on";
+ target.entity_id = nachtlicht;
+ data = {
+ inherit rgb_color brightness;
+ };
+ };
+ };
in
{
services.home-assistant.config.automation =
[
- { alias = "Nachtlicht im Flur an";
- trigger = {
- platform = "sun";
- event = "sunset";
- };
- action =
- [
- {
- service = "light.turn_on";
- target.entity_id = licht;
- data = {
- brightness = 87;
- rgb_color = nachtlicht_color;
- #effect = "None";
- };
+ { alias = "Nachtlicht trigger";
+ trigger = [
+ { platform = "sun"; event = "sunset"; }
+ { platform = "sun"; event = "sunrise"; }
+ { platform = "state"; entity_id = [
+ "calendar.kehrwoche_kehrwoche"
+ "binary_sensor.badezimmer_fenster_contact"
+ "binary_sensor.dusche_fenster_contact"
+ ];
}
];
- }
- { alias = "Nachtlicht in Flur aus, Kehrwoche an";
- trigger = {
- platform = "sun";
- event = "sunrise";
- };
action =
[
{ choose = [
- {
- conditions = {
- condition = "state";
- entity_id = "calendar.kehrwoche_kehrwoche";
- state = "on";
- };
- sequence = {
- service = "light.turn_on";
- target.entity_id = licht;
- data = {
- brightness = 190;
- rgb_color = kehrwoche_color; # pink
- };
- };
- }];
+ (lightcond "Badezimmer Fenster Auf"
+ { condition = "state"; entity_id = "binary_sensor.badezimmer_fenster_contact"; state = "on"; }
+ [ 64 207 255 ] 255 # helblau
+ )
+ (lightcond "Duschenster auf"
+ { condition = "state"; entity_id = "binary_sensor.dusche_fenster_contact"; state = "on"; }
+ [ 64 207 255 ] 255 # helblau
+ )
+ (lightcond "Nachtlicht"
+ { condition = "state"; entity_id = "sun.sun"; state = "below_horizon"; }
+ [ 255 190 0 ] 90 # red
+ )
+ (lightcond "Kehrwoche"
+ { condition = "state"; entity_id = "calendar.kehrwoche_kehrwoche"; state = "on"; }
+ [ 204 0 255 ] 128 # pink
+ )
+ ];
default = {
- service = "light.turn_off";
- entity_id = licht;
- };
+ service = "light.turn_off";
+ entity_id = nachtlicht;
+ };
}
];
}
diff --git a/makefu/2configs/home/ham/automation/giesskanne.nix b/makefu/2configs/home/ham/automation/giesskanne.nix
index b11fd9d52..400e553e8 100644
--- a/makefu/2configs/home/ham/automation/giesskanne.nix
+++ b/makefu/2configs/home/ham/automation/giesskanne.nix
@@ -7,8 +7,10 @@ let
light = "light.espcam_02_light";
seconds = 90; # default shutoff to protect the LED from burning out
};
- seconds = 70; # time for giesskanne
+ seconds = 60*5; # time for giesskanne - 5 minutes
pump = "switch.arbeitszimmer_giesskanne_relay";
+ light = "switch.terrasse_plug_relay";
+
# sensor = "sensor.statistics_for_sensor_crafting_brotbox_soil_moisture";
in
{
@@ -26,56 +28,51 @@ in
[
##### brotbox
- { alias = "Water the plant for ${toString seconds} seconds";
+ { alias = "Water the plant for ${toString seconds} seconds and turn on the light";
trigger = [
{ # trigger at 23:15 no matter what
# TODO: retry or run only if switch.wasser is available
- platform = "time";
- at = "23:15:00";
+ platform = "sun";
+ event = "sunrise";
}
];
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 ];
+ entity_id = [ pump light ];
}
{ delay.seconds = seconds; }
{
service = "homeassistant.turn_off";
entity_id = [ pump 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";
+ };
+ }
];
}
- { alias = "Always turn off the light after ${toString (cam.seconds)}s";
+ { alias = "Turn off the light at sunset";
trigger = [
{
- platform = "state";
- entity_id = cam.light;
- to = "on";
- for.seconds = cam.seconds;
+ platform = "sun";
+ event = "sunset";
+ # offset = "+02:00:00";
}
];
action =
[
{
service = "homeassistant.turn_off";
- entity_id = [ pump cam.light ];
+ entity_id = [ light ];
}
];
}
@@ -93,7 +90,7 @@ in
[
{
service = "homeassistant.turn_off";
- entity_id = [ pump cam.light ];
+ entity_id = [ pump ];
}
];
}
diff --git a/makefu/2configs/home/ham/automation/urlaub.nix b/makefu/2configs/home/ham/automation/urlaub.nix
index 50294514c..c11c589cf 100644
--- a/makefu/2configs/home/ham/automation/urlaub.nix
+++ b/makefu/2configs/home/ham/automation/urlaub.nix
@@ -7,12 +7,26 @@ let
schranklicht = "light.wohnzimmer_schrank_osram";
weihnachtslicht = "light.wohnzimmer_fenster_lichterkette_licht";
fernsehlicht = "light.wled";
+
+ all_lights = [
+ schranklicht weihnachtslicht fernsehlicht
+ # extra lights to also turn off
+ # wohnzimmer
+ "light.wohnzimmer_komode_osram"
+ "light.wohnzimmer_stehlampe_osram"
+ # arbeitszimmer
+ "light.wled_4"
+ "light.arbeitszimmer_schrank_dimmer"
+ "light.arbeitszimmer_pflanzenlicht"
+ ];
+
final_off = "00:37";
- turn_on = entity_id: at:
- { alias = "Turn on ${entity_id} at ${at}";
+ turn_on = entity_id: offset:
+ # negative offset => before sunset
+ { alias = "Turn on ${entity_id} at sunset ${offset}";
trigger = [
- { platform = "time"; inherit at; }
+ { platform = "sun"; event = "sunset"; inherit offset; }
];
action =
[
@@ -25,9 +39,9 @@ in
{
automation =
[
- (turn_on schranklicht "17:30")
- (turn_on weihnachtslicht "17:30")
- (turn_on fernsehlicht "19:00")
+ (turn_on schranklicht "-00:30:00")
+ #(turn_on weihnachtslicht "-00:30:00")
+ (turn_on fernsehlicht "-00:00:00")
{ alias = "Always turn off the urlaub lights at ${final_off}";
trigger = [
diff --git a/makefu/2configs/home/ham/default.nix b/makefu/2configs/home/ham/default.nix
index b9701f129..31e7ba419 100644
--- a/makefu/2configs/home/ham/default.nix
+++ b/makefu/2configs/home/ham/default.nix
@@ -31,15 +31,16 @@ in {
./media/firetv.nix
./media/sonos.nix
./media/remote_sound_wohnzimmer.nix
+ ./media/remote_sound_arbeitszimmer.nix
./automation/check-in.nix
./automation/fenster_auf.nix
./automation/firetv_restart.nix
./automation/light_buttons.nix
./automation/wohnzimmer_rf_fernbedienung.nix
- ./automation/ladestecker_timer.nix
+ # ./automation/ladestecker_timer.nix
./automation/flurlicht.nix
- #./automation/giesskanne.nix
+ ./automation/giesskanne.nix
./automation/pflanzen_giessen_erinnerung.nix
./automation/urlaub.nix
./automation/moodlight.nix
@@ -59,7 +60,7 @@ in {
extraPackages = p: [
(p.callPackage ./deps/dwdwfsapi.nix {})
(p.callPackage ./signal-rest/pkg.nix {})
- #(p.callPackage ./deps/pykodi.nix {})
+ (p.callPackage ./deps/pykodi.nix {})
];
};
@@ -141,11 +142,11 @@ in {
retain = true;
};
};
- luftdaten = {
- show_on_map = true;
- sensor_id = 10529;
- sensors.monitored_conditions = [ "P1" "P2" ];
- };
+ #luftdaten = {
+ # show_on_map = true;
+ # sensor_id = 10529;
+ # sensors.monitored_conditions = [ "P1" "P2" ];
+ #};
#binary_sensor =
# flurlicht.binary_sensor;
diff --git a/makefu/2configs/home/ham/light/tint_wohnzimmer.nix b/makefu/2configs/home/ham/light/tint_wohnzimmer.nix
index fd87cf064..474bf5c99 100644
--- a/makefu/2configs/home/ham/light/tint_wohnzimmer.nix
+++ b/makefu/2configs/home/ham/light/tint_wohnzimmer.nix
@@ -25,19 +25,20 @@ let
default_scene_1 = "Solid";
default_color_1 = "Default";
main_color_select_1 = "select.wled_color_palette";
- light_group_1.entity_id = [
- main_light_1
- ];
+ light_group_1.entity_id = [
+ main_light_1
+ ];
# contains only the actually changeable lights
- light_group_2.entity_id = [
+ light_group_2 = { entity_id = [
"light.wohnzimmer_komode_osram"
"light.wohnzimmer_schrank_osram"
"light.wohnzimmer_fenster_lichterkette_licht"
- ];
- light_group_3.entity_id = [
+ ];
+ };
+ light_group_3 = { entity_id = [
"light.wohnzimmer_stehlampe_osram"
- ];
+ ]; };
statecond = cond: { # cond must be a list
condition = "template";
diff --git a/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix b/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix
new file mode 100644
index 000000000..f59f022f4
--- /dev/null
+++ b/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix
@@ -0,0 +1,107 @@
+{ lib, ...}:
+let
+ statecond = cond: { # cond must be a list
+ condition = "template";
+ value_template = "{{ trigger.to_state.state in ( " +
+ (lib.concatMapStringsSep "," (x: "'${x}'") cond) + ") }}";
+ };
+ vol_change = 0.030;
+
+ max_repeat = "30"; # max loops to repeat before bailing out
+ remote = "sensor.arbeitszimmer_sound1_action";
+ player = "media_player.office";
+ last_state_sensor_name = "last_rotation_action_arbeitszimmer";
+ last_state_sensor = "input_text.${last_state_sensor_name}";
+ # - service: media_player.volume_set
+ # target:
+ # entity_id: media_player.kitchen
+ # data:
+ # volume_level: {{ state_attr('media_player.kitchen', 'volume_level') + 0.02 }}
+ rotate_stop = "brightness_stop";
+ rotate_right = "brightness_move_up";
+ rotate_left = "brightness_move_down" ;
+
+ single_click = "toggle";
+ double_click = "brightness_step_up";
+ triple_click = "brightness_step_down";
+in {
+ services.home-assistant.config.input_text."${last_state_sensor_name}".name = "Last action of the arbeitszimmer";
+ services.home-assistant.config.automation = [
+ {
+ trigger = {
+ platform = "state";
+ entity_id = remote;
+ to = [ rotate_stop ];
+ };
+ action = [
+ { service = "input_text.set_value";
+ target.entity_id = last_state_sensor;
+ data.value = "stop";
+ }
+ ];
+ }
+ {
+ alias = "Perform Actions with ${remote}";
+ trigger = {
+ platform = "state";
+ entity_id = remote;
+ to = [ single_click double_click triple_click rotate_left rotate_right ];
+ };
+ #mode = "queued";
+ #max = 5;
+ mode = "single";
+ #max_exceeded = "silent";
+ action = [
+ {
+ choose = [
+ {
+ conditions = statecond [ single_click ];
+ sequence = [
+ { service = "media_player.media_play_pause";
+ target.entity_id = player;
+ }
+ ];
+ }
+ {
+ conditions = statecond [ rotate_left rotate_right ];
+ sequence = let
+ vol_up = toString vol_change;
+ vol_down = toString (-1 * vol_change);
+ in [
+ {
+ variables.nextvol = ''{% if trigger.to_state.state in ( "${rotate_left}" ) -%} ${vol_down} {% else -%} ${vol_up} {% endif -%}'';
+ variables.state = ''{% if trigger.to_state.state in ( "${rotate_left}" ) -%} left {% else -%} right {% endif -%}'';
+ }
+ { service = "input_text.set_value";
+ target.entity_id = last_state_sensor;
+ data.value = ''{{ state }}'';
+ }
+ {
+ repeat = {
+ sequence = [
+ { service = "media_player.volume_set";
+ target.entity_id = player;
+ data.volume_level = ''{{ state_attr("${player}","volume_level") + (nextvol|float) }}'';
+ }
+ { delay.milliseconds = "150"; }
+ ];
+ while = [
+ {
+ condition = "template";
+ value_template = ''{{ states("${last_state_sensor}") == state }}'';
+ }
+ {
+ condition = "template";
+ value_template = "{{ repeat.index <= ${max_repeat}}}";
+ }
+ ];
+ };
+ }
+ ];
+ }
+ ];
+ }
+ ];
+ }
+ ];
+}
diff --git a/makefu/2configs/home/ham/media/sonos.nix b/makefu/2configs/home/ham/media/sonos.nix
index 5b9694512..40dcfc3ca 100644
--- a/makefu/2configs/home/ham/media/sonos.nix
+++ b/makefu/2configs/home/ham/media/sonos.nix
@@ -2,6 +2,7 @@
services.home-assistant.config.sonos.media_player.hosts = [
"192.168.111.30"
"192.168.111.31"
+ "192.168.111.32"
];
}
diff --git a/makefu/2configs/home/ham/person/default.nix b/makefu/2configs/home/ham/person/default.nix
new file mode 100644
index 000000000..a72f610e8
--- /dev/null
+++ b/makefu/2configs/home/ham/person/default.nix
@@ -0,0 +1,20 @@
+{config, ... }:
+{
+ services.home-assistant.config.person = [
+ {
+ name = "Felix";
+ id = 1;
+ device_trackers = [
+ "device_tracker.felix_phone"
+ "device_tracker.x"
+ ];
+ }
+ {
+ name = "Misa";
+ id = 2;
+ device_trackers = [
+ "device_tracker.misa_phone"
+ ];
+ }
+ ];
+}