summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/homeautomation
diff options
context:
space:
mode:
Diffstat (limited to 'makefu/2configs/homeautomation')
-rw-r--r--makefu/2configs/homeautomation/default.nix69
-rw-r--r--makefu/2configs/homeautomation/google-muell.nix16
2 files changed, 69 insertions, 16 deletions
diff --git a/makefu/2configs/homeautomation/default.nix b/makefu/2configs/homeautomation/default.nix
index 596d0002a..4e9ac0ee3 100644
--- a/makefu/2configs/homeautomation/default.nix
+++ b/makefu/2configs/homeautomation/default.nix
@@ -55,7 +55,8 @@ let
payload_not_available = "Offline";
};
- firetv = "192.168.1.238";
+ firetv = "192.168.1.183";
+ hassdir = "/var/lib/hass";
tasmota_plug = name: topic:
{ platform = "mqtt";
inherit name;
@@ -105,13 +106,7 @@ in {
imports = [
./mqtt.nix
];
- #systemd.services.firetv = {
- # wantedBy = [ "multi-user.target" ];
- # serviceConfig = {
- # User = "nobody";
- # ExecStart = "${pkgs.python-firetv}/bin/firetv-server -d ${firetv}:5555";
- # };
- #};
+
services.home-assistant = {
config = {
homeassistant = {
@@ -133,9 +128,11 @@ in {
{ platform = "kodi";
host = firetv;
}
- #{ platform = "firetv";
- # # assumes python-firetv running
- #}
+ { platform = "firetv";
+ name = "FireTV Stick";
+ host = firetv;
+ adbkey = <secrets/hass/adbkey>;
+ }
];
mqtt = {
broker = "localhost";
@@ -211,9 +208,12 @@ in {
flur = [
"light.flurlicht"
"binary_sensor.flur_bewegung"
+ "automation.dunkel_bei_sonnenuntergang"
+ "automation.hell_bei_sonnenaufgang"
];
wohnzimmer = [
"media_player.kodi"
+ "media_player.firetv_stick"
];
draussen = [
"sensor.dark_sky_temperature"
@@ -240,6 +240,47 @@ in {
];
light = [ (tasmota_rgb "Flurlicht" "flurlicht" ) ];
automation = [
+ { alias = "Dunkel bei Sonnenuntergang";
+ trigger = {
+ platform = "sun";
+ event = "sunset";
+ # offset: "-00:45:00"
+ };
+ action = [
+ {
+ service= "light.turn_on";
+ data = {
+ entity_id= "light.flurlicht";
+ # rgb_color = [ 0,0,0 ]; <-- TODO default color
+ brightness_pct = 15;
+ };
+ }
+ {
+ service= "light.turn_off";
+ entity_id= "light.flurlicht";
+ }
+ ];
+ }
+ { alias = "Hell bei Sonnenaufgang";
+ trigger = {
+ platform = "sun";
+ event = "sunrise";
+ # offset: "-00:00:00"
+ };
+ action = [
+ {
+ service= "light.turn_on";
+ data = {
+ entity_id= "light.flurlicht";
+ brightness_pct = 85;
+ };
+ }
+ {
+ service= "light.turn_off";
+ entity_id= "light.flurlicht";
+ }
+ ];
+ }
{ alias = "Staubsauger Strom aus nach 6h";
trigger = {
platform = "state";
@@ -255,6 +296,10 @@ in {
];
};
enable = true;
- #configDir = "/var/lib/hass";
+ configDir = hassdir;
};
+ nixpkgs.config.permittedInsecurePackages = [
+ "homeassistant-0.77.2"
+ ];
+
}
diff --git a/makefu/2configs/homeautomation/google-muell.nix b/makefu/2configs/homeautomation/google-muell.nix
index 235cc1546..c81eae201 100644
--- a/makefu/2configs/homeautomation/google-muell.nix
+++ b/makefu/2configs/homeautomation/google-muell.nix
@@ -3,13 +3,21 @@ with import <stockholm/lib>;
let
pkg = pkgs.ampel;
home = "/var/lib/ampel";
- sec = "${toString <secrets>}/google-muell.json";
+ sec = "${toString <secrets>}/ampel/google-muell.json";
ampelsec = "${home}/google-muell.json";
- cred = "${toString <secrets>}/google-muell-creds.json";
+ cred = "${toString <secrets>}/ampel/google-muell-creds.json";
# TODO: generate this credential file locally
ampelcred = "${home}/google-muell-creds.json";
- esp = "192.168.8.204";
sleepval = "1800";
+ # default-color = "18,63,40";
+ default-color = "255,127,0";
+ config_json = toFile "config.json" (toJSON {
+ mq_hostname = "localhost";
+ mq_port = 1883;
+ mq_username = "sensor";
+ mq_topic = "/ham/flurlicht/cmnd/MEM1";
+ mq_password = replaceChars ["\n"] [""] (readFile "${toString <secrets>}/mqtt/sensor");
+ });
in {
users.users.ampel = {
uid = genid "ampel";
@@ -27,7 +35,7 @@ in {
install -m600 -o ampel ${sec} ${ampelsec}
install -m600 -o ampel ${cred} ${ampelcred}
'';
- ExecStart = "${pkg}/bin/google-muell --esp=${esp} --client-secrets=${ampelsec} --credential-path=${ampelcred} --sleepval=${sleepval}";
+ ExecStart = "${pkg}/bin/google-muell --config ${config_json} --default-color=${default-color} --client-secrets=${ampelsec} --credential-path=${ampelcred} --sleepval=${sleepval}";
PermissionsStartOnly = true;
Restart = "always";
RestartSec = 10;