From d31fbfe31ee26b70f13c93d910f5ce0d3ce1d8c2 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 5 Feb 2020 17:34:44 +0100 Subject: ma 2/homeautomation -> 2/ham avoid overlapping autocomplete with home-manager --- makefu/2configs/ham/default.nix | 225 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 225 insertions(+) create mode 100644 makefu/2configs/ham/default.nix (limited to 'makefu/2configs/ham/default.nix') diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix new file mode 100644 index 00000000..56acc2d0 --- /dev/null +++ b/makefu/2configs/ham/default.nix @@ -0,0 +1,225 @@ +{ pkgs, lib, config, ... }: + +# Ideas: +## wake-on-lan server +## +let + hlib = (import ./lib); + prefix = hlib.prefix; + tasmota = hlib.tasmota; + firetv = "192.168.1.183"; + kodi-host = firetv; + hassdir = "/var/lib/hass"; + zigbee = import ./multi/zigbee2mqtt.nix; +# switch +# automation +# binary_sensor +# sensor +# input_select +# timer +in { + imports = [ + ./mqtt.nix + ]; + + services.home-assistant = { + config = { + input_select = zigbee.input_select; # dict + timer = zigbee.timer; # dict + homeassistant = { + name = "Home"; time_zone = "Europe/Berlin"; + latitude = "48.7687"; + longitude = "9.2478"; + elevation = 247; + }; + #discovery = {}; + conversation = {}; + history = {}; + logbook = {}; + tts = [ + { platform = "google_translate"; + language = "de"; + time_memory = 57600; + service_name = "google_say"; + } + ]; + + telegram_bot = [ + # secrets file: { + # "platform": "broadcast", + # "api_key": "", # talk to Botfather /newbot + # "allowed_chat_ids": [ ID ] # curl -X GET # https://api.telegram.org/bot/getUpdates + #} + (builtins.fromJSON + (builtins.readFile )) + ]; + notify = [ + { + platform = "kodi"; + name = "wohnzimmer"; + host = kodi-host; + } + { + platform = "telegram"; + name = "telegrambot"; + chat_id = builtins.elemAt + (builtins.fromJSON (builtins.readFile + )).allowed_chat_ids 0; + } + ]; + sun.elevation = 247; + recorder = {}; + media_player = [ + { platform = "kodi"; + host = firetv; + } + { platform = "firetv"; + name = "FireTV Stick"; + host = firetv; + adbkey = ; + } + ]; + mqtt = { + broker = "localhost"; + port = 1883; + client_id = "home-assistant"; + username = "hass"; + password = lib.removeSuffix "\n" (builtins.readFile ); + keepalive = 60; + protocol = 3.1; + birth_message = { + topic = "${prefix}/hass/tele/LWT"; + payload = "Online"; + qos = 1; + retain = true; + }; + will_message = { + topic = "${prefix}/hass/tele/LWT"; + payload = "Offline"; + qos = 1; + retain = true; + }; + }; + binary_sensor = [ + (tasmota.motion { name = "Flur Bewegung"; host = "flurlicht";}) + ] ++ zigbee.binary_sensor; + sensor = [ + # broken + #{ platform = "speedtest"; + # monitored_conditions = [ "ping" "download" "upload" ]; + #} + # https://www.home-assistant.io/cookbook/automation_for_rainy_days/ + ] + ++ ((import ./sensor/outside.nix) {inherit lib;}) + ++ zigbee.sensor + ++ (tasmota.bme { name = "Schlafzimmer"; host = "schlafzimmer";}) + ++ (tasmota.am2301 { name= "Arbeitszimmer" ; host = "arbeitszimmer"; }); + frontend = { }; + group = + { default_view = + { view = "yes"; + entities = [ + "group.flur" + "group.schlafzimmer" + "group.draussen" + "group.wohnzimmer" + "group.arbeitszimmer" + ]; + }; + 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" + "sensor.dark_sky_hourly_summary" + "sensor.dark_sky_humidity" + "sensor.dark_sky_pressure" + "sensor.muehlhausen_pm10" + "sensor.muehlhausen_pm25" + ]; + schlafzimmer = [ + "sensor.schlafzimmer_temperatur" + "sensor.schlafzimmer_luftdruck" + "sensor.schlafzimmer_luftfeuchtigkeit" + "switch.lichterkette_schlafzimmer" + ]; + arbeitszimmer = [ + "switch.strom_staubsauger" + "sensor.arbeitszimmer_temperatur" + "sensor.arbeitszimmer_luftfeuchtigkeit" + ]; + }; + http = { }; + switch = [ + (tasmota.plug { name = "Lichterkette Schlafzimmer"; host = "schlafzimmer";}) + (tasmota.plug { name = "Strom Staubsauger"; host = "arbeitszimmer"; } ) + ] ++ zigbee.switch; + light = [ (tasmota.rgb { name = "Flurlicht"; host = "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"; + # entity_id = "switch.strom_staubsauger"; + # to = "on"; + # for.hours = 6; + # }; + # action = { + # service= "homeassistant.turn_off"; + # entity_id= "switch.strom_staubsauger"; + # }; + #} + ] ++ zigbee.automation; + }; + enable = true; + configDir = hassdir; + }; + +} -- cgit v1.2.3 From 910686f65623aaccfcf55b91b538441bfbbec5d9 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 24 Feb 2020 16:55:34 +0100 Subject: ma ham/esphome: init --- makefu/2configs/ham/default.nix | 112 ++++++++++++---------------------------- 1 file changed, 34 insertions(+), 78 deletions(-) (limited to 'makefu/2configs/ham/default.nix') diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix index 56acc2d0..1a65ba62 100644 --- a/makefu/2configs/ham/default.nix +++ b/makefu/2configs/ham/default.nix @@ -7,10 +7,12 @@ let hlib = (import ./lib); prefix = hlib.prefix; tasmota = hlib.tasmota; - firetv = "192.168.1.183"; - kodi-host = firetv; + firetv_stick = "192.168.1.24"; hassdir = "/var/lib/hass"; zigbee = import ./multi/zigbee2mqtt.nix; + flurlicht = import ./multi/flurlicht.nix; + kurzzeitwecker = import ./multi/kurzzeitwecker.nix; + esphome = import ./multi/esphome.nix; # switch # automation # binary_sensor @@ -25,7 +27,7 @@ in { services.home-assistant = { config = { input_select = zigbee.input_select; # dict - timer = zigbee.timer; # dict + timer = zigbee.timer // kurzzeitwecker.timer; # dict homeassistant = { name = "Home"; time_zone = "Europe/Berlin"; latitude = "48.7687"; @@ -57,7 +59,7 @@ in { { platform = "kodi"; name = "wohnzimmer"; - host = kodi-host; + host = firetv_stick; } { platform = "telegram"; @@ -71,12 +73,13 @@ in { recorder = {}; media_player = [ { platform = "kodi"; - host = firetv; + host = firetv_stick; } - { platform = "firetv"; + { platform = "androidtv"; name = "FireTV Stick"; - host = firetv; - adbkey = ; + device_class = "firetv"; + # adb_server_ip = firetv_stick; + host = firetv_stick; } ]; mqtt = { @@ -100,21 +103,26 @@ in { retain = true; }; }; - binary_sensor = [ - (tasmota.motion { name = "Flur Bewegung"; host = "flurlicht";}) - ] ++ zigbee.binary_sensor; + luftdaten = { + show_on_map = true; + sensor_id = 679; + sensors.monitored_conditions = [ "P1" "P2" ]; + }; + binary_sensor = + zigbee.binary_sensor + ++ esphome.binary_sensor + ++ flurlicht.binary_sensor; sensor = [ - # broken - #{ platform = "speedtest"; - # monitored_conditions = [ "ping" "download" "upload" ]; - #} + { platform = "speedtest"; + monitored_conditions = [ "ping" "download" "upload" ]; + } # https://www.home-assistant.io/cookbook/automation_for_rainy_days/ ] ++ ((import ./sensor/outside.nix) {inherit lib;}) - ++ zigbee.sensor - ++ (tasmota.bme { name = "Schlafzimmer"; host = "schlafzimmer";}) - ++ (tasmota.am2301 { name= "Arbeitszimmer" ; host = "arbeitszimmer"; }); + ++ esphome.sensor + ++ zigbee.sensor ; frontend = { }; + light = flurlicht.light ++ esphome.light; group = { default_view = { view = "yes"; @@ -157,66 +165,14 @@ in { ]; }; http = { }; - switch = [ - (tasmota.plug { name = "Lichterkette Schlafzimmer"; host = "schlafzimmer";}) - (tasmota.plug { name = "Strom Staubsauger"; host = "arbeitszimmer"; } ) - ] ++ zigbee.switch; - light = [ (tasmota.rgb { name = "Flurlicht"; host = "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"; - # entity_id = "switch.strom_staubsauger"; - # to = "on"; - # for.hours = 6; - # }; - # action = { - # service= "homeassistant.turn_off"; - # entity_id= "switch.strom_staubsauger"; - # }; - #} - ] ++ zigbee.automation; + switch = + esphome.switch + ++ zigbee.switch; + automation = + flurlicht.automation + ++ kurzzeitwecker.automation + ++ zigbee.automation; + script = kurzzeitwecker.script; # dict }; enable = true; configDir = hassdir; -- cgit v1.2.3 From bcbc9ad90304a7bc86018e1fdb08c12feb33f17f Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 24 Feb 2020 16:56:42 +0100 Subject: ma ham/esphome: rip, replaced with autodiscovery --- makefu/2configs/ham/default.nix | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'makefu/2configs/ham/default.nix') diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix index 1a65ba62..de9fa6be 100644 --- a/makefu/2configs/ham/default.nix +++ b/makefu/2configs/ham/default.nix @@ -12,7 +12,6 @@ let zigbee = import ./multi/zigbee2mqtt.nix; flurlicht = import ./multi/flurlicht.nix; kurzzeitwecker = import ./multi/kurzzeitwecker.nix; - esphome = import ./multi/esphome.nix; # switch # automation # binary_sensor @@ -34,7 +33,7 @@ in { longitude = "9.2478"; elevation = 247; }; - #discovery = {}; + discovery = {}; conversation = {}; history = {}; logbook = {}; @@ -110,7 +109,6 @@ in { }; binary_sensor = zigbee.binary_sensor - ++ esphome.binary_sensor ++ flurlicht.binary_sensor; sensor = [ { platform = "speedtest"; @@ -119,10 +117,9 @@ in { # https://www.home-assistant.io/cookbook/automation_for_rainy_days/ ] ++ ((import ./sensor/outside.nix) {inherit lib;}) - ++ esphome.sensor ++ zigbee.sensor ; frontend = { }; - light = flurlicht.light ++ esphome.light; + light = flurlicht.light; group = { default_view = { view = "yes"; @@ -166,8 +163,7 @@ in { }; http = { }; switch = - esphome.switch - ++ zigbee.switch; + zigbee.switch; automation = flurlicht.automation ++ kurzzeitwecker.automation -- cgit v1.2.3 From 843ee70248752c7b3fc656807bd12b6e6f21f0e1 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 24 Feb 2020 16:59:11 +0100 Subject: ma ham/zigbee2mqtt: configuration with discovery in mind --- makefu/2configs/ham/default.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'makefu/2configs/ham/default.nix') diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix index de9fa6be..ae0c46ba 100644 --- a/makefu/2configs/ham/default.nix +++ b/makefu/2configs/ham/default.nix @@ -108,8 +108,7 @@ in { sensors.monitored_conditions = [ "P1" "P2" ]; }; binary_sensor = - zigbee.binary_sensor - ++ flurlicht.binary_sensor; + flurlicht.binary_sensor; sensor = [ { platform = "speedtest"; monitored_conditions = [ "ping" "download" "upload" ]; @@ -162,8 +161,7 @@ in { ]; }; http = { }; - switch = - zigbee.switch; + switch = []; automation = flurlicht.automation ++ kurzzeitwecker.automation -- cgit v1.2.3 From 2563c59e73dfe9df7b98d5b184785f3a5936ca17 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 3 Mar 2020 21:12:51 +0100 Subject: ma ham: use home-assistant from unstable, enable androidtv support --- makefu/2configs/ham/default.nix | 67 ++++++++++++----------------------------- 1 file changed, 19 insertions(+), 48 deletions(-) (limited to 'makefu/2configs/ham/default.nix') diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix index ae0c46ba..3fbe1187 100644 --- a/makefu/2configs/ham/default.nix +++ b/makefu/2configs/ham/default.nix @@ -4,13 +4,14 @@ ## wake-on-lan server ## let + upkgs = (import {}).pkgs; hlib = (import ./lib); prefix = hlib.prefix; tasmota = hlib.tasmota; firetv_stick = "192.168.1.24"; hassdir = "/var/lib/hass"; zigbee = import ./multi/zigbee2mqtt.nix; - flurlicht = import ./multi/flurlicht.nix; + #flurlicht = import ./multi/flurlicht.nix; kurzzeitwecker = import ./multi/kurzzeitwecker.nix; # switch # automation @@ -24,6 +25,13 @@ in { ]; services.home-assistant = { + package = (upkgs.home-assistant.overrideAttrs (old: { + })).override { + extraPackages = ps: with ps; [ + python-forecastio jsonrpc-async jsonrpc-websocket mpd2 pkgs.picotts + (ps.callPackage ./androidtv {}) + ]; + }; config = { input_select = zigbee.input_select; # dict timer = zigbee.timer // kurzzeitwecker.timer; # dict @@ -71,7 +79,7 @@ in { sun.elevation = 247; recorder = {}; media_player = [ - { platform = "kodi"; + { platform = "FireTV Stick kodi"; host = firetv_stick; } { platform = "androidtv"; @@ -79,10 +87,13 @@ in { device_class = "firetv"; # adb_server_ip = firetv_stick; host = firetv_stick; + port = 5555; } ]; mqtt = { broker = "localhost"; + discovery = true; #enable esphome discovery + discovery_prefix = "homeassistant"; port = 1883; client_id = "home-assistant"; username = "hass"; @@ -107,8 +118,8 @@ in { sensor_id = 679; sensors.monitored_conditions = [ "P1" "P2" ]; }; - binary_sensor = - flurlicht.binary_sensor; + #binary_sensor = + # flurlicht.binary_sensor; sensor = [ { platform = "speedtest"; monitored_conditions = [ "ping" "download" "upload" ]; @@ -118,53 +129,13 @@ in { ++ ((import ./sensor/outside.nix) {inherit lib;}) ++ zigbee.sensor ; frontend = { }; - light = flurlicht.light; - group = - { default_view = - { view = "yes"; - entities = [ - "group.flur" - "group.schlafzimmer" - "group.draussen" - "group.wohnzimmer" - "group.arbeitszimmer" - ]; - }; - 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" - "sensor.dark_sky_hourly_summary" - "sensor.dark_sky_humidity" - "sensor.dark_sky_pressure" - "sensor.muehlhausen_pm10" - "sensor.muehlhausen_pm25" - ]; - schlafzimmer = [ - "sensor.schlafzimmer_temperatur" - "sensor.schlafzimmer_luftdruck" - "sensor.schlafzimmer_luftfeuchtigkeit" - "switch.lichterkette_schlafzimmer" - ]; - arbeitszimmer = [ - "switch.strom_staubsauger" - "sensor.arbeitszimmer_temperatur" - "sensor.arbeitszimmer_luftfeuchtigkeit" - ]; - }; + # light = flurlicht.light; http = { }; switch = []; automation = - flurlicht.automation - ++ kurzzeitwecker.automation + (import ./automation/firetv_restart.nix) + kurzzeitwecker.automation + #++ flurlicht.automation ++ zigbee.automation; script = kurzzeitwecker.script; # dict }; -- cgit v1.2.3 From c325d7d6cfd6a11b6d3e4e83d06801de3c97b48a Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:41:23 +0100 Subject: ma ham: update home-assistant config --- makefu/2configs/ham/default.nix | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'makefu/2configs/ham/default.nix') diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix index 3fbe1187..53723299 100644 --- a/makefu/2configs/ham/default.nix +++ b/makefu/2configs/ham/default.nix @@ -13,6 +13,7 @@ let zigbee = import ./multi/zigbee2mqtt.nix; #flurlicht = import ./multi/flurlicht.nix; kurzzeitwecker = import ./multi/kurzzeitwecker.nix; + firetv_restart = import ./multi/firetv_restart.nix; # switch # automation # binary_sensor @@ -45,6 +46,9 @@ in { conversation = {}; history = {}; logbook = {}; + logger = { + default = "info"; + }; tts = [ { platform = "google_translate"; language = "de"; @@ -132,12 +136,14 @@ in { # light = flurlicht.light; http = { }; switch = []; - automation = - (import ./automation/firetv_restart.nix) - kurzzeitwecker.automation - #++ flurlicht.automation - ++ zigbee.automation; - script = kurzzeitwecker.script; # dict + automation = [] + ++ (import ./automation/firetv_restart.nix) + ++ kurzzeitwecker.automation + #++ flurlicht.automation + ++ zigbee.automation; + script = + { } + // kurzzeitwecker.script; # dict }; enable = true; configDir = hassdir; -- cgit v1.2.3