From e2fcbd0919015085b310d72198fb2e0250b5d1cd Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 15 Jan 2020 09:11:03 +0100 Subject: shack/muellshack: bump to latest master adds new static data for 2020 --- krebs/2configs/shack/muellshack.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/krebs/2configs/shack/muellshack.nix b/krebs/2configs/shack/muellshack.nix index c67d8f523..e894b9394 100644 --- a/krebs/2configs/shack/muellshack.nix +++ b/krebs/2configs/shack/muellshack.nix @@ -4,8 +4,9 @@ let pkg = pkgs.callPackage ( pkgs.fetchgit { url = "https://git.shackspace.de/rz/muellshack"; - rev = "c3d1f70325e5b90f280c5be60110e14f4de653ae"; - sha256 = "1dd4kqwdr4v413rmkvmyjzzvw8id9747nifp96pg0c2cy6bhzj24"; + rev = "dc80cf1edaa3d86ec2bebae8596ad1d4c4e3650a"; + sha256 = "1yipr66zhrg5m20pf3rzvgvvl78an6ddkq6zc45rxb2r0i7ipkyh"; + }) { mkYarnPackage = pkgs.yarn2nix-moretea.mkYarnPackage; }; home = "/var/lib/muellshack"; port = "8081"; -- cgit v1.2.3 From 6508c853da3596b701aa00e99a5260d31ebeaa24 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 23 Jan 2020 23:51:05 +0100 Subject: shack/glados: schlechte_luft add rz --- krebs/2configs/shack/glados/multi/schlechte_luft.nix | 5 +++++ makefu/2configs/default.nix | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/krebs/2configs/shack/glados/multi/schlechte_luft.nix b/krebs/2configs/shack/glados/multi/schlechte_luft.nix index 9cd2c56f4..4625f6846 100644 --- a/krebs/2configs/shack/glados/multi/schlechte_luft.nix +++ b/krebs/2configs/shack/glados/multi/schlechte_luft.nix @@ -15,6 +15,11 @@ in (glados.esphome.temp { host = "fablab_feinstaub";}) (glados.esphome.dust_25m { host = "fablab_feinstaub";}) (glados.esphome.dust_100m { host = "fablab_feinstaub";}) + + (glados.esphome.temp { host = "rz_feinstaub";}) + (glados.esphome.hum { host = "rz_feinstaub";}) + (glados.esphome.dust_25m { host = "rz_feinstaub";}) + (glados.esphome.dust_100m { host = "rz_feinstaub";}) ]; automation = [ diff --git a/makefu/2configs/default.nix b/makefu/2configs/default.nix index 5faf3ce93..0cbb5efe7 100644 --- a/makefu/2configs/default.nix +++ b/makefu/2configs/default.nix @@ -28,6 +28,7 @@ with import ; openssh.authorizedKeys.keys = [ config.krebs.users.makefu.pubkey ]; }; }; + nix.trustedUsers = [ config.krebs.build.user.name ]; boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; @@ -41,8 +42,6 @@ with import ; }; - - boot.tmpOnTmpfs = true; systemd.tmpfiles.rules = [ "d /tmp 1777 root root - -" @@ -61,7 +60,7 @@ with import ; environment.shellAliases = { # TODO: see .aliases lsl = "ls -lAtr"; - dmesg = "journalctl -kb | cat"; + dmesg = "dmesg -L --reltime"; psg = "ps -ef | grep"; nmap = "nmap -oN $HOME/loot/scan-`date +\%s`.nmap -oX $HOME/loot/scan-`date +%s`.xml"; grep = "grep --color=auto"; -- cgit v1.2.3 From c12411d79f21f6e462251d02485c8b2a139cb93e Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 23 Jan 2020 23:52:39 +0100 Subject: shack/glados: add shack-startup --- .../shack/glados/automation/hass-restart.nix | 3 +- .../shack/glados/automation/shack-startup.nix | 82 ++++++++++++++++++++++ krebs/2configs/shack/glados/default.nix | 13 +++- krebs/2configs/shack/glados/lib/default.nix | 40 +++++++++++ 4 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 krebs/2configs/shack/glados/automation/shack-startup.nix diff --git a/krebs/2configs/shack/glados/automation/hass-restart.nix b/krebs/2configs/shack/glados/automation/hass-restart.nix index e87354978..1b380204d 100644 --- a/krebs/2configs/shack/glados/automation/hass-restart.nix +++ b/krebs/2configs/shack/glados/automation/hass-restart.nix @@ -6,12 +6,13 @@ platform = "homeassistant"; event = "start"; }; + # trigger good/bad air action = [ { service = "light.turn_on"; data = { entity_id = "light.fablab_led"; effect = "Rainbow"; - color_name = "yellow"; + color_name = "purple"; }; } ]; diff --git a/krebs/2configs/shack/glados/automation/shack-startup.nix b/krebs/2configs/shack/glados/automation/shack-startup.nix new file mode 100644 index 000000000..10051d60a --- /dev/null +++ b/krebs/2configs/shack/glados/automation/shack-startup.nix @@ -0,0 +1,82 @@ +# needs: +# binary_sensor.portal_lock +# sensor.keyholder +# media_player.lounge +let + glados = import ../lib; +in +[ + { + alias = "Greet new keyholder for key exchange"; + initial_state = true; + trigger = { + platform = "state"; + entity_id = "sensor.keyholder"; + }; + condition = { + condition = "template"; + value_template = "{{ trigger.from_state.state != 'No Keyholder' }}"; + }; + #action = glados.say.lounge "Danke {{trigger.to_state.state}} für das Übernehmen des Keys von {{trigger.from_state.state}}"; + action = []; + } + + { + alias = "Start Music on portal lock on"; + # TODO: use "power" trigger + trigger = { + platform = "state"; + entity_id = "binary_sensor.portal_lock"; + to = "on"; + for.seconds = 30; + }; + condition = { + condition = "and"; + conditions = + [ + { # only start if a keyholder opened the door and if the lounge mpd is currently not playing anything + condition = "template"; + value_template = "{{ state('sensor.keyholder') != 'No Keyholder' }}"; + } + { + condition = "state"; + entity_id = "media_player.lounge"; + state = "idle"; + } + ]; + }; + action = [ + { + service = "media_player.volume_set"; + data = { + entity_id = "media_player.lounge"; + volume_level = 1.0; + }; + } + { + service = "media_player.play_media"; + data = { + entity_id = "media_player.lounge"; + media_content_type = "playlist"; + media_content_id = "ansage"; + }; + } + { delay.seconds = 8; } + { + service = "media_player.volume_set"; + data = { + entity_id = "media_player.lounge"; + volume_level = 0.6; + }; + } + { + service = "media_player.play_media"; + data = { + entity_id = "media_player.lounge"; + media_content_type = "playlist"; + media_content_id = "lassulus superradio"; + }; + } + ]; + } +] diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix index e48a54551..ef22ccb0d 100644 --- a/krebs/2configs/shack/glados/default.nix +++ b/krebs/2configs/shack/glados/default.nix @@ -93,6 +93,7 @@ in { light = badair.light; media_player = [ { platform = "mpd"; + name = "lounge"; host = "lounge.mpd.shack"; } ]; @@ -117,19 +118,27 @@ in { #conversation = {}; history = {}; logbook = {}; + logger = { + default = "info"; + }; recorder = {}; tts = [ { platform = "google_translate"; + service_name = "say"; language = "de"; + cache = true; + time_memory = 57600; } #{ platform = "picotts"; # language = "de-DE"; + # service_name = "say"; #} ]; sun = {}; - automation = wasser.automation - ++ badair.automation + automation = wasser.automation + ++ badair.automation + ++ (import ./automation/shack-startup.nix) ++ (import ./automation/hass-restart.nix); device_tracker = []; diff --git a/krebs/2configs/shack/glados/lib/default.nix b/krebs/2configs/shack/glados/lib/default.nix index 6737af842..16cbc6830 100644 --- a/krebs/2configs/shack/glados/lib/default.nix +++ b/krebs/2configs/shack/glados/lib/default.nix @@ -2,6 +2,46 @@ let prefix = "glados"; in { + + say = let + # returns a list of actions to be performed on an mpd to say something + tts = { message, entity }: + [ + { + service = "media_player.turn_on"; + data.entity_id = "media_player.lounge"; + } + { service = "media_player.play_media"; + data = { + entity_id = "media_player.lounge"; + media_content_type = "playlist"; + media_content_id = "ansage"; + }; + } + { + service = "media_player.turn_on"; + data.entity_id = "media_player.lounge"; + } + { delay.seconds = 8; } + { service = "tts.say"; + entity_id = "media_player.lounge"; + data_template = { + inherit message; + language = "de"; + }; + } + ]; + in + { + lounge = message: tts { + inherit message; + entity = "lounge"; + }; + herrenklo = message: tts { + inherit message; + entity = "herrenklo"; + }; + }; esphome = { temp = {host, topic ? "temperature" }: -- cgit v1.2.3 From e38f61c7ff54031d5f48e57b96eff0062feb99b2 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 30 Jan 2020 08:12:24 +0100 Subject: ma: update omo pubkey --- krebs/3modules/makefu/sshd/omo.pub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/3modules/makefu/sshd/omo.pub b/krebs/3modules/makefu/sshd/omo.pub index 63bbbc709..5b9435414 100644 --- a/krebs/3modules/makefu/sshd/omo.pub +++ b/krebs/3modules/makefu/sshd/omo.pub @@ -1 +1 @@ -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPTBGboU/P00yYiwYje53G0oqDFWmcSJ+hIpMsl4f/HH +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIujMZ3ZFxKpWeB/cjfKfYRr77+VRZk0Eik+92t03NoA -- cgit v1.2.3 From 89032b3ac2aff2373377ef442804e90db9694c91 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 4 Feb 2020 18:26:59 +0100 Subject: ma homeautomation: init with zigbee --- makefu/2configs/homeautomation/default.nix | 224 +++++---------- makefu/2configs/homeautomation/lib/default.nix | 318 +++++++++++++++++++++ makefu/2configs/homeautomation/multi/timer.nix | 123 ++++++++ .../2configs/homeautomation/multi/zigbee2mqtt.nix | 165 +++++++++++ makefu/2configs/homeautomation/sensor/outside.nix | 26 ++ 5 files changed, 704 insertions(+), 152 deletions(-) create mode 100644 makefu/2configs/homeautomation/lib/default.nix create mode 100644 makefu/2configs/homeautomation/multi/timer.nix create mode 100644 makefu/2configs/homeautomation/multi/zigbee2mqtt.nix create mode 100644 makefu/2configs/homeautomation/sensor/outside.nix diff --git a/makefu/2configs/homeautomation/default.nix b/makefu/2configs/homeautomation/default.nix index 4e9ac0ee3..56acc2d07 100644 --- a/makefu/2configs/homeautomation/default.nix +++ b/makefu/2configs/homeautomation/default.nix @@ -2,106 +2,21 @@ # Ideas: ## wake-on-lan server -## +## let - tasmota_rgb = name: topic: -# LED WS2812b -# effect_state_topic: "stat/led/Scheme" -# effect_command_topic: "cmnd/led/Scheme" -# effect_value_template: "{{ value_json.Scheme }}" - { platform = "mqtt"; - inherit name; - retain = false; - qos = 1; - optimistic = false; - # state - # TODO: currently broken, will not use the custom state topic - #state_topic = "/ham/${topic}/stat/POWER"; - state_topic = "/ham/${topic}/stat/POWER"; - command_topic = "/ham/${topic}/cmnd/POWER"; - availability_topic = "/ham/${topic}/tele/LWT"; - payload_on= "ON"; - payload_off= "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - # brightness - brightness_state_topic = "/ham/${topic}/stat/Dimmer"; - brightness_command_topic = "/ham/${topic}/cmnd/Dimmer"; - brightness_value_template = "{{ value_json.Dimmer }}"; - brightness_scale = 100; - # color - rgb_state_topic = "/ham/${topic}/stat/Color"; - rgb_command_topic = "/ham/${topic}/cmnd/MEM1"; # use enabled tasmota rule - rgb_command_mode = "hex"; - rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; - # effects - effect_state_topic = "/ham/${topic}/stat/Scheme"; - effect_command_topic = "/ham/${topic}/cmnd/Scheme"; - effect_value_template = "{{ value_json.Scheme }}"; - effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ]; -}; - # switchmode 1 - also toggle power - # switchtopic flurlicht - tasmota_motion = name: topic: - { platform = "mqtt"; - device_class = "motion"; - inherit name; - # TODO: currently broken, will not use the custom state topic - state_topic = "/ham/${topic}/stat/POWER"; - payload_on = "ON"; - payload_off = "OFF"; - availability_topic = "/ham/${topic}/tele/LWT"; - payload_available = "Online"; - payload_not_available = "Offline"; - }; - + hlib = (import ./lib); + prefix = hlib.prefix; + tasmota = hlib.tasmota; firetv = "192.168.1.183"; + kodi-host = firetv; hassdir = "/var/lib/hass"; - tasmota_plug = name: topic: - { platform = "mqtt"; - inherit name; - state_topic = "/ham/${topic}/stat/POWER1"; - command_topic = "/ham/${topic}/cmnd/POWER1"; - availability_topic = "/ham/${topic}/tele/LWT"; - payload_on= "ON"; - payload_off= "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - }; - tasmota_bme = name: topic: - [ { platform = "mqtt"; - name = "${name} Temperatur"; - state_topic = "/ham/${topic}/tele/SENSOR"; - value_template = "{{ value_json.BME280.Temperature }}"; - unit_of_measurement = "°C"; - } - { platform = "mqtt"; - name = "${name} Luftfeuchtigkeit"; - state_topic = "/ham/${topic}/tele/SENSOR"; - value_template = "{{ value_json.BME280.Humidity }}"; - unit_of_measurement = "%"; - } - { platform = "mqtt"; - name = "${name} Luftdruck"; - state_topic = "/ham/${topic}/tele/SENSOR"; - value_template = "{{ value_json.BME280.Pressure }}"; - unit_of_measurement = "hPa"; - } - ]; - tasmota_am2301 = name: topic: - [ { platform = "mqtt"; - name = "${name} Temperatur"; - state_topic = "/ham/${topic}/tele/SENSOR"; - value_template = "{{ value_json.AM2301.Temperature }}"; - unit_of_measurement = "°C"; - } - { platform = "mqtt"; - name = "${name} Luftfeuchtigkeit"; - state_topic = "/ham/${topic}/tele/SENSOR"; - value_template = "{{ value_json.AM2301.Humidity }}"; - unit_of_measurement = "%"; - } - ]; + zigbee = import ./multi/zigbee2mqtt.nix; +# switch +# automation +# binary_sensor +# sensor +# input_select +# timer in { imports = [ ./mqtt.nix @@ -109,6 +24,8 @@ in { services.home-assistant = { config = { + input_select = zigbee.input_select; # dict + timer = zigbee.timer; # dict homeassistant = { name = "Home"; time_zone = "Europe/Berlin"; latitude = "48.7687"; @@ -120,8 +37,36 @@ in { history = {}; logbook = {}; tts = [ - { platform = "google";} + { 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 = [ @@ -143,56 +88,32 @@ in { keepalive = 60; protocol = 3.1; birth_message = { - topic = "/ham/hass/tele/LWT"; + topic = "${prefix}/hass/tele/LWT"; payload = "Online"; qos = 1; retain = true; }; will_message = { - topic = "/ham/hass/tele/LWT"; + topic = "${prefix}/hass/tele/LWT"; payload = "Offline"; qos = 1; retain = true; }; }; binary_sensor = [ - (tasmota_motion "Flur Bewegung" "flurlicht") - ]; + (tasmota.motion { name = "Flur Bewegung"; host = "flurlicht";}) + ] ++ zigbee.binary_sensor; sensor = [ # broken #{ platform = "speedtest"; # monitored_conditions = [ "ping" "download" "upload" ]; #} - { platform = "luftdaten"; - name = "Wangen"; - sensorid = "663"; - monitored_conditions = [ "P1" "P2" ]; - } # https://www.home-assistant.io/cookbook/automation_for_rainy_days/ - { platform = "darksky"; - api_key = lib.removeSuffix "\n" - (builtins.readFile ); - language = "de"; - monitored_conditions = [ "summary" "icon" - "nearest_storm_distance" "precip_probability" - "precip_intensity" - "temperature" - "apparent_temperature" - "hourly_summary" - "humidity" - "pressure" - "uv_index" ]; - units = "si" ; - update_interval = { - days = 0; - hours = 0; - minutes = 30; - seconds = 0; - }; - } ] - ++ (tasmota_bme "Schlafzimmer" "schlafzimmer") - ++ (tasmota_am2301 "Arbeitszimmer" "arbeitszimmer"); + ++ ((import ./sensor/outside.nix) {inherit lib;}) + ++ zigbee.sensor + ++ (tasmota.bme { name = "Schlafzimmer"; host = "schlafzimmer";}) + ++ (tasmota.am2301 { name= "Arbeitszimmer" ; host = "arbeitszimmer"; }); frontend = { }; group = { default_view = @@ -218,8 +139,10 @@ in { draussen = [ "sensor.dark_sky_temperature" "sensor.dark_sky_hourly_summary" - "sensor.wangen_pm10" - "sensor.wangen_pm25" + "sensor.dark_sky_humidity" + "sensor.dark_sky_pressure" + "sensor.muehlhausen_pm10" + "sensor.muehlhausen_pm25" ]; schlafzimmer = [ "sensor.schlafzimmer_temperatur" @@ -235,10 +158,10 @@ in { }; http = { }; switch = [ - (tasmota_plug "Lichterkette Schlafzimmer" "schlafzimmer") - (tasmota_plug "Strom Staubsauger" "arbeitszimmer") - ]; - light = [ (tasmota_rgb "Flurlicht" "flurlicht" ) ]; + (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 = { @@ -281,25 +204,22 @@ in { } ]; } - { 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"; - }; - } - ]; + #{ 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; }; - nixpkgs.config.permittedInsecurePackages = [ - "homeassistant-0.77.2" - ]; } diff --git a/makefu/2configs/homeautomation/lib/default.nix b/makefu/2configs/homeautomation/lib/default.nix new file mode 100644 index 000000000..8bc544310 --- /dev/null +++ b/makefu/2configs/homeautomation/lib/default.nix @@ -0,0 +1,318 @@ +let + prefix = "/ham"; +in +{ + inherit prefix; + say = let + # returns a list of actions to be performed on an mpd to say something + tts = { message, entity }: + [ + { + service = "media_player.turn_on"; + data.entity_id = entity; + } + { + service = "media_player.play_media"; + data = { + entity_id = entity; + media_content_type = "playlist"; + media_content_id = "ansage"; + }; + } + { + service = "media_player.turn_on"; + data.entity_id = entity; + } + { delay.seconds = 8; } + { + service = "tts.say"; + entity_id = entity; + data_template = { + inherit message; + language = "de"; + }; + } + ]; + in + { + firetv = message: tts { + inherit message; + entity = "firetv"; + }; + }; + zigbee = let + prefix = "/ham/zigbee"; + in + { + inherit prefix; + state = name: { + platform = "mqtt"; + name = "zigbee ${name} connectivity"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + payload_on = true; + payload_off = false; + value_template = "{{ value_json.state }}"; + device_class = "connectivity"; + }; + battery = name: { + platform = "mqtt"; + name = "zigbee ${name} battery"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + unit_of_measurement = "%"; + device_class = "battery"; + value_template = "{{ value_json.battery }}"; + }; + linkquality = name: { + platform = "mqtt"; + name = "zigbee ${name} linkquality"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + unit_of_measurement = "-"; + value_template = "{{ value_json.linkquality }}"; + }; + temperature = name: { + platform = "mqtt"; + name = "zigbee ${name} temperature"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + unit_of_measurement = "°C"; + device_class = "temperature"; + value_template = "{{ value_json.temperature }}"; + }; + humidity = name: { + platform = "mqtt"; + name = "zigbee ${name} humidity"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + unit_of_measurement = "%"; + device_class = "humidity"; + value_template = "{{ value_json.humidity }}"; + }; + pressure = name: { + platform = "mqtt"; + state_topic = "${prefix}/${name}"; + name = "zigbee ${name} pressure"; + availability_topic = "${prefix}/bridge/state"; + unit_of_measurement = "hPa"; + device_class = "pressure"; + value_template = "{{ value_json.pressure }}" ; + }; + click = name: + { + platform = "mqtt"; + name = "zigbee ${name} click"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + icon = "mdi:toggle-switch"; + value_template = "{{ value_json.click }}"; + }; + contact = name: { + platform = "mqtt"; + name = "zigbee ${name} contact"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + payload_on = false; + payload_off = true; + value_template = "{{ value_json.contact }}"; + device_class = "door"; + }; + }; + esphome = + { + temp = {host, topic ? "temperature" }: + { + platform = "mqtt"; + name = "${host} Temperature"; + device_class = "temperature"; + unit_of_measurement = "°C"; + icon = "mdi:thermometer"; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + payload_available = "online"; + payload_not_available = "offline"; + }; + hum = {host, topic ? "humidity" }: + { + platform = "mqtt"; + unit_of_measurement = "%"; + icon = "mdi:water-percent"; + device_class = "humidity"; + name = "${host} Humidity"; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + payload_available = "online"; + payload_not_available = "offline"; + }; + # copied from "homeassistant/light/fablab_led/led_ring/config" + led = {host, topic ? "led", name ? host}: + { # name: fablab_led + # topic: led_ring + platform = "mqtt"; + inherit name; + schema = "json"; + brightness = true; + rgb = true; + effect = true; + effect_list = [ # TODO: may be different + "Random" + "Strobe" + "Rainbow" + "Color Wipe" + "Scan" + "Twinkle" + "Fireworks" + "Addressable Flicker" + "None" + ]; + state_topic = "${prefix}/${host}/light/${topic}/state"; + command_topic = "${prefix}/${host}/light/${topic}/command"; + availability_topic = "${prefix}/${host}/status"; + payload_available = "online"; + payload_not_available = "offline"; + qos = 1; + }; + # Feinstaub + dust_25m = { host, name ? "${host} < 2.5µm", topic ? "particulate_matter_25m_concentration" }: + { + platform = "mqtt"; + unit_of_measurement = "µg/m³"; + icon = "mdi:chemical-weapon"; + inherit name; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; + dust_100m = {host, name ? "${host} < 10µm", topic ? "particulate_matter_100m_concentration" }: + { + platform = "mqtt"; + unit_of_measurement = "µg/m³"; + icon = "mdi:chemical-weapon"; + inherit name; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; + ip = {host, name ? "${host} IP", topic ? "ip_address" }: + { + platform = "mqtt"; + inherit name; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; + wifi = {host, name ? "${host} Wifi Signal", topic ? "wifi_signal" }: + { + platform = "mqtt"; + unit_of_measurement = "dB"; + icon = "mdi:wifi"; + inherit name; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; + switch = {host, name ? "${host} Button", topic ? "btn" }: + # host: ampel + # name: Button 1 + # topic: btn1 + { + inherit name; + platform = "mqtt"; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + command_topic = "${prefix}/${host}/switch/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; + }; + tasmota = + { + plug = {host, name ? host, topic ? host}: + { + platform = "mqtt"; + inherit name; + state_topic = "sonoff/stat/${topic}/POWER1"; + command_topic = "sonoff/cmnd/${topic}/POWER1"; + availability_topic = "sonoff/tele/${topic}/LWT"; + payload_on= "ON"; + payload_off= "OFF"; + payload_available= "Online"; + payload_not_available= "Offline"; + retain = false; + qos = 1; + }; + am2301 = { name, host, topic?host }: + [ { platform = "mqtt"; + name = "${name} Temperatur"; + state_topic = "${prefix}/${topic}/tele/SENSOR"; + value_template = "{{ value_json.AM2301.Temperature }}"; + unit_of_measurement = "°C"; + } + { platform = "mqtt"; + name = "${name} Luftfeuchtigkeit"; + state_topic = "${prefix}/${topic}/tele/SENSOR"; + value_template = "{{ value_json.AM2301.Humidity }}"; + unit_of_measurement = "%"; + } + ]; + bme = { name, host, topic?host }: + [ { platform = "mqtt"; + name = "${name} Temperatur"; + state_topic = "${prefix}/${topic}/tele/SENSOR"; + value_template = "{{ value_json.BME280.Temperature }}"; + unit_of_measurement = "°C"; + } + { platform = "mqtt"; + name = "${name} Luftfeuchtigkeit"; + state_topic = "${prefix}/${topic}/tele/SENSOR"; + value_template = "{{ value_json.BME280.Humidity }}"; + unit_of_measurement = "%"; + } + { platform = "mqtt"; + name = "${name} Luftdruck"; + state_topic = "${prefix}/${topic}/tele/SENSOR"; + value_template = "{{ value_json.BME280.Pressure }}"; + unit_of_measurement = "hPa"; + } + ]; + rgb = { name, host, topic?host }: + { platform = "mqtt"; + inherit name; + retain = false; + qos = 1; + optimistic = false; + # state + # TODO: currently broken, will not use the custom state topic + #state_topic = "${prefix}/${topic}/stat/POWER"; + state_topic = "${prefix}/${topic}/stat/POWER"; + command_topic = "${prefix}/${topic}/cmnd/POWER"; + availability_topic = "${prefix}/${topic}/tele/LWT"; + payload_on= "ON"; + payload_off= "OFF"; + payload_available= "Online"; + payload_not_available= "Offline"; + # brightness + brightness_state_topic = "${prefix}/${topic}/stat/Dimmer"; + brightness_command_topic = "${prefix}/${topic}/cmnd/Dimmer"; + brightness_value_template = "{{ value_json.Dimmer }}"; + brightness_scale = 100; + # color + rgb_state_topic = "${prefix}/${topic}/stat/Color"; + rgb_command_topic = "${prefix}/${topic}/cmnd/MEM1"; # use enabled rule + rgb_command_mode = "hex"; + rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; + # effects + effect_state_topic = "${prefix}/${topic}/stat/Scheme"; + effect_command_topic = "${prefix}/${topic}/cmnd/Scheme"; + effect_value_template = "{{ value_json.Scheme }}"; + effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ]; +}; + motion = { name, host, topic?host }: + { platform = "mqtt"; + device_class = "motion"; + inherit name; + # TODO: currently broken, will not use the custom state topic + state_topic = "${prefix}/${topic}/stat/POWER"; + payload_on = "ON"; + payload_off = "OFF"; + availability_topic = "${prefix}/${topic}/tele/LWT"; + payload_available = "Online"; + payload_not_available = "Offline"; + }; + }; +} diff --git a/makefu/2configs/homeautomation/multi/timer.nix b/makefu/2configs/homeautomation/multi/timer.nix new file mode 100644 index 000000000..eafb7841d --- /dev/null +++ b/makefu/2configs/homeautomation/multi/timer.nix @@ -0,0 +1,123 @@ +# Provides: +# timer +# automation +# script + +# Needs: +# sensor.zigbee_btn1_click +# notify.telegrambot +let + button = "sensor.zigbee_btn1_click"; +in { + timer.kurzzeitwecker = + { + name = "Zigbee Kurzzeitwecker"; + duration = 300; + }; + script.add_5_minutes_to_kurzzeitwecker = + { + alias = "Add 5 minutes to kurzzeitwecker"; + sequence = [ + { service = "timer.pause"; + entity_id = "timer.kurzzeitwecker"; + } + { service = "timer.start"; + data_template = { + entity_id = "timer.kurzzeitwecker"; + duration = '' + {% set r = state_attr('timer.wecker', 'remaining') ~ '-0000' %} + {% set t = strptime(r, '%H:%M:%S.%f%z') %} + {{ (as_timestamp(t) + 300) | timestamp_custom('%H:%M:%S', false) }} + ''; + }; + } + ]; + }; + automation = + [ + { + alias = "Start Timer 5min"; + trigger = { + platform = "state"; + entity_id = button; + to = "single"; + }; + condition = + { condition = "state"; + entity_id = "timer.kurzzeitwecker"; + state = "idle"; + }; + + action = [ + { service = "timer.start"; + entity_id = "timer.kurzzeitwecker"; + duration = "00:05:00"; + } + { + service = "notify.telegrambot"; + data = { + title = "Timer gestartet"; + message = "Timer auf 5 minuten gestellt"; + }; + } + ]; + } + { + alias = "Start Timer 10min"; + trigger = { + platform = "state"; + entity_id = button; + to = "double"; + }; + condition = + { + condition = "state"; + entity_id = "timer.kurzzeitwecker"; + state = "idle"; + }; + action = + [ + { + service = "timer.start"; + entity_id = "timer.kurzzeitwecker"; + duration = "00:10:00"; + } + { + service = "notify.telegrambot"; + data = { + title = "Timer gestartet"; + message = "Timer auf 10 minuten gestellt"; + }; + } + ]; + } + { + alias = "Stop timer on triple click"; + trigger = + { + platform = "state"; + entity_id = button; + to = "triple"; + }; + condition = + { + condition = "state"; + entity_id = "timer.kurzzeitwecker"; + state = "active"; + }; + + action = [ + { + service = "timer.stop"; + entity_id = "timer.kurzzeitwecker"; + } + { + service = "notify.telegrambot"; + data = { + title = "Timer gestoppt"; + }; + } + ]; + } + ]; +} diff --git a/makefu/2configs/homeautomation/multi/zigbee2mqtt.nix b/makefu/2configs/homeautomation/multi/zigbee2mqtt.nix new file mode 100644 index 000000000..ba81b1298 --- /dev/null +++ b/makefu/2configs/homeautomation/multi/zigbee2mqtt.nix @@ -0,0 +1,165 @@ +# provides: +# switch +# automation +# binary_sensor +# sensor +# input_select +# timer +let + inherit (import ../lib) zigbee; + prefix = zigbee.prefix; + xiaomi_btn = name: [ + (zigbee.battery name) + (zigbee.linkquality name) + (zigbee.click name) + ]; + xiaomi_temp = name: [ + (zigbee.battery name) + (zigbee.linkquality name) + (zigbee.temperature name) + (zigbee.humidity name) + (zigbee.pressure name) + ]; + xiaomi_contact = name: [ + (zigbee.battery name) + (zigbee.linkquality name) + (zigbee.contact name) + ]; + router_link = name: [ + (zigbee.linkquality name) + ]; + router_bin = name: [ + (zigbee.state name) + ]; +in { + sensor = + (xiaomi_btn "btn1") + ++ (xiaomi_btn "btn2") + ++ (xiaomi_btn "btn3") + + ++ (xiaomi_temp "temp1") + ++ (xiaomi_temp "temp2") + ++ (xiaomi_temp "temp3") + + ++ (router_link "router1") + ++ (router_link "router2") + + ++ [ + # Sensor for monitoring the bridge state + { + platform = "mqtt"; + name = "Zigbee2mqtt Bridge state"; + state_topic = "${prefix}/bridge/state"; + icon = "mdi:router-wireless"; + } + # Sensor for Showing the Zigbee2mqtt Version + { + platform = "mqtt"; + name = "Zigbee2mqtt Version"; + state_topic = "${prefix}/bridge/config"; + value_template = "{{ value_json.version }}"; + icon = "mdi:zigbee"; + } + # Sensor for Showing the Coordinator Version + { + platform = "mqtt"; + name = "Coordinator Version"; + state_topic = "${prefix}/bridge/config"; + value_template = "{{ value_json.coordinator }}"; + icon = "mdi:chip"; + } + ]; + binary_sensor = + (router_bin "router1") + ++ (router_bin "router2"); + switch = [ + { + platform = "mqtt"; + name = "Zigbee2mqtt Main join"; + state_topic = "${prefix}/bridge/config/permit_join"; + command_topic = "${prefix}/bridge/config/permit_join"; + payload_on = "true"; + payload_off = "false"; + } + ]; + automation = [ + { + alias = "Zigbee2mqtt Log Level"; + initial_state = "on"; + trigger = { + platform = "state"; + entity_id = "input_select.zigbee2mqtt_log_level"; + }; + action = [ + { + service = "mqtt.publish"; + data = { + payload_template = "{{ states('input_select.zigbee2mqtt_log_level') }}"; + topic = "${prefix}/bridge/config/log_level"; + }; + } + ]; + } +# Automation to start timer when enable join is turned on + { + id = "zigbee_join_enabled"; + alias = "Zigbee Join Enabled"; + hide_entity = "true"; + trigger = + { + platform = "state"; + entity_id = "switch.zigbee2mqtt_main_join"; + to = "on"; + }; + action = + { + service = "timer.start"; + entity_id = "timer.zigbee_permit_join"; + }; + } +# # Automation to stop timer when switch turned off and turn off switch when timer finished + { + id = "zigbee_join_disabled"; + alias = "Zigbee Join Disabled"; + hide_entity = "true"; + trigger = [ + { + platform = "event"; + event_type = "timer.finished"; + event_data.entity_id = "timer.zigbee_permit_join"; + } + { + platform = "state"; + entity_id = "switch.zigbee2mqtt_main_join"; + to = "off"; + } + ]; + action = [ + { service = "timer.cancel"; + data.entity_id = "timer.zigbee_permit_join"; + } + { service = "switch.turn_off"; + entity_id = "switch.zigbee2mqtt_main_join"; + } + ]; + } + ]; + input_select.zigbee2mqtt_log_level = + { + name = "Zigbee2mqtt Log Level"; + options = [ + "debug" + "info" + "warn" + "error" + ]; + initial = "info"; + icon = "mdi:format-list-bulleted"; + }; + + timer.zigbee_permit_join = + { + name = "Zigbee Time remaining"; + duration = 120; + }; +} diff --git a/makefu/2configs/homeautomation/sensor/outside.nix b/makefu/2configs/homeautomation/sensor/outside.nix new file mode 100644 index 000000000..8436b8de2 --- /dev/null +++ b/makefu/2configs/homeautomation/sensor/outside.nix @@ -0,0 +1,26 @@ +{lib,...}: [ + { platform = "darksky"; + api_key = lib.removeSuffix "\n" + (builtins.readFile ); + language = "de"; + monitored_conditions = [ + "summary" "icon" + "nearest_storm_distance" "precip_probability" + "precip_intensity" + "temperature" # "temperature_high" "temperature_low" + "apparent_temperature" + "hourly_summary" # next 24 hours text + "humidity" + "pressure" + "uv_index" + ]; + units = "si" ; + scan_interval = "00:30:00"; + } + { platform = "luftdaten"; + name = "Muehlhausen"; + show_on_map = true; + sensor_id = "679"; + sensors.monitored_conditions = [ "P1" "P2" ]; + } + ] -- cgit v1.2.3 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/1systems/omo/config.nix | 39 ++- makefu/2configs/ham/default.nix | 225 +++++++++++++++ makefu/2configs/ham/google-muell.nix | 45 +++ makefu/2configs/ham/lib/default.nix | 318 +++++++++++++++++++++ makefu/2configs/ham/mqtt.nix | 24 ++ makefu/2configs/ham/multi/timer.nix | 123 ++++++++ makefu/2configs/ham/multi/zigbee2mqtt.nix | 165 +++++++++++ makefu/2configs/ham/sensor/outside.nix | 26 ++ makefu/2configs/homeautomation/default.nix | 225 --------------- makefu/2configs/homeautomation/google-muell.nix | 45 --- makefu/2configs/homeautomation/lib/default.nix | 318 --------------------- makefu/2configs/homeautomation/mqtt.nix | 24 -- makefu/2configs/homeautomation/multi/timer.nix | 123 -------- .../2configs/homeautomation/multi/zigbee2mqtt.nix | 165 ----------- makefu/2configs/homeautomation/sensor/outside.nix | 26 -- 15 files changed, 943 insertions(+), 948 deletions(-) create mode 100644 makefu/2configs/ham/default.nix create mode 100644 makefu/2configs/ham/google-muell.nix create mode 100644 makefu/2configs/ham/lib/default.nix create mode 100644 makefu/2configs/ham/mqtt.nix create mode 100644 makefu/2configs/ham/multi/timer.nix create mode 100644 makefu/2configs/ham/multi/zigbee2mqtt.nix create mode 100644 makefu/2configs/ham/sensor/outside.nix delete mode 100644 makefu/2configs/homeautomation/default.nix delete mode 100644 makefu/2configs/homeautomation/google-muell.nix delete mode 100644 makefu/2configs/homeautomation/lib/default.nix delete mode 100644 makefu/2configs/homeautomation/mqtt.nix delete mode 100644 makefu/2configs/homeautomation/multi/timer.nix delete mode 100644 makefu/2configs/homeautomation/multi/zigbee2mqtt.nix delete mode 100644 makefu/2configs/homeautomation/sensor/outside.nix diff --git a/makefu/1systems/omo/config.nix b/makefu/1systems/omo/config.nix index 9b9b91a6f..d00d61fdc 100644 --- a/makefu/1systems/omo/config.nix +++ b/makefu/1systems/omo/config.nix @@ -57,7 +57,7 @@ in { # - + # # services { @@ -71,14 +71,9 @@ in { - { - # Risikoübernahme - nixpkgs.config.permittedInsecurePackages = [ - "homeassistant-0.77.2" - ]; - } - - + + + { makefu.ps3netsrv = { enable = true; @@ -120,7 +115,7 @@ in { gid = (import ).genid "share"; members = [ "makefu" "misa" ]; }; - networking.firewall.trustedInterfaces = [ primaryInterface ]; + networking.firewall.trustedInterfaces = [ primaryInterface "docker0" ]; @@ -141,18 +136,18 @@ in { sed-plugin random-emoji ]; }; - krebs.Reaktor.reaktor-bgt = { - nickname = "Reaktor|bgt"; - workdir = "/var/lib/Reaktor/bgt"; - channels = [ "#binaergewitter" ]; - plugins = with pkgs.ReaktorPlugins; - [ titlebot - # stockholm-issue - nixos-version - shack-correct - sed-plugin - random-emoji ]; - }; + #krebs.Reaktor.reaktor-bgt = { + # nickname = "Reaktor|bgt"; + # workdir = "/var/lib/Reaktor/bgt"; + # channels = [ "#binaergewitter" ]; + # plugins = with pkgs.ReaktorPlugins; + # [ titlebot + # # stockholm-issue + # nixos-version + # shack-correct + # sed-plugin + # random-emoji ]; + #}; krebs.build.host = config.krebs.hosts.omo; } diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix new file mode 100644 index 000000000..56acc2d07 --- /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; + }; + +} diff --git a/makefu/2configs/ham/google-muell.nix b/makefu/2configs/ham/google-muell.nix new file mode 100644 index 000000000..c81eae201 --- /dev/null +++ b/makefu/2configs/ham/google-muell.nix @@ -0,0 +1,45 @@ +{ config, lib, pkgs, buildPythonPackage, ... }: +with import ; +let + pkg = pkgs.ampel; + home = "/var/lib/ampel"; + sec = "${toString }/ampel/google-muell.json"; + ampelsec = "${home}/google-muell.json"; + cred = "${toString }/ampel/google-muell-creds.json"; + # TODO: generate this credential file locally + ampelcred = "${home}/google-muell-creds.json"; + 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 }/mqtt/sensor"); + }); +in { + users.users.ampel = { + uid = genid "ampel"; + createHome = true; + isSystemUser = true; + inherit home; + }; + systemd.services.google-muell-ampel = { + description = "Send led change to rgb cubes"; + after = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + User = "ampel"; + ExecStartPre = pkgs.writeDash "copy-ampel-secrets" '' + install -m600 -o ampel ${sec} ${ampelsec} + install -m600 -o ampel ${cred} ${ampelcred} + ''; + 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; + PrivateTmp = true; + }; + }; +} diff --git a/makefu/2configs/ham/lib/default.nix b/makefu/2configs/ham/lib/default.nix new file mode 100644 index 000000000..8bc544310 --- /dev/null +++ b/makefu/2configs/ham/lib/default.nix @@ -0,0 +1,318 @@ +let + prefix = "/ham"; +in +{ + inherit prefix; + say = let + # returns a list of actions to be performed on an mpd to say something + tts = { message, entity }: + [ + { + service = "media_player.turn_on"; + data.entity_id = entity; + } + { + service = "media_player.play_media"; + data = { + entity_id = entity; + media_content_type = "playlist"; + media_content_id = "ansage"; + }; + } + { + service = "media_player.turn_on"; + data.entity_id = entity; + } + { delay.seconds = 8; } + { + service = "tts.say"; + entity_id = entity; + data_template = { + inherit message; + language = "de"; + }; + } + ]; + in + { + firetv = message: tts { + inherit message; + entity = "firetv"; + }; + }; + zigbee = let + prefix = "/ham/zigbee"; + in + { + inherit prefix; + state = name: { + platform = "mqtt"; + name = "zigbee ${name} connectivity"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + payload_on = true; + payload_off = false; + value_template = "{{ value_json.state }}"; + device_class = "connectivity"; + }; + battery = name: { + platform = "mqtt"; + name = "zigbee ${name} battery"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + unit_of_measurement = "%"; + device_class = "battery"; + value_template = "{{ value_json.battery }}"; + }; + linkquality = name: { + platform = "mqtt"; + name = "zigbee ${name} linkquality"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + unit_of_measurement = "-"; + value_template = "{{ value_json.linkquality }}"; + }; + temperature = name: { + platform = "mqtt"; + name = "zigbee ${name} temperature"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + unit_of_measurement = "°C"; + device_class = "temperature"; + value_template = "{{ value_json.temperature }}"; + }; + humidity = name: { + platform = "mqtt"; + name = "zigbee ${name} humidity"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + unit_of_measurement = "%"; + device_class = "humidity"; + value_template = "{{ value_json.humidity }}"; + }; + pressure = name: { + platform = "mqtt"; + state_topic = "${prefix}/${name}"; + name = "zigbee ${name} pressure"; + availability_topic = "${prefix}/bridge/state"; + unit_of_measurement = "hPa"; + device_class = "pressure"; + value_template = "{{ value_json.pressure }}" ; + }; + click = name: + { + platform = "mqtt"; + name = "zigbee ${name} click"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + icon = "mdi:toggle-switch"; + value_template = "{{ value_json.click }}"; + }; + contact = name: { + platform = "mqtt"; + name = "zigbee ${name} contact"; + state_topic = "${prefix}/${name}"; + availability_topic = "${prefix}/bridge/state"; + payload_on = false; + payload_off = true; + value_template = "{{ value_json.contact }}"; + device_class = "door"; + }; + }; + esphome = + { + temp = {host, topic ? "temperature" }: + { + platform = "mqtt"; + name = "${host} Temperature"; + device_class = "temperature"; + unit_of_measurement = "°C"; + icon = "mdi:thermometer"; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + payload_available = "online"; + payload_not_available = "offline"; + }; + hum = {host, topic ? "humidity" }: + { + platform = "mqtt"; + unit_of_measurement = "%"; + icon = "mdi:water-percent"; + device_class = "humidity"; + name = "${host} Humidity"; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + payload_available = "online"; + payload_not_available = "offline"; + }; + # copied from "homeassistant/light/fablab_led/led_ring/config" + led = {host, topic ? "led", name ? host}: + { # name: fablab_led + # topic: led_ring + platform = "mqtt"; + inherit name; + schema = "json"; + brightness = true; + rgb = true; + effect = true; + effect_list = [ # TODO: may be different + "Random" + "Strobe" + "Rainbow" + "Color Wipe" + "Scan" + "Twinkle" + "Fireworks" + "Addressable Flicker" + "None" + ]; + state_topic = "${prefix}/${host}/light/${topic}/state"; + command_topic = "${prefix}/${host}/light/${topic}/command"; + availability_topic = "${prefix}/${host}/status"; + payload_available = "online"; + payload_not_available = "offline"; + qos = 1; + }; + # Feinstaub + dust_25m = { host, name ? "${host} < 2.5µm", topic ? "particulate_matter_25m_concentration" }: + { + platform = "mqtt"; + unit_of_measurement = "µg/m³"; + icon = "mdi:chemical-weapon"; + inherit name; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; + dust_100m = {host, name ? "${host} < 10µm", topic ? "particulate_matter_100m_concentration" }: + { + platform = "mqtt"; + unit_of_measurement = "µg/m³"; + icon = "mdi:chemical-weapon"; + inherit name; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; + ip = {host, name ? "${host} IP", topic ? "ip_address" }: + { + platform = "mqtt"; + inherit name; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; + wifi = {host, name ? "${host} Wifi Signal", topic ? "wifi_signal" }: + { + platform = "mqtt"; + unit_of_measurement = "dB"; + icon = "mdi:wifi"; + inherit name; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; + switch = {host, name ? "${host} Button", topic ? "btn" }: + # host: ampel + # name: Button 1 + # topic: btn1 + { + inherit name; + platform = "mqtt"; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + command_topic = "${prefix}/${host}/switch/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; + }; + tasmota = + { + plug = {host, name ? host, topic ? host}: + { + platform = "mqtt"; + inherit name; + state_topic = "sonoff/stat/${topic}/POWER1"; + command_topic = "sonoff/cmnd/${topic}/POWER1"; + availability_topic = "sonoff/tele/${topic}/LWT"; + payload_on= "ON"; + payload_off= "OFF"; + payload_available= "Online"; + payload_not_available= "Offline"; + retain = false; + qos = 1; + }; + am2301 = { name, host, topic?host }: + [ { platform = "mqtt"; + name = "${name} Temperatur"; + state_topic = "${prefix}/${topic}/tele/SENSOR"; + value_template = "{{ value_json.AM2301.Temperature }}"; + unit_of_measurement = "°C"; + } + { platform = "mqtt"; + name = "${name} Luftfeuchtigkeit"; + state_topic = "${prefix}/${topic}/tele/SENSOR"; + value_template = "{{ value_json.AM2301.Humidity }}"; + unit_of_measurement = "%"; + } + ]; + bme = { name, host, topic?host }: + [ { platform = "mqtt"; + name = "${name} Temperatur"; + state_topic = "${prefix}/${topic}/tele/SENSOR"; + value_template = "{{ value_json.BME280.Temperature }}"; + unit_of_measurement = "°C"; + } + { platform = "mqtt"; + name = "${name} Luftfeuchtigkeit"; + state_topic = "${prefix}/${topic}/tele/SENSOR"; + value_template = "{{ value_json.BME280.Humidity }}"; + unit_of_measurement = "%"; + } + { platform = "mqtt"; + name = "${name} Luftdruck"; + state_topic = "${prefix}/${topic}/tele/SENSOR"; + value_template = "{{ value_json.BME280.Pressure }}"; + unit_of_measurement = "hPa"; + } + ]; + rgb = { name, host, topic?host }: + { platform = "mqtt"; + inherit name; + retain = false; + qos = 1; + optimistic = false; + # state + # TODO: currently broken, will not use the custom state topic + #state_topic = "${prefix}/${topic}/stat/POWER"; + state_topic = "${prefix}/${topic}/stat/POWER"; + command_topic = "${prefix}/${topic}/cmnd/POWER"; + availability_topic = "${prefix}/${topic}/tele/LWT"; + payload_on= "ON"; + payload_off= "OFF"; + payload_available= "Online"; + payload_not_available= "Offline"; + # brightness + brightness_state_topic = "${prefix}/${topic}/stat/Dimmer"; + brightness_command_topic = "${prefix}/${topic}/cmnd/Dimmer"; + brightness_value_template = "{{ value_json.Dimmer }}"; + brightness_scale = 100; + # color + rgb_state_topic = "${prefix}/${topic}/stat/Color"; + rgb_command_topic = "${prefix}/${topic}/cmnd/MEM1"; # use enabled rule + rgb_command_mode = "hex"; + rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; + # effects + effect_state_topic = "${prefix}/${topic}/stat/Scheme"; + effect_command_topic = "${prefix}/${topic}/cmnd/Scheme"; + effect_value_template = "{{ value_json.Scheme }}"; + effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ]; +}; + motion = { name, host, topic?host }: + { platform = "mqtt"; + device_class = "motion"; + inherit name; + # TODO: currently broken, will not use the custom state topic + state_topic = "${prefix}/${topic}/stat/POWER"; + payload_on = "ON"; + payload_off = "OFF"; + availability_topic = "${prefix}/${topic}/tele/LWT"; + payload_available = "Online"; + payload_not_available = "Offline"; + }; + }; +} diff --git a/makefu/2configs/ham/mqtt.nix b/makefu/2configs/ham/mqtt.nix new file mode 100644 index 000000000..cd1c328d7 --- /dev/null +++ b/makefu/2configs/ham/mqtt.nix @@ -0,0 +1,24 @@ +{ pkgs, config, ... }: +{ + services.mosquitto = { + enable = true; + host = "0.0.0.0"; + allowAnonymous = false; + checkPasswords = true; + # see /mosquitto + users.sensor = { + hashedPassword = "$6$2DXU7W1bvqXPqxkF$vtdz5KTd/T09hmoc9LjgEGFjvpwQbQth6vlVcr5hJNLgcBHv4U03YCKC8TKXbmQAa8xiJ76xJIg25kcL+KI3tg=="; + acl = [ "topic readwrite #" ]; + }; + users.hass = { + hashedPassword = "$6$SHuYGrE5kPSUc/hu$EomZ0KBy+vkxLt/6eJkrSBjYblCCeMjhDfUd2mwqXYJ4XsP8hGmZ59mMlmBCd3AvlFYQxb4DT/j3TYlrqo7cDA=="; + acl = [ "topic readwrite #" ]; + }; + users.stats = { + hashedPassword = "$6$j4H7KXD/YZgvgNmL$8e9sUKRXowDqJLOVgzCdDrvDE3+4dGgU6AngfAeN/rleGOgaMhee2Mbg2KS5TC1TOW3tYbk9NhjLYtjBgfRkoA=="; + acl = [ "topic read #" ]; + }; + }; + environment.systemPackages = [ pkgs.mosquitto ]; + # port open via trusted interface +} diff --git a/makefu/2configs/ham/multi/timer.nix b/makefu/2configs/ham/multi/timer.nix new file mode 100644 index 000000000..eafb7841d --- /dev/null +++ b/makefu/2configs/ham/multi/timer.nix @@ -0,0 +1,123 @@ +# Provides: +# timer +# automation +# script + +# Needs: +# sensor.zigbee_btn1_click +# notify.telegrambot +let + button = "sensor.zigbee_btn1_click"; +in { + timer.kurzzeitwecker = + { + name = "Zigbee Kurzzeitwecker"; + duration = 300; + }; + script.add_5_minutes_to_kurzzeitwecker = + { + alias = "Add 5 minutes to kurzzeitwecker"; + sequence = [ + { service = "timer.pause"; + entity_id = "timer.kurzzeitwecker"; + } + { service = "timer.start"; + data_template = { + entity_id = "timer.kurzzeitwecker"; + duration = '' + {% set r = state_attr('timer.wecker', 'remaining') ~ '-0000' %} + {% set t = strptime(r, '%H:%M:%S.%f%z') %} + {{ (as_timestamp(t) + 300) | timestamp_custom('%H:%M:%S', false) }} + ''; + }; + } + ]; + }; + automation = + [ + { + alias = "Start Timer 5min"; + trigger = { + platform = "state"; + entity_id = button; + to = "single"; + }; + condition = + { condition = "state"; + entity_id = "timer.kurzzeitwecker"; + state = "idle"; + }; + + action = [ + { service = "timer.start"; + entity_id = "timer.kurzzeitwecker"; + duration = "00:05:00"; + } + { + service = "notify.telegrambot"; + data = { + title = "Timer gestartet"; + message = "Timer auf 5 minuten gestellt"; + }; + } + ]; + } + { + alias = "Start Timer 10min"; + trigger = { + platform = "state"; + entity_id = button; + to = "double"; + }; + condition = + { + condition = "state"; + entity_id = "timer.kurzzeitwecker"; + state = "idle"; + }; + action = + [ + { + service = "timer.start"; + entity_id = "timer.kurzzeitwecker"; + duration = "00:10:00"; + } + { + service = "notify.telegrambot"; + data = { + title = "Timer gestartet"; + message = "Timer auf 10 minuten gestellt"; + }; + } + ]; + } + { + alias = "Stop timer on triple click"; + trigger = + { + platform = "state"; + entity_id = button; + to = "triple"; + }; + condition = + { + condition = "state"; + entity_id = "timer.kurzzeitwecker"; + state = "active"; + }; + + action = [ + { + service = "timer.stop"; + entity_id = "timer.kurzzeitwecker"; + } + { + service = "notify.telegrambot"; + data = { + title = "Timer gestoppt"; + }; + } + ]; + } + ]; +} diff --git a/makefu/2configs/ham/multi/zigbee2mqtt.nix b/makefu/2configs/ham/multi/zigbee2mqtt.nix new file mode 100644 index 000000000..ba81b1298 --- /dev/null +++ b/makefu/2configs/ham/multi/zigbee2mqtt.nix @@ -0,0 +1,165 @@ +# provides: +# switch +# automation +# binary_sensor +# sensor +# input_select +# timer +let + inherit (import ../lib) zigbee; + prefix = zigbee.prefix; + xiaomi_btn = name: [ + (zigbee.battery name) + (zigbee.linkquality name) + (zigbee.click name) + ]; + xiaomi_temp = name: [ + (zigbee.battery name) + (zigbee.linkquality name) + (zigbee.temperature name) + (zigbee.humidity name) + (zigbee.pressure name) + ]; + xiaomi_contact = name: [ + (zigbee.battery name) + (zigbee.linkquality name) + (zigbee.contact name) + ]; + router_link = name: [ + (zigbee.linkquality name) + ]; + router_bin = name: [ + (zigbee.state name) + ]; +in { + sensor = + (xiaomi_btn "btn1") + ++ (xiaomi_btn "btn2") + ++ (xiaomi_btn "btn3") + + ++ (xiaomi_temp "temp1") + ++ (xiaomi_temp "temp2") + ++ (xiaomi_temp "temp3") + + ++ (router_link "router1") + ++ (router_link "router2") + + ++ [ + # Sensor for monitoring the bridge state + { + platform = "mqtt"; + name = "Zigbee2mqtt Bridge state"; + state_topic = "${prefix}/bridge/state"; + icon = "mdi:router-wireless"; + } + # Sensor for Showing the Zigbee2mqtt Version + { + platform = "mqtt"; + name = "Zigbee2mqtt Version"; + state_topic = "${prefix}/bridge/config"; + value_template = "{{ value_json.version }}"; + icon = "mdi:zigbee"; + } + # Sensor for Showing the Coordinator Version + { + platform = "mqtt"; + name = "Coordinator Version"; + state_topic = "${prefix}/bridge/config"; + value_template = "{{ value_json.coordinator }}"; + icon = "mdi:chip"; + } + ]; + binary_sensor = + (router_bin "router1") + ++ (router_bin "router2"); + switch = [ + { + platform = "mqtt"; + name = "Zigbee2mqtt Main join"; + state_topic = "${prefix}/bridge/config/permit_join"; + command_topic = "${prefix}/bridge/config/permit_join"; + payload_on = "true"; + payload_off = "false"; + } + ]; + automation = [ + { + alias = "Zigbee2mqtt Log Level"; + initial_state = "on"; + trigger = { + platform = "state"; + entity_id = "input_select.zigbee2mqtt_log_level"; + }; + action = [ + { + service = "mqtt.publish"; + data = { + payload_template = "{{ states('input_select.zigbee2mqtt_log_level') }}"; + topic = "${prefix}/bridge/config/log_level"; + }; + } + ]; + } +# Automation to start timer when enable join is turned on + { + id = "zigbee_join_enabled"; + alias = "Zigbee Join Enabled"; + hide_entity = "true"; + trigger = + { + platform = "state"; + entity_id = "switch.zigbee2mqtt_main_join"; + to = "on"; + }; + action = + { + service = "timer.start"; + entity_id = "timer.zigbee_permit_join"; + }; + } +# # Automation to stop timer when switch turned off and turn off switch when timer finished + { + id = "zigbee_join_disabled"; + alias = "Zigbee Join Disabled"; + hide_entity = "true"; + trigger = [ + { + platform = "event"; + event_type = "timer.finished"; + event_data.entity_id = "timer.zigbee_permit_join"; + } + { + platform = "state"; + entity_id = "switch.zigbee2mqtt_main_join"; + to = "off"; + } + ]; + action = [ + { service = "timer.cancel"; + data.entity_id = "timer.zigbee_permit_join"; + } + { service = "switch.turn_off"; + entity_id = "switch.zigbee2mqtt_main_join"; + } + ]; + } + ]; + input_select.zigbee2mqtt_log_level = + { + name = "Zigbee2mqtt Log Level"; + options = [ + "debug" + "info" + "warn" + "error" + ]; + initial = "info"; + icon = "mdi:format-list-bulleted"; + }; + + timer.zigbee_permit_join = + { + name = "Zigbee Time remaining"; + duration = 120; + }; +} diff --git a/makefu/2configs/ham/sensor/outside.nix b/makefu/2configs/ham/sensor/outside.nix new file mode 100644 index 000000000..8436b8de2 --- /dev/null +++ b/makefu/2configs/ham/sensor/outside.nix @@ -0,0 +1,26 @@ +{lib,...}: [ + { platform = "darksky"; + api_key = lib.removeSuffix "\n" + (builtins.readFile ); + language = "de"; + monitored_conditions = [ + "summary" "icon" + "nearest_storm_distance" "precip_probability" + "precip_intensity" + "temperature" # "temperature_high" "temperature_low" + "apparent_temperature" + "hourly_summary" # next 24 hours text + "humidity" + "pressure" + "uv_index" + ]; + units = "si" ; + scan_interval = "00:30:00"; + } + { platform = "luftdaten"; + name = "Muehlhausen"; + show_on_map = true; + sensor_id = "679"; + sensors.monitored_conditions = [ "P1" "P2" ]; + } + ] diff --git a/makefu/2configs/homeautomation/default.nix b/makefu/2configs/homeautomation/default.nix deleted file mode 100644 index 56acc2d07..000000000 --- a/makefu/2configs/homeautomation/default.nix +++ /dev/null @@ -1,225 +0,0 @@ -{ 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; - }; - -} diff --git a/makefu/2configs/homeautomation/google-muell.nix b/makefu/2configs/homeautomation/google-muell.nix deleted file mode 100644 index c81eae201..000000000 --- a/makefu/2configs/homeautomation/google-muell.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ config, lib, pkgs, buildPythonPackage, ... }: -with import ; -let - pkg = pkgs.ampel; - home = "/var/lib/ampel"; - sec = "${toString }/ampel/google-muell.json"; - ampelsec = "${home}/google-muell.json"; - cred = "${toString }/ampel/google-muell-creds.json"; - # TODO: generate this credential file locally - ampelcred = "${home}/google-muell-creds.json"; - 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 }/mqtt/sensor"); - }); -in { - users.users.ampel = { - uid = genid "ampel"; - createHome = true; - isSystemUser = true; - inherit home; - }; - systemd.services.google-muell-ampel = { - description = "Send led change to rgb cubes"; - after = [ "network-online.target" ]; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - User = "ampel"; - ExecStartPre = pkgs.writeDash "copy-ampel-secrets" '' - install -m600 -o ampel ${sec} ${ampelsec} - install -m600 -o ampel ${cred} ${ampelcred} - ''; - 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; - PrivateTmp = true; - }; - }; -} diff --git a/makefu/2configs/homeautomation/lib/default.nix b/makefu/2configs/homeautomation/lib/default.nix deleted file mode 100644 index 8bc544310..000000000 --- a/makefu/2configs/homeautomation/lib/default.nix +++ /dev/null @@ -1,318 +0,0 @@ -let - prefix = "/ham"; -in -{ - inherit prefix; - say = let - # returns a list of actions to be performed on an mpd to say something - tts = { message, entity }: - [ - { - service = "media_player.turn_on"; - data.entity_id = entity; - } - { - service = "media_player.play_media"; - data = { - entity_id = entity; - media_content_type = "playlist"; - media_content_id = "ansage"; - }; - } - { - service = "media_player.turn_on"; - data.entity_id = entity; - } - { delay.seconds = 8; } - { - service = "tts.say"; - entity_id = entity; - data_template = { - inherit message; - language = "de"; - }; - } - ]; - in - { - firetv = message: tts { - inherit message; - entity = "firetv"; - }; - }; - zigbee = let - prefix = "/ham/zigbee"; - in - { - inherit prefix; - state = name: { - platform = "mqtt"; - name = "zigbee ${name} connectivity"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - payload_on = true; - payload_off = false; - value_template = "{{ value_json.state }}"; - device_class = "connectivity"; - }; - battery = name: { - platform = "mqtt"; - name = "zigbee ${name} battery"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - unit_of_measurement = "%"; - device_class = "battery"; - value_template = "{{ value_json.battery }}"; - }; - linkquality = name: { - platform = "mqtt"; - name = "zigbee ${name} linkquality"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - unit_of_measurement = "-"; - value_template = "{{ value_json.linkquality }}"; - }; - temperature = name: { - platform = "mqtt"; - name = "zigbee ${name} temperature"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - unit_of_measurement = "°C"; - device_class = "temperature"; - value_template = "{{ value_json.temperature }}"; - }; - humidity = name: { - platform = "mqtt"; - name = "zigbee ${name} humidity"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - unit_of_measurement = "%"; - device_class = "humidity"; - value_template = "{{ value_json.humidity }}"; - }; - pressure = name: { - platform = "mqtt"; - state_topic = "${prefix}/${name}"; - name = "zigbee ${name} pressure"; - availability_topic = "${prefix}/bridge/state"; - unit_of_measurement = "hPa"; - device_class = "pressure"; - value_template = "{{ value_json.pressure }}" ; - }; - click = name: - { - platform = "mqtt"; - name = "zigbee ${name} click"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - icon = "mdi:toggle-switch"; - value_template = "{{ value_json.click }}"; - }; - contact = name: { - platform = "mqtt"; - name = "zigbee ${name} contact"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - payload_on = false; - payload_off = true; - value_template = "{{ value_json.contact }}"; - device_class = "door"; - }; - }; - esphome = - { - temp = {host, topic ? "temperature" }: - { - platform = "mqtt"; - name = "${host} Temperature"; - device_class = "temperature"; - unit_of_measurement = "°C"; - icon = "mdi:thermometer"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - payload_available = "online"; - payload_not_available = "offline"; - }; - hum = {host, topic ? "humidity" }: - { - platform = "mqtt"; - unit_of_measurement = "%"; - icon = "mdi:water-percent"; - device_class = "humidity"; - name = "${host} Humidity"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - payload_available = "online"; - payload_not_available = "offline"; - }; - # copied from "homeassistant/light/fablab_led/led_ring/config" - led = {host, topic ? "led", name ? host}: - { # name: fablab_led - # topic: led_ring - platform = "mqtt"; - inherit name; - schema = "json"; - brightness = true; - rgb = true; - effect = true; - effect_list = [ # TODO: may be different - "Random" - "Strobe" - "Rainbow" - "Color Wipe" - "Scan" - "Twinkle" - "Fireworks" - "Addressable Flicker" - "None" - ]; - state_topic = "${prefix}/${host}/light/${topic}/state"; - command_topic = "${prefix}/${host}/light/${topic}/command"; - availability_topic = "${prefix}/${host}/status"; - payload_available = "online"; - payload_not_available = "offline"; - qos = 1; - }; - # Feinstaub - dust_25m = { host, name ? "${host} < 2.5µm", topic ? "particulate_matter_25m_concentration" }: - { - platform = "mqtt"; - unit_of_measurement = "µg/m³"; - icon = "mdi:chemical-weapon"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - dust_100m = {host, name ? "${host} < 10µm", topic ? "particulate_matter_100m_concentration" }: - { - platform = "mqtt"; - unit_of_measurement = "µg/m³"; - icon = "mdi:chemical-weapon"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - ip = {host, name ? "${host} IP", topic ? "ip_address" }: - { - platform = "mqtt"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - wifi = {host, name ? "${host} Wifi Signal", topic ? "wifi_signal" }: - { - platform = "mqtt"; - unit_of_measurement = "dB"; - icon = "mdi:wifi"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - switch = {host, name ? "${host} Button", topic ? "btn" }: - # host: ampel - # name: Button 1 - # topic: btn1 - { - inherit name; - platform = "mqtt"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - command_topic = "${prefix}/${host}/switch/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - }; - tasmota = - { - plug = {host, name ? host, topic ? host}: - { - platform = "mqtt"; - inherit name; - state_topic = "sonoff/stat/${topic}/POWER1"; - command_topic = "sonoff/cmnd/${topic}/POWER1"; - availability_topic = "sonoff/tele/${topic}/LWT"; - payload_on= "ON"; - payload_off= "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - retain = false; - qos = 1; - }; - am2301 = { name, host, topic?host }: - [ { platform = "mqtt"; - name = "${name} Temperatur"; - state_topic = "${prefix}/${topic}/tele/SENSOR"; - value_template = "{{ value_json.AM2301.Temperature }}"; - unit_of_measurement = "°C"; - } - { platform = "mqtt"; - name = "${name} Luftfeuchtigkeit"; - state_topic = "${prefix}/${topic}/tele/SENSOR"; - value_template = "{{ value_json.AM2301.Humidity }}"; - unit_of_measurement = "%"; - } - ]; - bme = { name, host, topic?host }: - [ { platform = "mqtt"; - name = "${name} Temperatur"; - state_topic = "${prefix}/${topic}/tele/SENSOR"; - value_template = "{{ value_json.BME280.Temperature }}"; - unit_of_measurement = "°C"; - } - { platform = "mqtt"; - name = "${name} Luftfeuchtigkeit"; - state_topic = "${prefix}/${topic}/tele/SENSOR"; - value_template = "{{ value_json.BME280.Humidity }}"; - unit_of_measurement = "%"; - } - { platform = "mqtt"; - name = "${name} Luftdruck"; - state_topic = "${prefix}/${topic}/tele/SENSOR"; - value_template = "{{ value_json.BME280.Pressure }}"; - unit_of_measurement = "hPa"; - } - ]; - rgb = { name, host, topic?host }: - { platform = "mqtt"; - inherit name; - retain = false; - qos = 1; - optimistic = false; - # state - # TODO: currently broken, will not use the custom state topic - #state_topic = "${prefix}/${topic}/stat/POWER"; - state_topic = "${prefix}/${topic}/stat/POWER"; - command_topic = "${prefix}/${topic}/cmnd/POWER"; - availability_topic = "${prefix}/${topic}/tele/LWT"; - payload_on= "ON"; - payload_off= "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - # brightness - brightness_state_topic = "${prefix}/${topic}/stat/Dimmer"; - brightness_command_topic = "${prefix}/${topic}/cmnd/Dimmer"; - brightness_value_template = "{{ value_json.Dimmer }}"; - brightness_scale = 100; - # color - rgb_state_topic = "${prefix}/${topic}/stat/Color"; - rgb_command_topic = "${prefix}/${topic}/cmnd/MEM1"; # use enabled rule - rgb_command_mode = "hex"; - rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; - # effects - effect_state_topic = "${prefix}/${topic}/stat/Scheme"; - effect_command_topic = "${prefix}/${topic}/cmnd/Scheme"; - effect_value_template = "{{ value_json.Scheme }}"; - effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ]; -}; - motion = { name, host, topic?host }: - { platform = "mqtt"; - device_class = "motion"; - inherit name; - # TODO: currently broken, will not use the custom state topic - state_topic = "${prefix}/${topic}/stat/POWER"; - payload_on = "ON"; - payload_off = "OFF"; - availability_topic = "${prefix}/${topic}/tele/LWT"; - payload_available = "Online"; - payload_not_available = "Offline"; - }; - }; -} diff --git a/makefu/2configs/homeautomation/mqtt.nix b/makefu/2configs/homeautomation/mqtt.nix deleted file mode 100644 index cd1c328d7..000000000 --- a/makefu/2configs/homeautomation/mqtt.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ pkgs, config, ... }: -{ - services.mosquitto = { - enable = true; - host = "0.0.0.0"; - allowAnonymous = false; - checkPasswords = true; - # see /mosquitto - users.sensor = { - hashedPassword = "$6$2DXU7W1bvqXPqxkF$vtdz5KTd/T09hmoc9LjgEGFjvpwQbQth6vlVcr5hJNLgcBHv4U03YCKC8TKXbmQAa8xiJ76xJIg25kcL+KI3tg=="; - acl = [ "topic readwrite #" ]; - }; - users.hass = { - hashedPassword = "$6$SHuYGrE5kPSUc/hu$EomZ0KBy+vkxLt/6eJkrSBjYblCCeMjhDfUd2mwqXYJ4XsP8hGmZ59mMlmBCd3AvlFYQxb4DT/j3TYlrqo7cDA=="; - acl = [ "topic readwrite #" ]; - }; - users.stats = { - hashedPassword = "$6$j4H7KXD/YZgvgNmL$8e9sUKRXowDqJLOVgzCdDrvDE3+4dGgU6AngfAeN/rleGOgaMhee2Mbg2KS5TC1TOW3tYbk9NhjLYtjBgfRkoA=="; - acl = [ "topic read #" ]; - }; - }; - environment.systemPackages = [ pkgs.mosquitto ]; - # port open via trusted interface -} diff --git a/makefu/2configs/homeautomation/multi/timer.nix b/makefu/2configs/homeautomation/multi/timer.nix deleted file mode 100644 index eafb7841d..000000000 --- a/makefu/2configs/homeautomation/multi/timer.nix +++ /dev/null @@ -1,123 +0,0 @@ -# Provides: -# timer -# automation -# script - -# Needs: -# sensor.zigbee_btn1_click -# notify.telegrambot -let - button = "sensor.zigbee_btn1_click"; -in { - timer.kurzzeitwecker = - { - name = "Zigbee Kurzzeitwecker"; - duration = 300; - }; - script.add_5_minutes_to_kurzzeitwecker = - { - alias = "Add 5 minutes to kurzzeitwecker"; - sequence = [ - { service = "timer.pause"; - entity_id = "timer.kurzzeitwecker"; - } - { service = "timer.start"; - data_template = { - entity_id = "timer.kurzzeitwecker"; - duration = '' - {% set r = state_attr('timer.wecker', 'remaining') ~ '-0000' %} - {% set t = strptime(r, '%H:%M:%S.%f%z') %} - {{ (as_timestamp(t) + 300) | timestamp_custom('%H:%M:%S', false) }} - ''; - }; - } - ]; - }; - automation = - [ - { - alias = "Start Timer 5min"; - trigger = { - platform = "state"; - entity_id = button; - to = "single"; - }; - condition = - { condition = "state"; - entity_id = "timer.kurzzeitwecker"; - state = "idle"; - }; - - action = [ - { service = "timer.start"; - entity_id = "timer.kurzzeitwecker"; - duration = "00:05:00"; - } - { - service = "notify.telegrambot"; - data = { - title = "Timer gestartet"; - message = "Timer auf 5 minuten gestellt"; - }; - } - ]; - } - { - alias = "Start Timer 10min"; - trigger = { - platform = "state"; - entity_id = button; - to = "double"; - }; - condition = - { - condition = "state"; - entity_id = "timer.kurzzeitwecker"; - state = "idle"; - }; - action = - [ - { - service = "timer.start"; - entity_id = "timer.kurzzeitwecker"; - duration = "00:10:00"; - } - { - service = "notify.telegrambot"; - data = { - title = "Timer gestartet"; - message = "Timer auf 10 minuten gestellt"; - }; - } - ]; - } - { - alias = "Stop timer on triple click"; - trigger = - { - platform = "state"; - entity_id = button; - to = "triple"; - }; - condition = - { - condition = "state"; - entity_id = "timer.kurzzeitwecker"; - state = "active"; - }; - - action = [ - { - service = "timer.stop"; - entity_id = "timer.kurzzeitwecker"; - } - { - service = "notify.telegrambot"; - data = { - title = "Timer gestoppt"; - }; - } - ]; - } - ]; -} diff --git a/makefu/2configs/homeautomation/multi/zigbee2mqtt.nix b/makefu/2configs/homeautomation/multi/zigbee2mqtt.nix deleted file mode 100644 index ba81b1298..000000000 --- a/makefu/2configs/homeautomation/multi/zigbee2mqtt.nix +++ /dev/null @@ -1,165 +0,0 @@ -# provides: -# switch -# automation -# binary_sensor -# sensor -# input_select -# timer -let - inherit (import ../lib) zigbee; - prefix = zigbee.prefix; - xiaomi_btn = name: [ - (zigbee.battery name) - (zigbee.linkquality name) - (zigbee.click name) - ]; - xiaomi_temp = name: [ - (zigbee.battery name) - (zigbee.linkquality name) - (zigbee.temperature name) - (zigbee.humidity name) - (zigbee.pressure name) - ]; - xiaomi_contact = name: [ - (zigbee.battery name) - (zigbee.linkquality name) - (zigbee.contact name) - ]; - router_link = name: [ - (zigbee.linkquality name) - ]; - router_bin = name: [ - (zigbee.state name) - ]; -in { - sensor = - (xiaomi_btn "btn1") - ++ (xiaomi_btn "btn2") - ++ (xiaomi_btn "btn3") - - ++ (xiaomi_temp "temp1") - ++ (xiaomi_temp "temp2") - ++ (xiaomi_temp "temp3") - - ++ (router_link "router1") - ++ (router_link "router2") - - ++ [ - # Sensor for monitoring the bridge state - { - platform = "mqtt"; - name = "Zigbee2mqtt Bridge state"; - state_topic = "${prefix}/bridge/state"; - icon = "mdi:router-wireless"; - } - # Sensor for Showing the Zigbee2mqtt Version - { - platform = "mqtt"; - name = "Zigbee2mqtt Version"; - state_topic = "${prefix}/bridge/config"; - value_template = "{{ value_json.version }}"; - icon = "mdi:zigbee"; - } - # Sensor for Showing the Coordinator Version - { - platform = "mqtt"; - name = "Coordinator Version"; - state_topic = "${prefix}/bridge/config"; - value_template = "{{ value_json.coordinator }}"; - icon = "mdi:chip"; - } - ]; - binary_sensor = - (router_bin "router1") - ++ (router_bin "router2"); - switch = [ - { - platform = "mqtt"; - name = "Zigbee2mqtt Main join"; - state_topic = "${prefix}/bridge/config/permit_join"; - command_topic = "${prefix}/bridge/config/permit_join"; - payload_on = "true"; - payload_off = "false"; - } - ]; - automation = [ - { - alias = "Zigbee2mqtt Log Level"; - initial_state = "on"; - trigger = { - platform = "state"; - entity_id = "input_select.zigbee2mqtt_log_level"; - }; - action = [ - { - service = "mqtt.publish"; - data = { - payload_template = "{{ states('input_select.zigbee2mqtt_log_level') }}"; - topic = "${prefix}/bridge/config/log_level"; - }; - } - ]; - } -# Automation to start timer when enable join is turned on - { - id = "zigbee_join_enabled"; - alias = "Zigbee Join Enabled"; - hide_entity = "true"; - trigger = - { - platform = "state"; - entity_id = "switch.zigbee2mqtt_main_join"; - to = "on"; - }; - action = - { - service = "timer.start"; - entity_id = "timer.zigbee_permit_join"; - }; - } -# # Automation to stop timer when switch turned off and turn off switch when timer finished - { - id = "zigbee_join_disabled"; - alias = "Zigbee Join Disabled"; - hide_entity = "true"; - trigger = [ - { - platform = "event"; - event_type = "timer.finished"; - event_data.entity_id = "timer.zigbee_permit_join"; - } - { - platform = "state"; - entity_id = "switch.zigbee2mqtt_main_join"; - to = "off"; - } - ]; - action = [ - { service = "timer.cancel"; - data.entity_id = "timer.zigbee_permit_join"; - } - { service = "switch.turn_off"; - entity_id = "switch.zigbee2mqtt_main_join"; - } - ]; - } - ]; - input_select.zigbee2mqtt_log_level = - { - name = "Zigbee2mqtt Log Level"; - options = [ - "debug" - "info" - "warn" - "error" - ]; - initial = "info"; - icon = "mdi:format-list-bulleted"; - }; - - timer.zigbee_permit_join = - { - name = "Zigbee Time remaining"; - duration = 120; - }; -} diff --git a/makefu/2configs/homeautomation/sensor/outside.nix b/makefu/2configs/homeautomation/sensor/outside.nix deleted file mode 100644 index 8436b8de2..000000000 --- a/makefu/2configs/homeautomation/sensor/outside.nix +++ /dev/null @@ -1,26 +0,0 @@ -{lib,...}: [ - { platform = "darksky"; - api_key = lib.removeSuffix "\n" - (builtins.readFile ); - language = "de"; - monitored_conditions = [ - "summary" "icon" - "nearest_storm_distance" "precip_probability" - "precip_intensity" - "temperature" # "temperature_high" "temperature_low" - "apparent_temperature" - "hourly_summary" # next 24 hours text - "humidity" - "pressure" - "uv_index" - ]; - units = "si" ; - scan_interval = "00:30:00"; - } - { platform = "luftdaten"; - name = "Muehlhausen"; - show_on_map = true; - sensor_id = "679"; - sensors.monitored_conditions = [ "P1" "P2" ]; - } - ] -- cgit v1.2.3 From 160e9d1843b3e8c6d503a0ae023df31a27f7880c Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 12 Feb 2020 07:55:17 +0100 Subject: ma gum: add dns.euer.krebsco.de domain naim --- krebs/3modules/makefu/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/krebs/3modules/makefu/default.nix b/krebs/3modules/makefu/default.nix index dcfee59b3..6c2fd6245 100644 --- a/krebs/3modules/makefu/default.nix +++ b/krebs/3modules/makefu/default.nix @@ -171,6 +171,7 @@ in { cgit.euer IN A ${nets.internet.ip4.addr} dl.euer IN A ${nets.internet.ip4.addr} dockerhub IN A ${nets.internet.ip4.addr} + dns.euer IN A ${nets.internet.ip4.addr} euer IN A ${nets.internet.ip4.addr} euer IN MX 1 aspmx.l.google.com. ghook IN A ${nets.internet.ip4.addr} -- cgit v1.2.3 From 0509f857414ef1ca9b84f6cec29985ea50ecf579 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 12 Feb 2020 07:55:39 +0100 Subject: ma gum: sort dnsnames --- krebs/3modules/makefu/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/krebs/3modules/makefu/default.nix b/krebs/3modules/makefu/default.nix index 6c2fd6245..56d313528 100644 --- a/krebs/3modules/makefu/default.nix +++ b/krebs/3modules/makefu/default.nix @@ -164,14 +164,15 @@ in { ci = true; extraZones = { "krebsco.de" = '' + bookmark.euer IN A ${nets.internet.ip4.addr} boot IN A ${nets.internet.ip4.addr} boot.euer IN A ${nets.internet.ip4.addr} cache.euer IN A ${nets.internet.ip4.addr} cache.gum IN A ${nets.internet.ip4.addr} cgit.euer IN A ${nets.internet.ip4.addr} dl.euer IN A ${nets.internet.ip4.addr} - dockerhub IN A ${nets.internet.ip4.addr} dns.euer IN A ${nets.internet.ip4.addr} + dockerhub IN A ${nets.internet.ip4.addr} euer IN A ${nets.internet.ip4.addr} euer IN MX 1 aspmx.l.google.com. ghook IN A ${nets.internet.ip4.addr} @@ -179,7 +180,9 @@ in { gold IN A ${nets.internet.ip4.addr} graph IN A ${nets.internet.ip4.addr} gum IN A ${nets.internet.ip4.addr} + io IN NS gum.krebsco.de. iso.euer IN A ${nets.internet.ip4.addr} + mediengewitter IN CNAME over.dose.io. mon.euer IN A ${nets.internet.ip4.addr} netdata.euer IN A ${nets.internet.ip4.addr} nixos.unstable IN CNAME krebscode.github.io. @@ -190,9 +193,6 @@ in { wg.euer IN A ${nets.internet.ip4.addr} wiki.euer IN A ${nets.internet.ip4.addr} wikisearch IN A ${nets.internet.ip4.addr} - bookmark.euer IN A ${nets.internet.ip4.addr} - io IN NS gum.krebsco.de. - mediengewitter IN CNAME over.dose.io. ''; }; cores = 8; -- cgit v1.2.3 From 2d25196a960b6a4e33d8b9f365db26192034fc45 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 19 Feb 2020 13:51:03 +0100 Subject: ma pkgs.pico2wave: use upstream --- makefu/5pkgs/pico2wave/default.nix | 51 -------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 makefu/5pkgs/pico2wave/default.nix diff --git a/makefu/5pkgs/pico2wave/default.nix b/makefu/5pkgs/pico2wave/default.nix deleted file mode 100644 index b2d18fee1..000000000 --- a/makefu/5pkgs/pico2wave/default.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ stdenv, lib, fetchurl -, popt -, libredirect -, dpkg -, makeWrapper -, autoPatchelfHook -, ... -}: -# https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=svox-pico-bin -let - pkgrel="8"; - _arch = "amd64"; -in -stdenv.mkDerivation rec { - name = "pico2wave"; # svox-pico-bin - version = "1.0+git20130326"; - srcs = [ - (fetchurl { url = "http://mirrors.kernel.org/ubuntu/pool/multiverse/s/svox/libttspico0_${version}-${pkgrel}_${_arch}.deb"; sha256 = "0b8r7r8by5kamnm960bsicimnj1a40ghy3475nzy1jvwj5xgqhrj"; }) - (fetchurl { url = "http://mirrors.kernel.org/ubuntu/pool/multiverse/s/svox/libttspico-dev_${version}-${pkgrel}_${_arch}.deb"; sha256 = "1knjiwi117h02nbf7k6ll080vl65gxwx3rpj0fq5xkvxbqpjjbvz"; }) - (fetchurl { url = "http://mirrors.kernel.org/ubuntu/pool/multiverse/s/svox/libttspico-data_${version}-${pkgrel}_all.deb"; sha256 = "0k0x5jh5qzzasrg766pfmls3ksj18wwdbssysvpxkq98aqg4fgmx"; }) - (fetchurl { url = "http://mirrors.kernel.org/ubuntu/pool/multiverse/s/svox/libttspico-utils_${version}-${pkgrel}_${_arch}.deb"; sha256 = "11yk25fh4n7qz4xjg0dri68ygc3aapj1bk9cvhcwkfvm46j5lrjv"; }) - ] ; - - nativeBuildInputs = [ dpkg makeWrapper autoPatchelfHook ]; - - dontBuild = true; - - buildInputs = [ popt ]; - - unpackPhase = lib.concatMapStringsSep ";" (src: "dpkg-deb -x ${src} .") srcs; - - installPhase = '' - mkdir -p $out - cp -r usr/. $out/ - - mv $out/lib/*-linux-gnu/* $out/lib/ - rmdir $out/lib/*-linux-gnu - - wrapProgram "$out/bin/pico2wave" \ - --set LD_PRELOAD "${libredirect}/lib/libredirect.so" \ - --set NIX_REDIRECTS /usr/share/pico/lang=$out/share/pico/lang - ''; - - meta = with stdenv.lib; { - description = "Text-to-speech engine"; - homepage = https://android.googlesource.com/platform/external/svox; - platforms = platforms.linux; - license = licenses.asl20; - maintainers = with maintainers; [ abbradar ]; - }; -} -- cgit v1.2.3 From 2f49fff2883c3c34eca2ecebadee67e4d451f87e Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 19 Feb 2020 13:58:40 +0100 Subject: ma arafetch,aralast: use latest revision which fixes https issue --- makefu/2configs/stats/arafetch.nix | 4 ++-- makefu/2configs/stats/external/aralast.nix | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/makefu/2configs/stats/arafetch.nix b/makefu/2configs/stats/arafetch.nix index a078e3646..e96daa038 100644 --- a/makefu/2configs/stats/arafetch.nix +++ b/makefu/2configs/stats/arafetch.nix @@ -2,7 +2,7 @@ with import ; let pkg = with pkgs.python3Packages;buildPythonPackage rec { - rev = "cce2394"; + rev = "56d41de8219adc"; name = "arafetch-${rev}"; propagatedBuildInputs = [ requests @@ -14,7 +14,7 @@ let src = pkgs.fetchgit { url = "http://cgit.euer.krebsco.de/arafetch"; inherit rev; - sha256 = "sha256:0zdz8sqn9n8i69rqngcg7nakmvahf1i5dwajzjpylsh1x5csv2gs"; + sha256 = "0hnwbmj0plynhv3h2idhrzf2zcqx3qnw6lq8zzyn9am74pmvza39"; }; }; home = "/var/lib/arafetch"; diff --git a/makefu/2configs/stats/external/aralast.nix b/makefu/2configs/stats/external/aralast.nix index 870db99a8..19c7327af 100644 --- a/makefu/2configs/stats/external/aralast.nix +++ b/makefu/2configs/stats/external/aralast.nix @@ -1,14 +1,13 @@ { config, lib, pkgs, ... }: -with import ; let pkg = pkgs.stdenv.mkDerivation { name = "aralast-master"; src = pkgs.fetchFromGitHub { owner = "makefu"; repo = "aralast"; - rev = "7121598"; - sha256 = "0vw027c698h9b69ksid5p3pji9960hd7n9xi4arrax0vfkwryb4m"; + rev = "a0d3aeaa109e219fb6fc57170e59020c23413718"; + sha256 = "0bi0nc51z5wk72lnjhg1gfzr5yvvsshyzq924yjbbqpqw08v7i4p"; }; installPhase = '' install -m755 -D aralast.sh $out/bin/aralast -- cgit v1.2.3 From d9e111716af4556cd5a29704080ba1e46c23ae02 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 19 Feb 2020 14:35:53 +0100 Subject: shack/glados: enable sensemap, mpd for kiosk --- krebs/2configs/shack/glados/default.nix | 5 +++++ krebs/2configs/shack/glados/sensors/sensemap.nix | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 krebs/2configs/shack/glados/sensors/sensemap.nix diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix index ef22ccb0d..06350db2a 100644 --- a/krebs/2configs/shack/glados/default.nix +++ b/krebs/2configs/shack/glados/default.nix @@ -96,6 +96,10 @@ in { name = "lounge"; host = "lounge.mpd.shack"; } + { platform = "mpd"; + name = "kiosk"; + host = "lounge.kiosk.shack"; + } ]; sensor = @@ -103,6 +107,7 @@ in { ++ (import ./sensors/power.nix) ++ shackopen.sensor ++ badair.sensor; + airquality = (import ./sensors/sensemap.nix ); binary_sensor = shackopen.binary_sensor; diff --git a/krebs/2configs/shack/glados/sensors/sensemap.nix b/krebs/2configs/shack/glados/sensors/sensemap.nix new file mode 100644 index 000000000..dff29c3c4 --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/sensemap.nix @@ -0,0 +1,6 @@ +[ + { + platform = "opensensemap"; + station_id = "56a0de932cb6e1e41040a68b"; + } +] -- cgit v1.2.3 From cc1659925919b777ee76fcab99e605cbf90057f4 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 19 Feb 2020 14:36:21 +0100 Subject: shack/glados/lib: generalize tts --- krebs/2configs/shack/glados/lib/default.nix | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/krebs/2configs/shack/glados/lib/default.nix b/krebs/2configs/shack/glados/lib/default.nix index 16cbc6830..eb0528a06 100644 --- a/krebs/2configs/shack/glados/lib/default.nix +++ b/krebs/2configs/shack/glados/lib/default.nix @@ -9,22 +9,22 @@ in [ { service = "media_player.turn_on"; - data.entity_id = "media_player.lounge"; + data.entity_id = "media_player.${entity}"; } { service = "media_player.play_media"; data = { - entity_id = "media_player.lounge"; + entity_id = "media_player.${entity}"; media_content_type = "playlist"; media_content_id = "ansage"; }; } { service = "media_player.turn_on"; - data.entity_id = "media_player.lounge"; + data.entity_id = "media_player.${entity}"; } { delay.seconds = 8; } { service = "tts.say"; - entity_id = "media_player.lounge"; + entity_id = "media_player.${entity}"; data_template = { inherit message; language = "de"; @@ -41,6 +41,10 @@ in inherit message; entity = "herrenklo"; }; + kiosk = message: tts { + inherit message; + entity = "kiosk"; + }; }; esphome = { @@ -115,6 +119,22 @@ in state_topic = "${prefix}/${host}/sensor/${topic}/state"; availability_topic = "${prefix}/${host}/status"; }; + ip = {host, name ? "${host} IP", topic ? "ip_address" }: + { + platform = "mqtt"; + inherit name; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; + wifi = {host, name ? "${host} Wifi Signal", topic ? "wifi_signal" }: + { + platform = "mqtt"; + unit_of_measurement = "dB"; + icon = "mdi:wifi"; + inherit name; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; switch = {host, name ? "${host} Button", topic ? "btn" }: # host: ampel # name: Button 1 -- cgit v1.2.3 From 54ef473e33af58638b242a086e9b8ef995fe2ce6 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 19 Feb 2020 14:37:00 +0100 Subject: shack/glados/schlechte_luft: enable ip and wifi sensors --- krebs/2configs/shack/glados/multi/schlechte_luft.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/krebs/2configs/shack/glados/multi/schlechte_luft.nix b/krebs/2configs/shack/glados/multi/schlechte_luft.nix index 4625f6846..c02287d56 100644 --- a/krebs/2configs/shack/glados/multi/schlechte_luft.nix +++ b/krebs/2configs/shack/glados/multi/schlechte_luft.nix @@ -12,10 +12,17 @@ in (glados.esphome.led { name = "Fablab LED Part D"; host = "fablab_led"; topic = "D";}) ]; sensor = [ + (glados.esphome.ip { host = "fablab_feinstaub";}) + (glados.esphome.wifi { host = "fablab_feinstaub";}) (glados.esphome.temp { host = "fablab_feinstaub";}) (glados.esphome.dust_25m { host = "fablab_feinstaub";}) (glados.esphome.dust_100m { host = "fablab_feinstaub";}) + (glados.esphome.ip { host = "fablab_led";}) + (glados.esphome.wifi { host = "fablab_led";}) + + (glados.esphome.ip { host = "rz_feinstaub";}) + (glados.esphome.wifi { host = "rz_feinstaub";}) (glados.esphome.temp { host = "rz_feinstaub";}) (glados.esphome.hum { host = "rz_feinstaub";}) (glados.esphome.dust_25m { host = "rz_feinstaub";}) -- cgit v1.2.3 From 7f197bc2b842670707937779510cc4efc1a50dd4 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 19 Feb 2020 14:38:10 +0100 Subject: shack/glados: re-enable picotts with pico2wave --- krebs/2configs/shack/glados/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix index 06350db2a..7abc55af1 100644 --- a/krebs/2configs/shack/glados/default.nix +++ b/krebs/2configs/shack/glados/default.nix @@ -134,10 +134,10 @@ in { cache = true; time_memory = 57600; } - #{ platform = "picotts"; - # language = "de-DE"; - # service_name = "say"; - #} + { platform = "picotts"; + language = "de-DE"; + service_name = "pico"; + } ]; sun = {}; -- cgit v1.2.3 From 72d34fccb48e5a1c303db72e708f434225306fc9 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 19 Feb 2020 14:43:44 +0100 Subject: shack/glados: use kiosk to say something, add picotts package --- krebs/2configs/shack/glados/automation/shack-startup.nix | 4 ++-- krebs/2configs/shack/glados/default.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/2configs/shack/glados/automation/shack-startup.nix b/krebs/2configs/shack/glados/automation/shack-startup.nix index 10051d60a..35314923b 100644 --- a/krebs/2configs/shack/glados/automation/shack-startup.nix +++ b/krebs/2configs/shack/glados/automation/shack-startup.nix @@ -17,8 +17,8 @@ in condition = "template"; value_template = "{{ trigger.from_state.state != 'No Keyholder' }}"; }; - #action = glados.say.lounge "Danke {{trigger.to_state.state}} für das Übernehmen des Keys von {{trigger.from_state.state}}"; - action = []; + action = glados.say.kiosk "Danke {{trigger.to_state.state}} für das Übernehmen des Keys von {{trigger.from_state.state}}"; + # action = []; } { diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix index 7abc55af1..d8ee199cc 100644 --- a/krebs/2configs/shack/glados/default.nix +++ b/krebs/2configs/shack/glados/default.nix @@ -39,7 +39,7 @@ in { ''; })).override { extraPackages = ps: with ps; [ - python-forecastio jsonrpc-async jsonrpc-websocket mpd2 + python-forecastio jsonrpc-async jsonrpc-websocket mpd2 picotts ]; }; autoExtraComponents = true; -- cgit v1.2.3 From a62f71b00bdb4028595d7edae0e2a25942ad1e56 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 19 Feb 2020 16:38:25 +0100 Subject: shack/glados/lib: add rollo config --- krebs/2configs/shack/glados/lib/default.nix | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/krebs/2configs/shack/glados/lib/default.nix b/krebs/2configs/shack/glados/lib/default.nix index eb0528a06..6ab1edf85 100644 --- a/krebs/2configs/shack/glados/lib/default.nix +++ b/krebs/2configs/shack/glados/lib/default.nix @@ -72,6 +72,17 @@ in payload_available = "online"; payload_not_available = "offline"; }; + rollo = {host, topic ? "rollo" }: + { + optimistic = true; + platform = "mqtt"; + name = "${host} Rollo"; + state_topic = "${prefix}/${host}/sensor/${topic}/state"; + command_topic = "${prefix}/${host}/sensor/${topic}/command"; + availability_topic = "${prefix}/${host}/status"; + position_topic = "${prefix}/${host}/cover/${topic}/position/state"; + set_position_topic = "${prefix}/${host}/cover/${topic}/position/command"; + }; # copied from "homeassistant/light/fablab_led/led_ring/config" led = {host, topic ? "led", name ? host}: { # name: fablab_led @@ -100,6 +111,37 @@ in payload_not_available = "offline"; qos = 1; }; + monoled = {host, topic ? "blue_led", name ? host "MonoLED ${host}"}: + { + platform = "mqtt"; + inherit name; + schema = "json"; + brightness = true; + effect = true; + effect_list = [ # TODO: may be different + "Strobe" + "Twinkle" + "None" + ]; + state_topic = "${prefix}/${host}/light/${topic}/state"; + command_topic = "${prefix}/${host}/light/${topic}/command"; + availability_topic = "${prefix}/${host}/status"; + }; + btn = {host, topic ? "button", name ? "${host} ${topic}"}: #binary_sensor + { + platform = "mqtt"; + name = "${host} Button"; + state_topic = "${prefix}/${host}/binary_sensor/${topic}/state"; + availability_topic = "${prefix}/${host}/status"; + }; + relay = {host, name ? "${host} ${topic}", topic ? "relay" }: #switch + { + inherit name; + platform = "mqtt"; + state_topic = "${prefix}/${host}/switch/${topic}/state"; + command_topic = "${prefix}/${host}/switch/${topic}/command"; + availability_topic = "${prefix}/${host}/status"; + }; # Feinstaub dust_25m = { host, name ? "${host} < 2.5µm", topic ? "particulate_matter_25m_concentration" }: { -- cgit v1.2.3 From 64c224a711a1147b1be562ddd5ce1778ff5a6b1c Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 20 Feb 2020 14:00:17 +0100 Subject: shack/glados: add darksky,mate,spaceap,rollos --- krebs/2configs/shack/glados/default.nix | 20 ++- krebs/2configs/shack/glados/lib/default.nix | 143 --------------------- krebs/2configs/shack/glados/multi/rollos.nix | 13 ++ .../2configs/shack/glados/multi/schlechte_luft.nix | 26 ---- krebs/2configs/shack/glados/sensors/darksky.nix | 21 +++ krebs/2configs/shack/glados/sensors/hass.nix | 5 - krebs/2configs/shack/glados/sensors/mate.nix | 16 +++ krebs/2configs/shack/glados/sensors/power.nix | 7 +- krebs/2configs/shack/glados/sensors/spaceapi.nix | 52 ++++++++ krebs/2configs/shack/glados/sensors/unifi.nix | 6 + 10 files changed, 124 insertions(+), 185 deletions(-) create mode 100644 krebs/2configs/shack/glados/multi/rollos.nix create mode 100644 krebs/2configs/shack/glados/sensors/darksky.nix delete mode 100644 krebs/2configs/shack/glados/sensors/hass.nix create mode 100644 krebs/2configs/shack/glados/sensors/mate.nix create mode 100644 krebs/2configs/shack/glados/sensors/spaceapi.nix create mode 100644 krebs/2configs/shack/glados/sensors/unifi.nix diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix index d8ee199cc..3f3b1cac5 100644 --- a/krebs/2configs/shack/glados/default.nix +++ b/krebs/2configs/shack/glados/default.nix @@ -39,7 +39,7 @@ in { ''; })).override { extraPackages = ps: with ps; [ - python-forecastio jsonrpc-async jsonrpc-websocket mpd2 picotts + python-forecastio jsonrpc-async jsonrpc-websocket mpd2 pkgs.picotts ]; }; autoExtraComponents = true; @@ -76,6 +76,8 @@ in { client_id = "home-assistant"; keepalive = 60; protocol = 3.1; + discovery = true; #enable esphome discovery + discovery_prefix = "homeassistant"; birth_message = { topic = "glados/hass/status/LWT"; payload = "Online"; @@ -90,7 +92,7 @@ in { }; }; switch = wasser.switch; - light = badair.light; + light = []; media_player = [ { platform = "mpd"; name = "lounge"; @@ -103,13 +105,17 @@ in { ]; sensor = - (import ./sensors/hass.nix) - ++ (import ./sensors/power.nix) + (import ./sensors/power.nix) + ++ (import ./sensors/mate.nix) + ++ (import ./sensors/darksky.nix { inherit lib;}) ++ shackopen.sensor - ++ badair.sensor; - airquality = (import ./sensors/sensemap.nix ); + ; + air_quality = (import ./sensors/sensemap.nix ); - binary_sensor = shackopen.binary_sensor; + binary_sensor = + shackopen.binary_sensor + ++ (import ./sensors/spaceapi.nix) + ; camera = []; diff --git a/krebs/2configs/shack/glados/lib/default.nix b/krebs/2configs/shack/glados/lib/default.nix index 6ab1edf85..6d2b7749b 100644 --- a/krebs/2configs/shack/glados/lib/default.nix +++ b/krebs/2configs/shack/glados/lib/default.nix @@ -46,149 +46,6 @@ in entity = "kiosk"; }; }; - esphome = - { - temp = {host, topic ? "temperature" }: - { - platform = "mqtt"; - name = "${host} Temperature"; - device_class = "temperature"; - unit_of_measurement = "°C"; - icon = "mdi:thermometer"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - payload_available = "online"; - payload_not_available = "offline"; - }; - hum = {host, topic ? "humidity" }: - { - platform = "mqtt"; - unit_of_measurement = "%"; - icon = "mdi:water-percent"; - device_class = "humidity"; - name = "${host} Humidity"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - payload_available = "online"; - payload_not_available = "offline"; - }; - rollo = {host, topic ? "rollo" }: - { - optimistic = true; - platform = "mqtt"; - name = "${host} Rollo"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - command_topic = "${prefix}/${host}/sensor/${topic}/command"; - availability_topic = "${prefix}/${host}/status"; - position_topic = "${prefix}/${host}/cover/${topic}/position/state"; - set_position_topic = "${prefix}/${host}/cover/${topic}/position/command"; - }; - # copied from "homeassistant/light/fablab_led/led_ring/config" - led = {host, topic ? "led", name ? host}: - { # name: fablab_led - # topic: led_ring - platform = "mqtt"; - inherit name; - schema = "json"; - brightness = true; - rgb = true; - effect = true; - effect_list = [ # TODO: may be different - "Random" - "Strobe" - "Rainbow" - "Color Wipe" - "Scan" - "Twinkle" - "Fireworks" - "Addressable Flicker" - "None" - ]; - state_topic = "${prefix}/${host}/light/${topic}/state"; - command_topic = "${prefix}/${host}/light/${topic}/command"; - availability_topic = "${prefix}/${host}/status"; - payload_available = "online"; - payload_not_available = "offline"; - qos = 1; - }; - monoled = {host, topic ? "blue_led", name ? host "MonoLED ${host}"}: - { - platform = "mqtt"; - inherit name; - schema = "json"; - brightness = true; - effect = true; - effect_list = [ # TODO: may be different - "Strobe" - "Twinkle" - "None" - ]; - state_topic = "${prefix}/${host}/light/${topic}/state"; - command_topic = "${prefix}/${host}/light/${topic}/command"; - availability_topic = "${prefix}/${host}/status"; - }; - btn = {host, topic ? "button", name ? "${host} ${topic}"}: #binary_sensor - { - platform = "mqtt"; - name = "${host} Button"; - state_topic = "${prefix}/${host}/binary_sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - relay = {host, name ? "${host} ${topic}", topic ? "relay" }: #switch - { - inherit name; - platform = "mqtt"; - state_topic = "${prefix}/${host}/switch/${topic}/state"; - command_topic = "${prefix}/${host}/switch/${topic}/command"; - availability_topic = "${prefix}/${host}/status"; - }; - # Feinstaub - dust_25m = { host, name ? "${host} < 2.5µm", topic ? "particulate_matter_25m_concentration" }: - { - platform = "mqtt"; - unit_of_measurement = "µg/m³"; - icon = "mdi:chemical-weapon"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - dust_100m = {host, name ? "${host} < 10µm", topic ? "particulate_matter_100m_concentration" }: - { - platform = "mqtt"; - unit_of_measurement = "µg/m³"; - icon = "mdi:chemical-weapon"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - ip = {host, name ? "${host} IP", topic ? "ip_address" }: - { - platform = "mqtt"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - wifi = {host, name ? "${host} Wifi Signal", topic ? "wifi_signal" }: - { - platform = "mqtt"; - unit_of_measurement = "dB"; - icon = "mdi:wifi"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - switch = {host, name ? "${host} Button", topic ? "btn" }: - # host: ampel - # name: Button 1 - # topic: btn1 - { - inherit name; - platform = "mqtt"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - command_topic = "${prefix}/${host}/switch/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - }; tasmota = { plug = {host, name ? host, topic ? host}: diff --git a/krebs/2configs/shack/glados/multi/rollos.nix b/krebs/2configs/shack/glados/multi/rollos.nix new file mode 100644 index 000000000..1febad525 --- /dev/null +++ b/krebs/2configs/shack/glados/multi/rollos.nix @@ -0,0 +1,13 @@ +let + glados = import ../lib; +in +{ + # LED + light = [ + ]; + sensor = [ + ]; + automation = + [ + ]; +} diff --git a/krebs/2configs/shack/glados/multi/schlechte_luft.nix b/krebs/2configs/shack/glados/multi/schlechte_luft.nix index c02287d56..529454a41 100644 --- a/krebs/2configs/shack/glados/multi/schlechte_luft.nix +++ b/krebs/2configs/shack/glados/multi/schlechte_luft.nix @@ -2,32 +2,6 @@ let glados = import ../lib; in { - # LED - light = [ - (glados.esphome.led { name = "Fablab LED"; host = "fablab_led"; topic = "led_ring"; }) - - (glados.esphome.led { name = "Fablab LED Part A"; host = "fablab_led"; topic = "A";}) - (glados.esphome.led { name = "Fablab LED Part B"; host = "fablab_led"; topic = "B";}) - (glados.esphome.led { name = "Fablab LED Part C"; host = "fablab_led"; topic = "C";}) - (glados.esphome.led { name = "Fablab LED Part D"; host = "fablab_led"; topic = "D";}) - ]; - sensor = [ - (glados.esphome.ip { host = "fablab_feinstaub";}) - (glados.esphome.wifi { host = "fablab_feinstaub";}) - (glados.esphome.temp { host = "fablab_feinstaub";}) - (glados.esphome.dust_25m { host = "fablab_feinstaub";}) - (glados.esphome.dust_100m { host = "fablab_feinstaub";}) - - (glados.esphome.ip { host = "fablab_led";}) - (glados.esphome.wifi { host = "fablab_led";}) - - (glados.esphome.ip { host = "rz_feinstaub";}) - (glados.esphome.wifi { host = "rz_feinstaub";}) - (glados.esphome.temp { host = "rz_feinstaub";}) - (glados.esphome.hum { host = "rz_feinstaub";}) - (glados.esphome.dust_25m { host = "rz_feinstaub";}) - (glados.esphome.dust_100m { host = "rz_feinstaub";}) - ]; automation = [ { alias = "Gute Luft Fablab"; diff --git a/krebs/2configs/shack/glados/sensors/darksky.nix b/krebs/2configs/shack/glados/sensors/darksky.nix new file mode 100644 index 000000000..c8725b868 --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/darksky.nix @@ -0,0 +1,21 @@ +{lib,...}: +[ + { platform = "darksky"; + api_key = lib.removeSuffix "\n" + (builtins.readFile ); + language = "de"; + monitored_conditions = [ + "summary" "icon" + "nearest_storm_distance" "precip_probability" + "precip_intensity" + "temperature" # "temperature_high" "temperature_low" + "apparent_temperature" + "hourly_summary" # next 24 hours text + "humidity" + "pressure" + "uv_index" + ]; + units = "si" ; + scan_interval = "00:15:00"; + } +] diff --git a/krebs/2configs/shack/glados/sensors/hass.nix b/krebs/2configs/shack/glados/sensors/hass.nix deleted file mode 100644 index 8de0ef391..000000000 --- a/krebs/2configs/shack/glados/sensors/hass.nix +++ /dev/null @@ -1,5 +0,0 @@ -let - glados = import ../lib; -in - (map (host: glados.esphome.temp {inherit host;}) [ "lounge" "werkstatt" "herrenklo" "dusche" "fablab" "whc" ]) - ++ (map (host: glados.esphome.hum {inherit host;}) [ "lounge" "werkstatt" "herrenklo" "dusche" "fablab" "whc" ]) diff --git a/krebs/2configs/shack/glados/sensors/mate.nix b/krebs/2configs/shack/glados/sensors/mate.nix new file mode 100644 index 000000000..1bb0e71eb --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/mate.nix @@ -0,0 +1,16 @@ +let + fuellstand = name: id: { + platform = "rest"; + resource = "https://ora5.tutschonwieder.net/ords/lick_prod/v1/get/fuellstand/1/${toString id}"; + method = "GET"; + name = "Füllstand ${name}"; + value_template = "{{ value_json.fuellstand }}"; + }; +in [ + (fuellstand "Wasser" 1) + (fuellstand "Mate Cola" 2) + (fuellstand "Apfelschorle" 3) + (fuellstand "Zitronensprudel" 4) + (fuellstand "Mate 1" 26) + (fuellstand "Mate 2" 27) +] diff --git a/krebs/2configs/shack/glados/sensors/power.nix b/krebs/2configs/shack/glados/sensors/power.nix index 1aa250a19..b168f2beb 100644 --- a/krebs/2configs/shack/glados/sensors/power.nix +++ b/krebs/2configs/shack/glados/sensors/power.nix @@ -2,7 +2,6 @@ let power_x = name: phase: { platform = "mqtt"; name = "${phase} ${name}"; - # device_class = "power"; state_topic = "/power/total/${phase}/${name}"; availability_topic = "/power/lwt"; payload_available = "Online"; @@ -11,17 +10,17 @@ let power_consumed = { platform = "mqtt"; name = "Power Consumed"; - #device_class = "power"; + device_class = "power"; state_topic = "/power/total/consumed"; availability_topic = "/power/lwt"; payload_available = "Online"; payload_not_available = "Offline"; }; power_volt = power_x "Voltage"; - power_watt = power_x "Power"; + power_watt = (power_x "Power") ; power_curr = power_x "Current"; in (map power_volt [ "L1" "L2" "L3" ]) -++ (map power_watt [ "L1" "L2" "L3" ]) +++ (map (x: ((power_watt x) // { device_class = "power"; })) [ "L1" "L2" "L3" ]) ++ (map power_curr [ "L1" "L2" "L3" ]) ++ [ power_consumed ] diff --git a/krebs/2configs/shack/glados/sensors/spaceapi.nix b/krebs/2configs/shack/glados/sensors/spaceapi.nix new file mode 100644 index 000000000..11cab11c9 --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/spaceapi.nix @@ -0,0 +1,52 @@ +[ + { + platform = "rest"; + resource = "https://spaceapi.afra-berlin.de/v1/status.json"; + method = "GET"; + name = "Door AFRA Berlin"; + device_class = "door"; + value_template = "{{ value_json.open }}"; + } + { + platform = "rest"; + resource = "http://club.entropia.de/spaceapi"; + method = "GET"; + name = "Door Entropia"; + device_class = "door"; + value_template = "{{ value_json.open }}"; + } + { + platform = "rest"; + resource = "http://www.c-base.org/status.json"; + method = "GET"; + name = "Door C-Base Berlin"; + device_class = "door"; + value_template = "{{ value_json.open }}"; + } + { + platform = "rest"; + resource = "https://status.raumzeitlabor.de/api/full.json"; + method = "GET"; + name = "Door RZL"; + device_class = "door"; + value_template = "{{ value_json.status }}"; + } + { + platform = "rest"; + resource = "https://datenobservatorium.de/"; + method = "GET"; + name = "Door Datenobservatorium"; + device_class = "door"; + value_template = "false"; + scan_interval = 2592000; + } + { + platform = "rest"; + resource = "https://infuanfu.de/"; + method = "GET"; + name = "Door Infuanfu"; + device_class = "door"; + value_template = "false"; + scan_interval = 2592000; + } +] diff --git a/krebs/2configs/shack/glados/sensors/unifi.nix b/krebs/2configs/shack/glados/sensors/unifi.nix new file mode 100644 index 000000000..f64e3feb6 --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/unifi.nix @@ -0,0 +1,6 @@ +{ + controllers = { + host = "unifi.shack"; + site = "shackspace"; + }; +} -- 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 +++++++---------------- makefu/2configs/ham/multi/esphome.nix | 45 +++++++++ makefu/2configs/ham/multi/kurzzeitwecker.nix | 132 +++++++++++++++++++++++++++ 3 files changed, 211 insertions(+), 78 deletions(-) create mode 100644 makefu/2configs/ham/multi/esphome.nix create mode 100644 makefu/2configs/ham/multi/kurzzeitwecker.nix diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix index 56acc2d07..1a65ba62c 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; diff --git a/makefu/2configs/ham/multi/esphome.nix b/makefu/2configs/ham/multi/esphome.nix new file mode 100644 index 000000000..8ca12d899 --- /dev/null +++ b/makefu/2configs/ham/multi/esphome.nix @@ -0,0 +1,45 @@ +# provides: +# switch +# automation +# binary_sensor +# sensor +# input_select +# timer +let + inherit (import ../lib) esphome; + sonoff_s20 = host: { + sensor = [ + (esphome.ip { inherit host;}) + (esphome.wifi { inherit host;}) + (esphome.temp { inherit host;}) + (esphome.hum { inherit host;}) + ]; + binary_sensor = [ + (esphome.btn { inherit host;}) + ]; + light = [ + (esphome.monoled { inherit host;}) + ]; + switch = [ + (esphome.relay { inherit host;}) + (esphome.restart { inherit host;}) + ]; + }; + dusche = sonoff_s20 "dusche_plug"; + schlafzimmer = sonoff_s20 "schlafzimmer_plug"; +in { + sensor = [ + (esphome.pressure {host = "dusche_plug";}) + ] + ++ dusche.sensor + ++ schlafzimmer.sensor; + binary_sensor = + dusche.binary_sensor + ++ schlafzimmer.binary_sensor; + light = + dusche.light + ++ schlafzimmer.light; + switch = + dusche.switch + ++ schlafzimmer.switch; +} diff --git a/makefu/2configs/ham/multi/kurzzeitwecker.nix b/makefu/2configs/ham/multi/kurzzeitwecker.nix new file mode 100644 index 000000000..03d0d5aac --- /dev/null +++ b/makefu/2configs/ham/multi/kurzzeitwecker.nix @@ -0,0 +1,132 @@ +# Provides: +# timer +# automation +# script + +# Needs: +# sensor.zigbee_btn1_click +# notify.telegrambot +let + button = "sensor.zigbee_btn2_click"; +in { + timer.kurzzeitwecker = + { + name = "Zigbee Kurzzeitwecker"; + duration = 300; + }; + script.add_5_minutes_to_kurzzeitwecker = + { + alias = "Add 5 minutes to kurzzeitwecker"; + sequence = [ + { service = "timer.pause"; + entity_id = "timer.kurzzeitwecker"; + } + { service = "timer.start"; + data_template = { + entity_id = "timer.kurzzeitwecker"; + duration = '' + {% set r = state_attr('timer.kurzzeitwecker', 'remaining') ~ '-0000' %} + {% set t = strptime(r, '%H:%M:%S.%f%z') %} + {{ (as_timestamp(t) + 300) | timestamp_custom('%H:%M:%S', false) }} + ''; + }; + } + ]; + }; + automation = + [ + { + alias = "Start Timer 5min"; + trigger = { + platform = "state"; + entity_id = button; + to = "single"; + }; + condition = + { condition = "state"; + entity_id = "timer.kurzzeitwecker"; + state = "idle"; + }; + + action = [ + { service = "timer.start"; + entity_id = "timer.kurzzeitwecker"; + data.duration = "00:05:00"; + } + { + service = "notify.telegrambot"; + data.message = "Timer gestartet {{state_attr('timer.kurzzeitwecker', 'remaining') }}, verbleibend "; + } + ]; + } + { + alias = "Add Timer 5min"; + trigger = { + platform = "state"; + entity_id = button; + to = "single"; + }; + condition = + { condition = "state"; + entity_id = "timer.kurzzeitwecker"; + state = "active"; + }; + + action = [ + { service = "homeassistant.turn_on"; + entity_id = "script.add_5_minutes_to_kurzzeitwecker"; + } + { + service = "notify.telegrambot"; + data.message = ''Timer um 5 minuten verlängert, {{ state_attr('timer.kurzzeitwecker', 'remaining') | truncate(9,True," ") }} verbleibend ''; + } + ]; + } + { + alias = "Stop timer on double click"; + trigger = [ + { + platform = "state"; + entity_id = button; + to = "double"; + } + { + platform = "state"; + entity_id = button; + to = "triple"; + } + ]; + condition = + { + condition = "state"; + entity_id = "timer.kurzzeitwecker"; + state = "active"; + }; + + action = [ + { + service = "timer.cancel"; + entity_id = "timer.kurzzeitwecker"; + } + { + service = "notify.telegrambot"; + data.message = "Timer gestoppt, abgebrochen"; + } + ]; + } + { + alias = "Timer Finished"; + trigger = { + platform = "event"; + event_type = "timer.finished"; + event_data.entity_id = "timer.kurzzeitwecker"; + }; + action = [ + { + service = "notify.telegrambot"; + data.message = "Timer beendet"; + } + ]; + } + ]; +} -- 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 +++----- makefu/2configs/ham/multi/esphome.nix | 45 ----------------------------------- 2 files changed, 3 insertions(+), 52 deletions(-) delete mode 100644 makefu/2configs/ham/multi/esphome.nix diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix index 1a65ba62c..de9fa6be7 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 diff --git a/makefu/2configs/ham/multi/esphome.nix b/makefu/2configs/ham/multi/esphome.nix deleted file mode 100644 index 8ca12d899..000000000 --- a/makefu/2configs/ham/multi/esphome.nix +++ /dev/null @@ -1,45 +0,0 @@ -# provides: -# switch -# automation -# binary_sensor -# sensor -# input_select -# timer -let - inherit (import ../lib) esphome; - sonoff_s20 = host: { - sensor = [ - (esphome.ip { inherit host;}) - (esphome.wifi { inherit host;}) - (esphome.temp { inherit host;}) - (esphome.hum { inherit host;}) - ]; - binary_sensor = [ - (esphome.btn { inherit host;}) - ]; - light = [ - (esphome.monoled { inherit host;}) - ]; - switch = [ - (esphome.relay { inherit host;}) - (esphome.restart { inherit host;}) - ]; - }; - dusche = sonoff_s20 "dusche_plug"; - schlafzimmer = sonoff_s20 "schlafzimmer_plug"; -in { - sensor = [ - (esphome.pressure {host = "dusche_plug";}) - ] - ++ dusche.sensor - ++ schlafzimmer.sensor; - binary_sensor = - dusche.binary_sensor - ++ schlafzimmer.binary_sensor; - light = - dusche.light - ++ schlafzimmer.light; - switch = - dusche.switch - ++ schlafzimmer.switch; -} -- 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 +- makefu/2configs/ham/lib/default.nix | 275 ---------------------------- makefu/2configs/ham/zigbee2mqtt/default.nix | 31 ++++ 3 files changed, 33 insertions(+), 279 deletions(-) create mode 100644 makefu/2configs/ham/zigbee2mqtt/default.nix diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix index de9fa6be7..ae0c46baa 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 diff --git a/makefu/2configs/ham/lib/default.nix b/makefu/2configs/ham/lib/default.nix index 8bc544310..c2d7916c1 100644 --- a/makefu/2configs/ham/lib/default.nix +++ b/makefu/2configs/ham/lib/default.nix @@ -40,279 +40,4 @@ in entity = "firetv"; }; }; - zigbee = let - prefix = "/ham/zigbee"; - in - { - inherit prefix; - state = name: { - platform = "mqtt"; - name = "zigbee ${name} connectivity"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - payload_on = true; - payload_off = false; - value_template = "{{ value_json.state }}"; - device_class = "connectivity"; - }; - battery = name: { - platform = "mqtt"; - name = "zigbee ${name} battery"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - unit_of_measurement = "%"; - device_class = "battery"; - value_template = "{{ value_json.battery }}"; - }; - linkquality = name: { - platform = "mqtt"; - name = "zigbee ${name} linkquality"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - unit_of_measurement = "-"; - value_template = "{{ value_json.linkquality }}"; - }; - temperature = name: { - platform = "mqtt"; - name = "zigbee ${name} temperature"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - unit_of_measurement = "°C"; - device_class = "temperature"; - value_template = "{{ value_json.temperature }}"; - }; - humidity = name: { - platform = "mqtt"; - name = "zigbee ${name} humidity"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - unit_of_measurement = "%"; - device_class = "humidity"; - value_template = "{{ value_json.humidity }}"; - }; - pressure = name: { - platform = "mqtt"; - state_topic = "${prefix}/${name}"; - name = "zigbee ${name} pressure"; - availability_topic = "${prefix}/bridge/state"; - unit_of_measurement = "hPa"; - device_class = "pressure"; - value_template = "{{ value_json.pressure }}" ; - }; - click = name: - { - platform = "mqtt"; - name = "zigbee ${name} click"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - icon = "mdi:toggle-switch"; - value_template = "{{ value_json.click }}"; - }; - contact = name: { - platform = "mqtt"; - name = "zigbee ${name} contact"; - state_topic = "${prefix}/${name}"; - availability_topic = "${prefix}/bridge/state"; - payload_on = false; - payload_off = true; - value_template = "{{ value_json.contact }}"; - device_class = "door"; - }; - }; - esphome = - { - temp = {host, topic ? "temperature" }: - { - platform = "mqtt"; - name = "${host} Temperature"; - device_class = "temperature"; - unit_of_measurement = "°C"; - icon = "mdi:thermometer"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - payload_available = "online"; - payload_not_available = "offline"; - }; - hum = {host, topic ? "humidity" }: - { - platform = "mqtt"; - unit_of_measurement = "%"; - icon = "mdi:water-percent"; - device_class = "humidity"; - name = "${host} Humidity"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - payload_available = "online"; - payload_not_available = "offline"; - }; - # copied from "homeassistant/light/fablab_led/led_ring/config" - led = {host, topic ? "led", name ? host}: - { # name: fablab_led - # topic: led_ring - platform = "mqtt"; - inherit name; - schema = "json"; - brightness = true; - rgb = true; - effect = true; - effect_list = [ # TODO: may be different - "Random" - "Strobe" - "Rainbow" - "Color Wipe" - "Scan" - "Twinkle" - "Fireworks" - "Addressable Flicker" - "None" - ]; - state_topic = "${prefix}/${host}/light/${topic}/state"; - command_topic = "${prefix}/${host}/light/${topic}/command"; - availability_topic = "${prefix}/${host}/status"; - payload_available = "online"; - payload_not_available = "offline"; - qos = 1; - }; - # Feinstaub - dust_25m = { host, name ? "${host} < 2.5µm", topic ? "particulate_matter_25m_concentration" }: - { - platform = "mqtt"; - unit_of_measurement = "µg/m³"; - icon = "mdi:chemical-weapon"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - dust_100m = {host, name ? "${host} < 10µm", topic ? "particulate_matter_100m_concentration" }: - { - platform = "mqtt"; - unit_of_measurement = "µg/m³"; - icon = "mdi:chemical-weapon"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - ip = {host, name ? "${host} IP", topic ? "ip_address" }: - { - platform = "mqtt"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - wifi = {host, name ? "${host} Wifi Signal", topic ? "wifi_signal" }: - { - platform = "mqtt"; - unit_of_measurement = "dB"; - icon = "mdi:wifi"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - switch = {host, name ? "${host} Button", topic ? "btn" }: - # host: ampel - # name: Button 1 - # topic: btn1 - { - inherit name; - platform = "mqtt"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - command_topic = "${prefix}/${host}/switch/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - }; - tasmota = - { - plug = {host, name ? host, topic ? host}: - { - platform = "mqtt"; - inherit name; - state_topic = "sonoff/stat/${topic}/POWER1"; - command_topic = "sonoff/cmnd/${topic}/POWER1"; - availability_topic = "sonoff/tele/${topic}/LWT"; - payload_on= "ON"; - payload_off= "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - retain = false; - qos = 1; - }; - am2301 = { name, host, topic?host }: - [ { platform = "mqtt"; - name = "${name} Temperatur"; - state_topic = "${prefix}/${topic}/tele/SENSOR"; - value_template = "{{ value_json.AM2301.Temperature }}"; - unit_of_measurement = "°C"; - } - { platform = "mqtt"; - name = "${name} Luftfeuchtigkeit"; - state_topic = "${prefix}/${topic}/tele/SENSOR"; - value_template = "{{ value_json.AM2301.Humidity }}"; - unit_of_measurement = "%"; - } - ]; - bme = { name, host, topic?host }: - [ { platform = "mqtt"; - name = "${name} Temperatur"; - state_topic = "${prefix}/${topic}/tele/SENSOR"; - value_template = "{{ value_json.BME280.Temperature }}"; - unit_of_measurement = "°C"; - } - { platform = "mqtt"; - name = "${name} Luftfeuchtigkeit"; - state_topic = "${prefix}/${topic}/tele/SENSOR"; - value_template = "{{ value_json.BME280.Humidity }}"; - unit_of_measurement = "%"; - } - { platform = "mqtt"; - name = "${name} Luftdruck"; - state_topic = "${prefix}/${topic}/tele/SENSOR"; - value_template = "{{ value_json.BME280.Pressure }}"; - unit_of_measurement = "hPa"; - } - ]; - rgb = { name, host, topic?host }: - { platform = "mqtt"; - inherit name; - retain = false; - qos = 1; - optimistic = false; - # state - # TODO: currently broken, will not use the custom state topic - #state_topic = "${prefix}/${topic}/stat/POWER"; - state_topic = "${prefix}/${topic}/stat/POWER"; - command_topic = "${prefix}/${topic}/cmnd/POWER"; - availability_topic = "${prefix}/${topic}/tele/LWT"; - payload_on= "ON"; - payload_off= "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - # brightness - brightness_state_topic = "${prefix}/${topic}/stat/Dimmer"; - brightness_command_topic = "${prefix}/${topic}/cmnd/Dimmer"; - brightness_value_template = "{{ value_json.Dimmer }}"; - brightness_scale = 100; - # color - rgb_state_topic = "${prefix}/${topic}/stat/Color"; - rgb_command_topic = "${prefix}/${topic}/cmnd/MEM1"; # use enabled rule - rgb_command_mode = "hex"; - rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; - # effects - effect_state_topic = "${prefix}/${topic}/stat/Scheme"; - effect_command_topic = "${prefix}/${topic}/cmnd/Scheme"; - effect_value_template = "{{ value_json.Scheme }}"; - effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ]; -}; - motion = { name, host, topic?host }: - { platform = "mqtt"; - device_class = "motion"; - inherit name; - # TODO: currently broken, will not use the custom state topic - state_topic = "${prefix}/${topic}/stat/POWER"; - payload_on = "ON"; - payload_off = "OFF"; - availability_topic = "${prefix}/${topic}/tele/LWT"; - payload_available = "Online"; - payload_not_available = "Offline"; - }; - }; } diff --git a/makefu/2configs/ham/zigbee2mqtt/default.nix b/makefu/2configs/ham/zigbee2mqtt/default.nix new file mode 100644 index 000000000..cb1f80d8a --- /dev/null +++ b/makefu/2configs/ham/zigbee2mqtt/default.nix @@ -0,0 +1,31 @@ +{config, pkgs, lib, ...}: + +let + pkg = pkgs.callPackage ./zigbee2mqtt.nix { }; +in + +{ + #users.users.z2m = { + # extraGroups = [ "dialout" ]; + #}; + + services.udev.extraRules = '' + SUBSYSTEM=="tty", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16a8", SYMLINK+="cc2531", MODE="0660", GROUP="dailout" + ''; + #systemd.services.zigbee2mqtt = { + # wantedBy = ["multi-user.target" ]; + # after = [ "network.target" ]; + # description = "Run zigbee2mqtt as daemon"; + # environment.ZIGBEE2MQTT_DATA = "/var/lib/zigbee2mqtt"; + # serviceConfig = { + # WorkingDirectory = ''${pkg}/lib/node_modules/zigbee2mqtt''; + # ExecStart = ''${pkgs.nodejs-12_x}/bin/node index.js''; + # StandardOutput = "inherit"; + # StandardError = "inherit"; + # Restart = "always"; + # User = "z2m"; + # StateDirectory = "zigbee2mqtt"; + # #DeviceAllow = "/dev/cc2531 rw"; + # }; + #}; +} -- 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/androidtv/adbshell.nix | 38 +++++++++++++ makefu/2configs/ham/androidtv/default.nix | 30 ++++++++++ makefu/2configs/ham/androidtv/purepythonadb.nix | 21 +++++++ makefu/2configs/ham/automation/firetv_restart.nix | 26 +++++++++ makefu/2configs/ham/default.nix | 67 +++++++---------------- 5 files changed, 134 insertions(+), 48 deletions(-) create mode 100644 makefu/2configs/ham/androidtv/adbshell.nix create mode 100644 makefu/2configs/ham/androidtv/default.nix create mode 100644 makefu/2configs/ham/androidtv/purepythonadb.nix create mode 100644 makefu/2configs/ham/automation/firetv_restart.nix diff --git a/makefu/2configs/ham/androidtv/adbshell.nix b/makefu/2configs/ham/androidtv/adbshell.nix new file mode 100644 index 000000000..f5b96c859 --- /dev/null +++ b/makefu/2configs/ham/androidtv/adbshell.nix @@ -0,0 +1,38 @@ +{ lib +, buildPythonPackage +, fetchPypi +, cryptography +, pyasn1 +, rsa +, pycryptodome +}: + +buildPythonPackage rec { + pname = "adb_shell"; + version = "0.0.8"; + + src = fetchPypi { + inherit pname version; + sha256 = "01f9jinhfyjldg9793gz2i7gcd9xyx0a62r7a5ijssklcnn2rwnm"; + }; + + propagatedBuildInputs = [ + cryptography + pyasn1 + rsa + ]; + + # tests are not part of pypi package + doCheck = false; + + checkInputs = [ + pycryptodome + ]; + + meta = with lib; { + description = "A Python implementation of ADB with shell and FileSync functionality"; + homepage = https://github.com/JeffLIrion/adb_shell/; + license = licenses.mit; + # maintainers = [ maintainers. ]; + }; +} diff --git a/makefu/2configs/ham/androidtv/default.nix b/makefu/2configs/ham/androidtv/default.nix new file mode 100644 index 000000000..8f3bdc1f3 --- /dev/null +++ b/makefu/2configs/ham/androidtv/default.nix @@ -0,0 +1,30 @@ +{ lib +, buildPythonPackage +, callPackage +, fetchPypi +}: + +buildPythonPackage rec { + pname = "androidtv"; + version = "0.0.34"; + + src = fetchPypi { + inherit pname version; + sha256 = "13078i2a9hglpv4ldycph5n5485np21vs6z2qn830hybmx8kfxsw"; + }; + + propagatedBuildInputs = [ + (callPackage ./adbshell.nix {}) + (callPackage ./purepythonadb.nix {}) + ]; + + # tests are not packaged in pypi release + doCheck = false; + + meta = with lib; { + description = "Communicate with an Android TV or Fire TV device via ADB over a network"; + homepage = https://github.com/JeffLIrion/python-androidtv/; + license = licenses.mit; + # maintainers = [ maintainers. ]; + }; +} diff --git a/makefu/2configs/ham/androidtv/purepythonadb.nix b/makefu/2configs/ham/androidtv/purepythonadb.nix new file mode 100644 index 000000000..d4e763b70 --- /dev/null +++ b/makefu/2configs/ham/androidtv/purepythonadb.nix @@ -0,0 +1,21 @@ +{ lib +, buildPythonPackage +, fetchPypi +}: + +buildPythonPackage rec { + pname = "pure-python-adb"; + version = "0.2.3.dev0"; + + src = fetchPypi { + inherit pname version; + sha256 = "88e5a4578435197799aa368fb1a5d87fe43e02a888cb7e85c2ad66173b383c89"; + }; + + meta = with lib; { + description = "Pure python implementation of the adb client"; + homepage = https://github.com/Swind/pure-python-adb; + license = licenses.mit; + # maintainers = [ maintainers. ]; + }; +} \ No newline at end of file diff --git a/makefu/2configs/ham/automation/firetv_restart.nix b/makefu/2configs/ham/automation/firetv_restart.nix new file mode 100644 index 000000000..779092c73 --- /dev/null +++ b/makefu/2configs/ham/automation/firetv_restart.nix @@ -0,0 +1,26 @@ +[ + { + alias = "Nightly reboot of firetv"; + trigger = { + platform = "time"; + at = "03:00:00"; + }; + action = [ + { + service = "androidtv.adb_command"; + data = { + entity_id = "media_player.firetv_stick"; + command = "reboot"; + }; + } + { delay.minutes = 2; } + { + service = "media_player.select_source"; + data = { + entity_id = "media_player.firetv_stick"; + source = "com.amazon.bueller.music"; + }; + } + ]; + } +] diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix index ae0c46baa..3fbe1187f 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 e1d6406fbd7be66bd4a2ebd08c568a19ee09f906 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 3 Mar 2020 21:17:43 +0100 Subject: ma ham/zigbee2mqtt: giving up docker-container that shit away --- makefu/2configs/ham/zigbee2mqtt/default.nix | 35 ++++++++++------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/makefu/2configs/ham/zigbee2mqtt/default.nix b/makefu/2configs/ham/zigbee2mqtt/default.nix index cb1f80d8a..7c55326f9 100644 --- a/makefu/2configs/ham/zigbee2mqtt/default.nix +++ b/makefu/2configs/ham/zigbee2mqtt/default.nix @@ -1,31 +1,20 @@ {config, pkgs, lib, ...}: -let - pkg = pkgs.callPackage ./zigbee2mqtt.nix { }; -in { - #users.users.z2m = { - # extraGroups = [ "dialout" ]; - #}; - + # symlink the zigbee controller services.udev.extraRules = '' SUBSYSTEM=="tty", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16a8", SYMLINK+="cc2531", MODE="0660", GROUP="dailout" ''; - #systemd.services.zigbee2mqtt = { - # wantedBy = ["multi-user.target" ]; - # after = [ "network.target" ]; - # description = "Run zigbee2mqtt as daemon"; - # environment.ZIGBEE2MQTT_DATA = "/var/lib/zigbee2mqtt"; - # serviceConfig = { - # WorkingDirectory = ''${pkg}/lib/node_modules/zigbee2mqtt''; - # ExecStart = ''${pkgs.nodejs-12_x}/bin/node index.js''; - # StandardOutput = "inherit"; - # StandardError = "inherit"; - # Restart = "always"; - # User = "z2m"; - # StateDirectory = "zigbee2mqtt"; - # #DeviceAllow = "/dev/cc2531 rw"; - # }; - #}; + + system.activationScripts.installZigbee = '' + install -d /var/lib/zigbee2mqtt + ''; + + docker-containers.zigbee2mqtt = { + image = "koenkk/zigbee2mqtt"; + extraDockerOptions = [ "--device=/dev/cc2531:/dev/cc2531" ]; + volumes = ["/var/lib/zigbee2mqtt:/app/data"]; + }; + state = [ "/var/lib/zigbee2mqtt/configuration.yaml" "/var/lib/zigbee2mqtt/state.json" ]; } -- cgit v1.2.3 From 0f93e2d02aa7bd63771a3ad41b0b0ffffbc0c564 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 3 Mar 2020 21:19:19 +0100 Subject: ma ham: cleanup --- makefu/2configs/ham/lib/default.nix | 1 + makefu/2configs/ham/multi/timer.nix | 123 ------------------------------ makefu/2configs/ham/multi/zigbee2mqtt.nix | 38 +-------- makefu/2configs/ham/sensor/outside.nix | 6 -- 4 files changed, 2 insertions(+), 166 deletions(-) delete mode 100644 makefu/2configs/ham/multi/timer.nix diff --git a/makefu/2configs/ham/lib/default.nix b/makefu/2configs/ham/lib/default.nix index c2d7916c1..45c86138b 100644 --- a/makefu/2configs/ham/lib/default.nix +++ b/makefu/2configs/ham/lib/default.nix @@ -40,4 +40,5 @@ in entity = "firetv"; }; }; + zigbee.prefix = "/ham/zigbee"; } diff --git a/makefu/2configs/ham/multi/timer.nix b/makefu/2configs/ham/multi/timer.nix deleted file mode 100644 index eafb7841d..000000000 --- a/makefu/2configs/ham/multi/timer.nix +++ /dev/null @@ -1,123 +0,0 @@ -# Provides: -# timer -# automation -# script - -# Needs: -# sensor.zigbee_btn1_click -# notify.telegrambot -let - button = "sensor.zigbee_btn1_click"; -in { - timer.kurzzeitwecker = - { - name = "Zigbee Kurzzeitwecker"; - duration = 300; - }; - script.add_5_minutes_to_kurzzeitwecker = - { - alias = "Add 5 minutes to kurzzeitwecker"; - sequence = [ - { service = "timer.pause"; - entity_id = "timer.kurzzeitwecker"; - } - { service = "timer.start"; - data_template = { - entity_id = "timer.kurzzeitwecker"; - duration = '' - {% set r = state_attr('timer.wecker', 'remaining') ~ '-0000' %} - {% set t = strptime(r, '%H:%M:%S.%f%z') %} - {{ (as_timestamp(t) + 300) | timestamp_custom('%H:%M:%S', false) }} - ''; - }; - } - ]; - }; - automation = - [ - { - alias = "Start Timer 5min"; - trigger = { - platform = "state"; - entity_id = button; - to = "single"; - }; - condition = - { condition = "state"; - entity_id = "timer.kurzzeitwecker"; - state = "idle"; - }; - - action = [ - { service = "timer.start"; - entity_id = "timer.kurzzeitwecker"; - duration = "00:05:00"; - } - { - service = "notify.telegrambot"; - data = { - title = "Timer gestartet"; - message = "Timer auf 5 minuten gestellt"; - }; - } - ]; - } - { - alias = "Start Timer 10min"; - trigger = { - platform = "state"; - entity_id = button; - to = "double"; - }; - condition = - { - condition = "state"; - entity_id = "timer.kurzzeitwecker"; - state = "idle"; - }; - action = - [ - { - service = "timer.start"; - entity_id = "timer.kurzzeitwecker"; - duration = "00:10:00"; - } - { - service = "notify.telegrambot"; - data = { - title = "Timer gestartet"; - message = "Timer auf 10 minuten gestellt"; - }; - } - ]; - } - { - alias = "Stop timer on triple click"; - trigger = - { - platform = "state"; - entity_id = button; - to = "triple"; - }; - condition = - { - condition = "state"; - entity_id = "timer.kurzzeitwecker"; - state = "active"; - }; - - action = [ - { - service = "timer.stop"; - entity_id = "timer.kurzzeitwecker"; - } - { - service = "notify.telegrambot"; - data = { - title = "Timer gestoppt"; - }; - } - ]; - } - ]; -} diff --git a/makefu/2configs/ham/multi/zigbee2mqtt.nix b/makefu/2configs/ham/multi/zigbee2mqtt.nix index ba81b1298..947eb5517 100644 --- a/makefu/2configs/ham/multi/zigbee2mqtt.nix +++ b/makefu/2configs/ham/multi/zigbee2mqtt.nix @@ -8,43 +8,10 @@ let inherit (import ../lib) zigbee; prefix = zigbee.prefix; - xiaomi_btn = name: [ - (zigbee.battery name) - (zigbee.linkquality name) - (zigbee.click name) - ]; - xiaomi_temp = name: [ - (zigbee.battery name) - (zigbee.linkquality name) - (zigbee.temperature name) - (zigbee.humidity name) - (zigbee.pressure name) - ]; - xiaomi_contact = name: [ - (zigbee.battery name) - (zigbee.linkquality name) - (zigbee.contact name) - ]; - router_link = name: [ - (zigbee.linkquality name) - ]; - router_bin = name: [ - (zigbee.state name) - ]; in { sensor = - (xiaomi_btn "btn1") - ++ (xiaomi_btn "btn2") - ++ (xiaomi_btn "btn3") - - ++ (xiaomi_temp "temp1") - ++ (xiaomi_temp "temp2") - ++ (xiaomi_temp "temp3") - - ++ (router_link "router1") - ++ (router_link "router2") - ++ [ + [ # Sensor for monitoring the bridge state { platform = "mqtt"; @@ -69,9 +36,6 @@ in { icon = "mdi:chip"; } ]; - binary_sensor = - (router_bin "router1") - ++ (router_bin "router2"); switch = [ { platform = "mqtt"; diff --git a/makefu/2configs/ham/sensor/outside.nix b/makefu/2configs/ham/sensor/outside.nix index 8436b8de2..c46b35ba3 100644 --- a/makefu/2configs/ham/sensor/outside.nix +++ b/makefu/2configs/ham/sensor/outside.nix @@ -17,10 +17,4 @@ units = "si" ; scan_interval = "00:30:00"; } - { platform = "luftdaten"; - name = "Muehlhausen"; - show_on_map = true; - sensor_id = "679"; - sensors.monitored_conditions = [ "P1" "P2" ]; - } ] -- cgit v1.2.3 From 5a17797ba942c1615ad83d1b085d2af2120c4fdd Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 3 Mar 2020 21:19:46 +0100 Subject: ma ham: prepare flurlicht --- makefu/2configs/ham/multi/flurlicht.nix | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 makefu/2configs/ham/multi/flurlicht.nix diff --git a/makefu/2configs/ham/multi/flurlicht.nix b/makefu/2configs/ham/multi/flurlicht.nix new file mode 100644 index 000000000..25eb78b7f --- /dev/null +++ b/makefu/2configs/ham/multi/flurlicht.nix @@ -0,0 +1,57 @@ +# provides: +# light +# automation +# binary_sensor +let + hlib = (import ../lib); + tasmota = hlib.tasmota; +in +{ + binary_sensor = [ + (tasmota.motion { name = "Flur Bewegung"; host = "flurlicht";}) + ]; + 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"; + } + ]; + } + ]; +} -- cgit v1.2.3 From ff29e9067a7f014c690fd2878f3e26425554a8cb Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:34:29 +0100 Subject: ma pkgs.hydra-check: init --- makefu/2configs/bureautomation/camera/stuttgart.nix | 12 ++++++++++++ makefu/5pkgs/hydra-check/default.nix | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 makefu/2configs/bureautomation/camera/stuttgart.nix create mode 100644 makefu/5pkgs/hydra-check/default.nix diff --git a/makefu/2configs/bureautomation/camera/stuttgart.nix b/makefu/2configs/bureautomation/camera/stuttgart.nix new file mode 100644 index 000000000..99eecd5d9 --- /dev/null +++ b/makefu/2configs/bureautomation/camera/stuttgart.nix @@ -0,0 +1,12 @@ + +let + cam = name: still_image_url: + { + inherit name still_image_url; + platform = "generic"; + }; +in [ + ( cam "Max-Eyth-See" https://www.wav-stuttgart.de/webcam/_/webcam1.jpg ) + ( cam "Wilhelma" http://webcam.wilhelma.de/webcam02/webcam02.jpg ) + ( cam "Wilhelma" http://webcam.wilhelma.de/webcam02/webcam02.jpg ) +] diff --git a/makefu/5pkgs/hydra-check/default.nix b/makefu/5pkgs/hydra-check/default.nix new file mode 100644 index 000000000..b9930b4f4 --- /dev/null +++ b/makefu/5pkgs/hydra-check/default.nix @@ -0,0 +1,21 @@ +{ python3Packages, fetchFromGitHub }: + +with python3Packages; +buildPythonPackage rec { + name = "hydra-check"; + version = "1.0.0"; + + src = fetchFromGitHub { + owner = "makefu"; + repo = "hydra-check"; + rev = version; + sha256 = "0359s9rvl2q23a3yddhbn6w2sd5r1f1jl6whyik7qql7blpcvyi7"; + }; + propagatedBuildInputs = [ + docopt + requests + beautifulsoup4 + ]; + + checkInputs = [ black jq ]; +} -- cgit v1.2.3 From bf5a5fb3e0f70aeda37900e1c5ce478a2b07a764 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:37:24 +0100 Subject: ma pkgs.studio-link: use install, cleanup --- makefu/5pkgs/studio-link/default.nix | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/makefu/5pkgs/studio-link/default.nix b/makefu/5pkgs/studio-link/default.nix index 8c796b43b..8786f3574 100644 --- a/makefu/5pkgs/studio-link/default.nix +++ b/makefu/5pkgs/studio-link/default.nix @@ -11,17 +11,22 @@ stdenv.mkDerivation rec { name = "studio-link-${version}"; version = "17.03.1-beta"; + src = fetchurl { url = "https://github.com/Studio-Link-v2/backend/releases/download/v${version}/studio-link-standalone-linux.zip"; sha256 = "1y21nymin7iy64hcffc8g37fv305b1nvmh944hkf7ipb06kcx6r9"; }; - nativeBuildInputs = [ unzip autoPatchelfHook ]; - buildInputs = [ - alsaLib - openssl_1_0_2 - zlib - libjack2 + nativeBuildInputs = [ + unzip + autoPatchelfHook + ]; + + buildInputs = [ + alsaLib + openssl_1_0_2 + zlib + libjack2 ]; unpackPhase = '' @@ -29,9 +34,7 @@ stdenv.mkDerivation rec { ''; installPhase = '' - mkdir -p $out/bin - cp studio-link-standalone $out/bin/studio-link - chmod +x $out/bin/studio-link + install -m755 -D studio-link-standalone $out/bin/studio-link ''; meta = with stdenv.lib; { -- cgit v1.2.3 From a2d343e8070097de9c62f86dfd8cca883f55cd53 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:39:32 +0100 Subject: ma pkgs.hydra-check: move to custom --- makefu/5pkgs/custom/hydra-check/default.nix | 19 +++++++++++++++++++ makefu/5pkgs/hydra-check/default.nix | 21 --------------------- 2 files changed, 19 insertions(+), 21 deletions(-) create mode 100644 makefu/5pkgs/custom/hydra-check/default.nix delete mode 100644 makefu/5pkgs/hydra-check/default.nix diff --git a/makefu/5pkgs/custom/hydra-check/default.nix b/makefu/5pkgs/custom/hydra-check/default.nix new file mode 100644 index 000000000..512ceec9f --- /dev/null +++ b/makefu/5pkgs/custom/hydra-check/default.nix @@ -0,0 +1,19 @@ +{ docopt, requests, beautifulsoup4, fetchFromGitHub, buildPythonPackage }: + +buildPythonPackage rec { + name = "hydra-check"; + version = "1.0.0"; + + src = fetchFromGitHub { + owner = "makefu"; + repo = "hydra-check"; + rev = version; + sha256 = "0359s9rvl2q23a3yddhbn6w2sd5r1f1jl6whyik7qql7blpcvyi7"; + }; + propagatedBuildInputs = [ + docopt + requests + beautifulsoup4 + ]; + doCheck = false; # no tests +} diff --git a/makefu/5pkgs/hydra-check/default.nix b/makefu/5pkgs/hydra-check/default.nix deleted file mode 100644 index b9930b4f4..000000000 --- a/makefu/5pkgs/hydra-check/default.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ python3Packages, fetchFromGitHub }: - -with python3Packages; -buildPythonPackage rec { - name = "hydra-check"; - version = "1.0.0"; - - src = fetchFromGitHub { - owner = "makefu"; - repo = "hydra-check"; - rev = version; - sha256 = "0359s9rvl2q23a3yddhbn6w2sd5r1f1jl6whyik7qql7blpcvyi7"; - }; - propagatedBuildInputs = [ - docopt - requests - beautifulsoup4 - ]; - - checkInputs = [ black jq ]; -} -- cgit v1.2.3 From a72d8c58747de4b554b6f9643ba7e6db9249cf8a Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:40:11 +0100 Subject: ma pkgs: add cc-tool,liveproxy --- makefu/5pkgs/cc-tool/default.nix | 32 +++++++++++++++++++++++++++++++ makefu/5pkgs/custom/liveproxy/default.nix | 30 +++++++++++++++++++++++++++++ makefu/5pkgs/default.nix | 2 ++ 3 files changed, 64 insertions(+) create mode 100644 makefu/5pkgs/cc-tool/default.nix create mode 100644 makefu/5pkgs/custom/liveproxy/default.nix diff --git a/makefu/5pkgs/cc-tool/default.nix b/makefu/5pkgs/cc-tool/default.nix new file mode 100644 index 000000000..71d5f8a7d --- /dev/null +++ b/makefu/5pkgs/cc-tool/default.nix @@ -0,0 +1,32 @@ +{ stdenv, lib, pkgs, autoreconfHook ,libtool, fetchFromGitHub, boost, libusb1, +pkgconfig,file }: +stdenv.mkDerivation rec { + pname = "cc-tool"; + version = "407fd7e"; + name = "${pname}-${version}"; + + src = fetchFromGitHub { + owner = "dashesy"; + repo = "cc-tool"; + rev = version; + sha256 = "1q7zqib4rn5l8clk2hj7078rfyrjdwxzpyg4r10is31lq22zhxqj"; + }; + + buildInputs = [ boost libtool libusb1 pkgconfig autoreconfHook ]; + + preConfigure = '' + substituteInPlace configure \ + --replace /usr/bin/file ${file}/bin/file + + ''; + + postInstall = '' + install -m755 -D ./udev/90-cc-debugger.rules $out/etc/udev/rules.d/90-cc-debugger.rules + ''; + + meta = { + homepage = https://github.com/AKuHAK/hdl-dump ; + description = "copy isos to psx hdd"; + license = lib.licenses.gpl2; + }; +} diff --git a/makefu/5pkgs/custom/liveproxy/default.nix b/makefu/5pkgs/custom/liveproxy/default.nix new file mode 100644 index 000000000..195879c89 --- /dev/null +++ b/makefu/5pkgs/custom/liveproxy/default.nix @@ -0,0 +1,30 @@ +{ lib +, buildPythonPackage +, fetchPypi +, streamlink +}: + +buildPythonPackage rec { + pname = "liveproxy"; + version = "0.3.0"; + + src = fetchPypi { + inherit pname version; + sha256 = "70ba2f7b57cdf19c6d971a434ed47cccb5fdfe4621baa76a3f6221e75b7f2729"; + }; + + # # Package conditions to handle + # # might have to sed setup.py and egg.info in patchPhase + # # sed -i "s/...//" + # streamlink (>=1.1.1) + propagatedBuildInputs = [ + streamlink + ]; + + meta = with lib; { + description = "LiveProxy is a local Proxyserver between Streamlink and an URL"; + homepage = https://github.com/back-to/liveproxy; + license = licenses.BSD 2-Clause "Simplified" License; + # maintainers = [ maintainers. ]; + }; +} diff --git a/makefu/5pkgs/default.nix b/makefu/5pkgs/default.nix index bbd99ffe7..1b07fd5f8 100644 --- a/makefu/5pkgs/default.nix +++ b/makefu/5pkgs/default.nix @@ -40,6 +40,8 @@ in { qcma = super.pkgs.libsForQt5.callPackage ./custom/qcma { }; inherit (callPackage ./devpi {}) devpi-web ; nodemcu-uploader = super.pkgs.callPackage ./nodemcu-uploader {}; + liveproxy = super.pkgs.python3Packages.callPackage ./custom/liveproxy {}; + hydra-check = super.pkgs.python3Packages.callPackage ./custom/hydra-check {}; } // (mapAttrs (_: flip callPackage {}) -- cgit v1.2.3 From f28d580a4f86041d6f0df9482315d36673d8ef9d Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:41:01 +0100 Subject: ma bureautomation: use discovery, cleanup --- .../bureautomation/automation/daily-news.nix | 20 ++++++++ .../2configs/bureautomation/automation/quotes.nix | 4 ++ .../bureautomation/automation/schlechteluft.nix | 3 -- .../2configs/bureautomation/camera/stuttgart.nix | 16 +++++- makefu/2configs/bureautomation/default.nix | 21 +++++--- makefu/2configs/bureautomation/deps/aresponses.nix | 38 ++++++++++++++ .../2configs/bureautomation/multi/10h_timers.nix | 59 ++++++++++++++-------- .../bureautomation/multi/daily-standup.nix | 4 +- makefu/2configs/bureautomation/multi/frosch.nix | 6 ++- .../2configs/bureautomation/multi/mittagessen.nix | 6 +-- makefu/2configs/bureautomation/person/team.nix | 19 ++++--- makefu/2configs/bureautomation/puppy-proxy.nix | 5 ++ .../2configs/bureautomation/script/multi_blink.nix | 12 +++++ makefu/2configs/bureautomation/stream/puppies.nix | 4 ++ 14 files changed, 172 insertions(+), 45 deletions(-) create mode 100644 makefu/2configs/bureautomation/automation/daily-news.nix create mode 100644 makefu/2configs/bureautomation/automation/quotes.nix create mode 100644 makefu/2configs/bureautomation/deps/aresponses.nix create mode 100644 makefu/2configs/bureautomation/puppy-proxy.nix create mode 100644 makefu/2configs/bureautomation/stream/puppies.nix diff --git a/makefu/2configs/bureautomation/automation/daily-news.nix b/makefu/2configs/bureautomation/automation/daily-news.nix new file mode 100644 index 000000000..2bafe4795 --- /dev/null +++ b/makefu/2configs/bureautomation/automation/daily-news.nix @@ -0,0 +1,20 @@ +[ + { + alias = "Daily news for Felix"; + trigger = { + platform = "time"; + at = "07:35:00"; + }; + action = + [ + { + service = "notify.telegrambot"; + data_template = { + title = "Daily News"; + # TODO + message = ""; + }; + } + ]; + } +] diff --git a/makefu/2configs/bureautomation/automation/quotes.nix b/makefu/2configs/bureautomation/automation/quotes.nix new file mode 100644 index 000000000..c4625ae30 --- /dev/null +++ b/makefu/2configs/bureautomation/automation/quotes.nix @@ -0,0 +1,4 @@ +# heiss +Lieber Freund, was für ein Sommer! Ich denke Sie mir im Zimmer sitzend, mehr Omelette als Mensch. +Sommer ist die Zeit, in der es zu heiß ist, um das zu tun, wozu es im Winter zu kalt war. + diff --git a/makefu/2configs/bureautomation/automation/schlechteluft.nix b/makefu/2configs/bureautomation/automation/schlechteluft.nix index 8787ee280..370334743 100644 --- a/makefu/2configs/bureautomation/automation/schlechteluft.nix +++ b/makefu/2configs/bureautomation/automation/schlechteluft.nix @@ -66,9 +66,6 @@ in [ language = "de"; }; } - { service = "notify.matrix_notify"; - data_template.message = "Schlechte Luft Alarm seit ${toString long_threshold} Minuten ({{states.sensor.air_quality.state_with_unit}})!"; - } ]; } ] diff --git a/makefu/2configs/bureautomation/camera/stuttgart.nix b/makefu/2configs/bureautomation/camera/stuttgart.nix index 99eecd5d9..78cbeb3e2 100644 --- a/makefu/2configs/bureautomation/camera/stuttgart.nix +++ b/makefu/2configs/bureautomation/camera/stuttgart.nix @@ -8,5 +8,19 @@ let in [ ( cam "Max-Eyth-See" https://www.wav-stuttgart.de/webcam/_/webcam1.jpg ) ( cam "Wilhelma" http://webcam.wilhelma.de/webcam02/webcam02.jpg ) - ( cam "Wilhelma" http://webcam.wilhelma.de/webcam02/webcam02.jpg ) + ( cam "Marktplatz" https://webcam.stuttgart.de/wcam007/current.jpg ) + ( cam "Schoch Areal" https://webcam.stuttgart.de/wcam004/current.jpg ) + ( cam "Leuze" https://webcam.stuttgart.de/wcam005/current.jpg ) + ( cam "Straße Wilhelma" https://webcam.stuttgart.de/wcam006/current.jpg ) + ( cam "Fernsehturm 1" http://webcam.fernsehturmstuttgart.com/current.jpg ) + ( cam "Fernsehturm 2" http://webcam.fernsehturmstuttgart.com/current2.jpg ) + ( cam "Feuerbach Lemberg" http://www.regio7.de/handy/current.jpg ) + ( cam "Flughafen Stuttgart 1" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam2.jpg ) + ( cam "Flughafen Stuttgart 2" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam5.jpg ) + ( cam "Flughafen Stuttgart 3" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam7.jpg ) + ( cam "S21 1" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-03/s21-turm03.jpg ) + ( cam "S21 2" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-02/s21-turm-02.jpg ) + ( cam "S21 3" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-01/s21-turm-01.jpg ) + ( cam "S21 4" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Jaegerstrasse-Nordkopf/s21-jaegerstrassse-nordkopf.jpg ) + ( cam "S21 5" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Bahndirektion-Nord/S21-Bundesbahndirektion-Nord.jpg ) ] diff --git a/makefu/2configs/bureautomation/default.nix b/makefu/2configs/bureautomation/default.nix index c55bc1d14..3c1659558 100644 --- a/makefu/2configs/bureautomation/default.nix +++ b/makefu/2configs/bureautomation/default.nix @@ -11,6 +11,7 @@ in { imports = [ ./ota.nix ./comic-updater.nix + ./puppy-proxy.nix ]; networking.firewall.allowedTCPPorts = [ 8123 ]; state = [ "/var/lib/hass/known_devices.yaml" ]; @@ -33,13 +34,14 @@ in { ''; })).override { extraPackages = ps: with ps; [ - pkgs.pico2wave + pkgs.picotts python-forecastio jsonrpc-async jsonrpc-websocket mpd2 (callPackage ./deps/openwrt-luci-rpc.nix { }) ]; }; autoExtraComponents = true; config = { + discovery = {}; homeassistant = { name = "Bureautomation"; time_zone = "Europe/Berlin"; @@ -72,6 +74,8 @@ in { }; matrix = matrix.matrix; mqtt = { + discovery = true; + discovery_prefix = "homeassistant"; broker = "localhost"; port = 1883; client_id = "home-assistant"; @@ -124,7 +128,7 @@ in { frosch.script ten_hours.script mittagessen.script - standup.script + # standup.script ]; binary_sensor = (import ./binary_sensor/buttons.nix) @@ -145,7 +149,8 @@ in { camera = (import ./camera/verkehrskamera.nix) - ++ (import ./camera/comic.nix); + ++ (import ./camera/comic.nix) + ++ (import ./camera/stuttgart.nix); person = (import ./person/team.nix ); @@ -198,9 +203,10 @@ in { "switch.blitzdings" "switch.fernseher" "switch.feuer" + "switch.frosch_blasen" "light.status_felix" - "light.status_daniel" - "light.buslicht" + # "light.status_daniel" + # "light.buslicht" ]; team = [ "person.thorsten" @@ -212,6 +218,7 @@ in { "person.thierry" "person.frank" "person.emeka" + "person.tancrede" #"device_tracker.felix_phone" #"device_tracker.ecki_tablet" #"device_tracker.daniel_phone" @@ -228,6 +235,7 @@ in { "camera.Baumarkt" "camera.Autobahn_Heilbronn" "camera.Autobahn_Singen" + "camera.puppies" "camera.poorly_drawn_lines" ]; nachtlicht = [ @@ -264,7 +272,6 @@ in { outside = [ # "sensor.ditzingen_pm10" # "sensor.ditzingen_pm25" - "sensor.dark_sky_icon" "sensor.dark_sky_temperature" "sensor.dark_sky_humidity" "sensor.dark_sky_uv_index" @@ -282,7 +289,7 @@ in { ++ (import ./automation/hass-restart.nix) ++ ten_hours.automation ++ matrix.automation - ++ standup.automation + # ++ standup.automation ++ frosch.automation ++ mittagessen.automation; device_tracker = (import ./device_tracker/openwrt.nix ); diff --git a/makefu/2configs/bureautomation/deps/aresponses.nix b/makefu/2configs/bureautomation/deps/aresponses.nix new file mode 100644 index 000000000..9e64d2f65 --- /dev/null +++ b/makefu/2configs/bureautomation/deps/aresponses.nix @@ -0,0 +1,38 @@ +{ lib +, buildPythonPackage +, fetchPypi +# propagatedBuildInputs +, aiohttp +# buildInputs +, pytest +, pytest-asyncio +}: + +buildPythonPackage rec { + pname = "aresponses"; + version = "1.1.1"; + + src = fetchPypi { + inherit pname version; + sha256 = "d1d6ef52b9a97142d106688cf9b112602ef3dc66f6368de8f91f47241d8cfc9c"; + }; + + propagatedBuildInputs = [ + aiohttp + ]; + + buildInputs = [ + pytest + pytest-asyncio + ]; + + # tests only distributed via git repository, not pypi + doCheck = false; + + meta = with lib; { + description = "Asyncio testing server"; + homepage = "https://github.com/circleup/aresponses"; + license = licenses.mit; + maintainers = [ maintainers.makefu ]; + }; +} diff --git a/makefu/2configs/bureautomation/multi/10h_timers.nix b/makefu/2configs/bureautomation/multi/10h_timers.nix index 73709e738..a30fb28b0 100644 --- a/makefu/2configs/bureautomation/multi/10h_timers.nix +++ b/makefu/2configs/bureautomation/multi/10h_timers.nix @@ -2,6 +2,8 @@ let persons = [ "frank" "daniel" "thorsten" "carsten" "ecki" "felix" "thierry" # tjeri + "emeka" + "tancrede" ]; random_zu_lange = name: ''{{ [ "Du musst jetzt endlich nach Hause gehen ${name}!", @@ -20,6 +22,7 @@ let random_announce = name: ''{{ [ "${name} is in da House", "Ahoi ${name}", + "Hallöchen Popöchen ${name}", "Moinsen ${name}", "Moin Moin ${name}", "Palim, Palim ${name}", @@ -55,7 +58,7 @@ let "Und es startet für ${name} wieder ein Tag im Paradies", "Lieber ${name}, Markus Keck hat dich bereits drei mal Versucht anzurufen!", "Trotz schwerer Männergrippe ist ${name} heute im Büro erschienen.", - "${name} kenne keine Parteien mehr, ${name} kenne nur noch Arbeitsplätze", + "${name} kennt keine Parteien mehr, ${name} kennt nur noch Arbeitsplätze", "${name}, Frage nicht, was dein Arbeitsplatz für dich tun kann. Frage, was du für deinen Arbeitsplatz tun kannst", "${name} läuft bis in den Jemen - für sein Unternehmen. ${name} schwimmt bis nach Birma - für seine Firma", "Der Cyberian ${name} ist gekommen um die Bahnwelt vor Cyber-Angriffen zu schützen", @@ -121,7 +124,6 @@ let { alias = "start ${name} 10h"; trigger = { platform = "state"; - # TODO: ecki entity_id = [ "person.${name}"]; from = "not_home"; to = "home"; @@ -129,13 +131,11 @@ let condition = { condition = "and"; conditions = [ - { - condition = "state"; + { condition = "state"; entity_id = "timer.${name}_10h"; state = "idle"; } - { - condition = "time"; + { condition = "time"; after = "06:00:00"; before = "12:00:00"; } @@ -146,8 +146,8 @@ let entity_id = [ "timer.${name}_10h" ] ; } { service = "homeassistant.turn_on"; - entity_id = [ - # "switch.fernseher" + entity_id = + [ "switch.fernseher" "script.blitz_10s" "script.announce_${name}" ]; @@ -155,30 +155,45 @@ let ]; } + { alias = "pommes announce ${name}"; + trigger = + { platform = "event"; + event_type = "timer.started"; + event_data.entity_id = "timer.${name}_10h"; + }; + + condition = + { condition = "state"; + entity_id = "binary_sensor.pommes"; + state = "on"; + }; + + action = + { service = "homeassistant.turn_on"; + entity_id = "script.blasen_10s" ; + }; + } + { alias = "Zu lange ${name}!"; trigger = - { - platform = "event"; + { platform = "event"; event_type = "timer.finished"; event_data.entity_id = "timer.${name}_10h"; }; condition = - { - condition = "state"; + { condition = "state"; entity_id = "person.${name}"; state = "home"; }; action = - [ - { service = "homeassistant.turn_on"; - entity_id = [ - "script.blitz_10s" - "script.zu_lange_${name}" - ]; - } - ]; + { service = "homeassistant.turn_on"; + entity_id = [ + "script.blitz_10s" + "script.zu_lange_${name}" + ]; + }; } ]; in @@ -187,7 +202,7 @@ in (map tmr_10h persons); automation = (lib.flatten (map automation_10h persons)); script = lib.fold lib.recursiveUpdate {} ( - (map (p: announce_user p) persons) ++ - (map (p: zu_lange_user p) persons) + (map announce_user persons) ++ + (map zu_lange_user persons) ); } diff --git a/makefu/2configs/bureautomation/multi/daily-standup.nix b/makefu/2configs/bureautomation/multi/daily-standup.nix index f5bd85b9d..38fb22c1a 100644 --- a/makefu/2configs/bureautomation/multi/daily-standup.nix +++ b/makefu/2configs/bureautomation/multi/daily-standup.nix @@ -3,9 +3,9 @@ let random_daily_text = ''{{ [ "Es ist so weit, es ist Standup Zeit!", "Zehn Uhr Fünfunddreissig ist genau die richtige Zeit für ein Standup!", - "Hat jeder seine Hausaufgaben gemacht? Bitte einmal aufstehen und den Zettel nach rechts geben", + "Hat jeder seine zum Standup seine Hausaufgaben gemacht. Bitte einmal aufstehen und den Zettel nach rechts geben", "Aufstehen zum Appell, es wird die Anwesenheit kontrolliert!", - "Hallo Kinder, wisst ihr welche Zeit es ist??? ... Genau! ... Standup Zeit!", + "Hallo Kinder, wisst ihr welche Zeit es ist ... Genau ... Standup Zeit!", "Morgens, halb elf in Deutschland - das Standupchen" ] | random }}''; in { diff --git a/makefu/2configs/bureautomation/multi/frosch.nix b/makefu/2configs/bureautomation/multi/frosch.nix index c0e267b69..816539d46 100644 --- a/makefu/2configs/bureautomation/multi/frosch.nix +++ b/makefu/2configs/bureautomation/multi/frosch.nix @@ -1,5 +1,6 @@ { lib }: # needs: binary_sensor.pommes +# notify.matrix_notify let random_pommes = '' {{ [ "Nur ein Pommes Tag ist ein guter Tag", @@ -51,7 +52,7 @@ in { { alias = "Pommeszeit"; trigger = { platform = "time"; - at = "12:15:00"; + at = "11:00:00"; }; condition = { condition = "state"; @@ -89,6 +90,9 @@ in { language = "de"; }; } + { service = "notify.matrix_notify"; + data_template.message = random_pommes; + } ]; }; }; diff --git a/makefu/2configs/bureautomation/multi/mittagessen.nix b/makefu/2configs/bureautomation/multi/mittagessen.nix index 3ec70998d..2a9993e92 100644 --- a/makefu/2configs/bureautomation/multi/mittagessen.nix +++ b/makefu/2configs/bureautomation/multi/mittagessen.nix @@ -22,9 +22,9 @@ let "Heute bei Aramark: Rezepte aus Ländern, von denen Ihr noch nie gehört habt, Deutsch zubereitet", "Heute bei Aramark im Angebot: Scheiss mit Reis oder Reste von Freitag", "MHHHH es ist wieder mal so weit, lecker Bayerisch Kraut mit asiatischen Nudeln", - "Es ist 12 Uhr 30 und Heute gibt es Pommes - vielleicht", - "Heute gibt es Pommes - leider nicht einzeln zu verkaufen, da die Schälchen alle sind", - "Heute gibt es Pommes - verarscht! Natürlich gibt es nur salzlosen Reis, oder salzlose Nudeln.", + "Es ist 12 Uhr 30 und Heute gibt es nur Pommes, wenn der Pommesfrosch Blasen gespuckt hat.", + "Heute gibt es Pommes leider nicht einzeln zu verkaufen, da die Schälchen alle sind", + "Heute gibt es Pommes, verarscht! Natürlich gibt es nur salzlosen Reis, oder salzlose Nudeln.", "Heute auf dem Speiseplan: Sushi vom Vortag", "Aramark Kantinenessen: Der Hunger treibt es rein, der Geiz hält es drin.", "Das Essen in der Snackeria sieht heute wie die bessere Alternative aus", diff --git a/makefu/2configs/bureautomation/person/team.nix b/makefu/2configs/bureautomation/person/team.nix index fc2d9ba17..2a15abaf5 100644 --- a/makefu/2configs/bureautomation/person/team.nix +++ b/makefu/2configs/bureautomation/person/team.nix @@ -50,16 +50,23 @@ "device_tracker.emeka_phone" ]; } - #{ name = "Sabine"; - # id = 9; - # device_trackers = [ - # "device_tracker.sabine_phone" - # ]; - #} + { name = "Sabine"; + id = 9; + device_trackers = [ + "device_tracker.sabine_phone" + ]; + } { name = "Tobias"; id = 10; device_trackers = [ "device_tracker.tobias_phone" ]; } + { name = "Tancrede"; + id = 11; + device_trackers = [ + "device_tracker.tancrede_phone" + "device_tracker.tancrede_laptop" + ]; + } ] diff --git a/makefu/2configs/bureautomation/puppy-proxy.nix b/makefu/2configs/bureautomation/puppy-proxy.nix new file mode 100644 index 000000000..9e3542509 --- /dev/null +++ b/makefu/2configs/bureautomation/puppy-proxy.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: +# streamlink 'https://www.ustream.tv/channel/maximilian-schnauzers-cam4' worst --player-external-http --player-external-http-port 15321 --player-passthrough rtsp --retry-streams 60 +{ + environment.systemPackages = [ pkgs.liveproxy ]; +} diff --git a/makefu/2configs/bureautomation/script/multi_blink.nix b/makefu/2configs/bureautomation/script/multi_blink.nix index 5076111ac..e6acdc303 100644 --- a/makefu/2configs/bureautomation/script/multi_blink.nix +++ b/makefu/2configs/bureautomation/script/multi_blink.nix @@ -36,6 +36,18 @@ in { count = 1; alias = "blitz for 10 seconds"; }); + blasen_10s = (flash_entity { + entity = "switch.frosch_blasen"; + delay = 10000; + count = 1; + alias = "blasen for 10 seconds"; + }); + blasen_30s = (flash_entity { + entity = "switch.frosch_blasen"; + delay = 30000; + count = 1; + alias = "blasen for 30 seconds"; + }); schlechteluft = (flash_entity { entity = "switch.bauarbeiterlampe"; alias = "Schlechte Luft Lampe 5 secs"; diff --git a/makefu/2configs/bureautomation/stream/puppies.nix b/makefu/2configs/bureautomation/stream/puppies.nix new file mode 100644 index 000000000..d22be9ea6 --- /dev/null +++ b/makefu/2configs/bureautomation/stream/puppies.nix @@ -0,0 +1,4 @@ +[ + { stream_source = "http://127.0.0.1:53422/base64/c3RyZWFtbGluayBodHRwczovL3d3dy51c3RyZWFtLnR2L2NoYW5uZWwvbWF4aW1pbGlhbi1zY2huYXV6ZXJzLWNhbTIgd29yc3Q=/"; + } +] -- 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/automation/firetv_restart.nix | 39 +++++++++++++---------- makefu/2configs/ham/default.nix | 18 +++++++---- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/makefu/2configs/ham/automation/firetv_restart.nix b/makefu/2configs/ham/automation/firetv_restart.nix index 779092c73..1094d177f 100644 --- a/makefu/2configs/ham/automation/firetv_restart.nix +++ b/makefu/2configs/ham/automation/firetv_restart.nix @@ -1,4 +1,13 @@ -[ +let + cmd = command: { + service = "androidtv.adb_command"; + data = { + entity_id = "media_player.firetv_stick"; + inherit command; + }; + }; + sec = seconds: { delay.seconds = seconds; }; +in [ { alias = "Nightly reboot of firetv"; trigger = { @@ -6,21 +15,19 @@ at = "03:00:00"; }; action = [ - { - service = "androidtv.adb_command"; - data = { - entity_id = "media_player.firetv_stick"; - command = "reboot"; - }; - } - { delay.minutes = 2; } - { - service = "media_player.select_source"; - data = { - entity_id = "media_player.firetv_stick"; - source = "com.amazon.bueller.music"; - }; - } + (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/default.nix b/makefu/2configs/ham/default.nix index 3fbe1187f..53723299c 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 From f88e30e5ad906d946852891b6d668d8910c943b2 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:42:08 +0100 Subject: ma home-manager: update mail with mbsync --- makefu/2configs/home-manager/mail.nix | 18 +++++++++++ makefu/2configs/home-manager/zsh.nix | 61 ++--------------------------------- 2 files changed, 20 insertions(+), 59 deletions(-) diff --git a/makefu/2configs/home-manager/mail.nix b/makefu/2configs/home-manager/mail.nix index 467e0d7a0..ba29e86a4 100644 --- a/makefu/2configs/home-manager/mail.nix +++ b/makefu/2configs/home-manager/mail.nix @@ -1,6 +1,8 @@ { home-manager.users.makefu = { + programs.mbsync.enable = true; accounts.email.maildirBasePath = "/home/makefu/Mail"; + accounts.email.certificatesFile = "/etc/ssl/certs/ca-certificates.crt"; accounts.email.accounts.syntaxfehler = { address = "felix.richter@syntax-fehler.de"; userName = "Felix.Richter@syntax-fehler.de"; @@ -10,18 +12,34 @@ enable = true; }; }; + mbsync = { + enable = true; + create = "both"; + remove = "both"; + expunge = "both"; + patterns = [ "*" "!INBOX.Sent*"]; + }; smtp = { host = "syntax-fehler.de"; tls = { enable = true; }; }; + folders = { + sent = "Sent"; + trash = "Trash"; + inbox = "INBOX"; + drafts = "Drafts"; + }; msmtp.enable = true; notmuch.enable = true; offlineimap = { enable = true; postSyncHookCommand = "notmuch new"; extraConfig.remote = { + auth_mechanisms = "LOGIN"; + tls_level = "tls_secure"; + ssl_version = "tls1_2"; holdconnectionopen = true; idlefolders = "['INBOX']"; }; diff --git a/makefu/2configs/home-manager/zsh.nix b/makefu/2configs/home-manager/zsh.nix index d24969ef0..4cd9becc7 100644 --- a/makefu/2configs/home-manager/zsh.nix +++ b/makefu/2configs/home-manager/zsh.nix @@ -2,65 +2,8 @@ { imports = [ { #direnv - home-manager.users.makefu.home.packages = [ pkgs.direnv ]; - home-manager.users.makefu.home.file.".direnvrc".text = '' - use_nix() { - local path="$(nix-instantiate --find-file nixpkgs)" - - if [ -f "$${path}/.version-suffix" ]; then - local version="$(< $path/.version-suffix)" - elif [ -f "$path/.version" ]; then - local version="$(< $path/.version)" - else - local version="$(< $(< $path/.git/HEAD))" - fi - - local cache=".direnv/cache-''${version:-unknown}" - - if [[ ! -e "$cache" ]] || \ - [[ "$HOME/.direnvrc" -nt "$cache" ]] || \ - [[ .envrc -nt "$cache" ]] || \ - [[ default.nix -nt "$cache" ]] || \ - [[ shell.nix -nt "$cache" ]]; - then - [ -d .direnv ] || mkdir .direnv - local tmp=$(nix-shell --show-trace "$@" \ - --run "\"$direnv\" dump zsh") - echo "$tmp" > "$cache" - fi - - local path_backup=$PATH term_backup=$TERM - . "$cache" - - export PATH=$PATH:$path_backup TERM=$term_backup - - if [[ $# = 0 ]]; then - watch_file default.nix - watch_file shell.nix - fi - } - ''; - home-manager.users.makefu.programs.zsh.initExtra = '' - nixify() { - if [ ! -e ./.envrc ]; then - echo "use nix" > .envrc - direnv allow - fi - if [ ! -e default.nix ]; then - cat > default.nix <<'EOF' - with import {}; - stdenv.mkDerivation { - name = "env"; - buildInputs = [ - bashInteractive - ]; - } - EOF - ''${EDITOR:-vim} default.nix - fi - } - eval "$(direnv hook zsh)" - ''; + home-manager.users.makefu.home.packages = [ pkgs.direnv pkgs.nur.repos.kalbasit.nixify ]; + # home-manager.users.makefu.home.file.".direnvrc".text = ''''; } { # bat home-manager.users.makefu.home.packages = [ pkgs.bat ]; -- cgit v1.2.3 From 3e27de38fc3e9043187cd65986a799af3b356967 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:42:39 +0100 Subject: ma deployment: add board.euer, rss.euer --- .../2configs/deployment/board.euer.krebsco.de.nix | 15 ++++++++ .../deployment/docker/archiveteam-warrior.nix | 39 ++++++++++++++++++++ makefu/2configs/deployment/gecloudpad/default.nix | 43 ++++++++++++++++++++++ .../2configs/deployment/gecloudpad/gecloudpad.nix | 24 ++++++++++++ makefu/2configs/deployment/rss.euer.krebsco.de.nix | 14 +++++++ 5 files changed, 135 insertions(+) create mode 100644 makefu/2configs/deployment/board.euer.krebsco.de.nix create mode 100644 makefu/2configs/deployment/docker/archiveteam-warrior.nix create mode 100644 makefu/2configs/deployment/gecloudpad/default.nix create mode 100644 makefu/2configs/deployment/gecloudpad/gecloudpad.nix create mode 100644 makefu/2configs/deployment/rss.euer.krebsco.de.nix diff --git a/makefu/2configs/deployment/board.euer.krebsco.de.nix b/makefu/2configs/deployment/board.euer.krebsco.de.nix new file mode 100644 index 000000000..ca617976d --- /dev/null +++ b/makefu/2configs/deployment/board.euer.krebsco.de.nix @@ -0,0 +1,15 @@ +let + fqdn = "board.euer.krebsco.de"; + port = 13113; +in { + services.restya-board = { + enable = true; + virtualHost.listenPort = port; + }; + services.nginx.virtualHosts."${fqdn}" = { + enableACME = true; + forceSSL = true; + locations."/".proxyPass = "http://localhost:${toString port}"; + }; +} + diff --git a/makefu/2configs/deployment/docker/archiveteam-warrior.nix b/makefu/2configs/deployment/docker/archiveteam-warrior.nix new file mode 100644 index 000000000..8eef27a20 --- /dev/null +++ b/makefu/2configs/deployment/docker/archiveteam-warrior.nix @@ -0,0 +1,39 @@ +{ lib, ... }: +with lib; +let + port = ident: toString (28000 + ident); + instances = [ 1 2 3 4 5 6 7 8 9 ]; +in { + services.nginx.recommendedProxySettings = true; + services.nginx.virtualHosts."warrior.gum.r".locations = let + # TODO location "/" shows all warrior instances + proxy = ident: + { + "/warrior${toString ident}/" = { + proxyPass = "http://localhost:${port ident}/"; + # rewrite ^/info /warrior${toString ident}/info; + extraConfig = '' + sub_filter "http://warrior.gum.r/info" "http://warrior.gum.r/warrior${toString ident}/info"; + sub_filter_once off; + ''; + }; + + }; + in + foldl' mergeAttrs {} (map proxy instances); + docker-containers = let + container = ident: + { "archiveteam-warrior${toString ident}" = { + image = "archiveteam/warrior-dockerfile"; + ports = [ "127.0.0.1:${port ident}:8001" ]; + environment = { + DOWNLOADER = "makefu"; + SELECTED_PROJECT = "auto"; + CONCURRENT_ITEMS = "6"; + WARRIOR_ID = toString ident; + }; + }; + }; + in + foldl' mergeAttrs {} (map container instances); +} diff --git a/makefu/2configs/deployment/gecloudpad/default.nix b/makefu/2configs/deployment/gecloudpad/default.nix new file mode 100644 index 000000000..e13ec6ae6 --- /dev/null +++ b/makefu/2configs/deployment/gecloudpad/default.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: +# more than just nginx config but not enough to become a module +let + wsgi-sock = "${workdir}/uwsgi-gecloudpad.sock"; + workdir = config.services.uwsgi.runDir; + gecloudpad = pkgs.python3Packages.callPackage ./gecloudpad.nix {}; +in { + + services.uwsgi = { + enable = true; + user = "nginx"; + # runDir = "/var/lib/photostore"; + plugins = [ "python3" ]; + instance = { + type = "emperor"; + vassals = { + gecloudpad = { + type = "normal"; + pythonPackages = self: with self; [ gecloudpad ]; + socket = wsgi-sock; + }; + }; + }; + }; + + services.nginx = { + enable = lib.mkDefault true; + virtualHosts."pad.binaergewitter.de" = { + enableACME = true; + forceSSL = true; + locations = { + "/".extraConfig = '' + expires -1; + uwsgi_pass unix://${wsgi-sock}; + uwsgi_param UWSGI_CHDIR ${gecloudpad}/${pkgs.python.sitePackages}; + uwsgi_param UWSGI_MODULE gecloudpad.main; + uwsgi_param UWSGI_CALLABLE app; + include ${pkgs.nginx}/conf/uwsgi_params; + ''; + }; + }; + }; +} diff --git a/makefu/2configs/deployment/gecloudpad/gecloudpad.nix b/makefu/2configs/deployment/gecloudpad/gecloudpad.nix new file mode 100644 index 000000000..7d51dfa0d --- /dev/null +++ b/makefu/2configs/deployment/gecloudpad/gecloudpad.nix @@ -0,0 +1,24 @@ +{ lib, pkgs, fetchFromGitHub, ... }: + +with pkgs.python3Packages;buildPythonPackage rec { + name = "gecloudpad-${version}"; + version = "0.2.3"; + + propagatedBuildInputs = [ + flask requests + ]; + + src = fetchFromGitHub { + owner = "binaergewitter"; + repo = "gecloudpad"; + rev = "master"; + sha256 = "0p9lcphp3r7hyypxadzw4x9ix6d0anmspxnjnj0v2jjll8gxqlhf"; + }; + + meta = { + homepage = https://github.com/binaergeiwtter/gecloudpad; + description = "server side for gecloudpad"; + license = lib.licenses.wtfpl; + }; +} + diff --git a/makefu/2configs/deployment/rss.euer.krebsco.de.nix b/makefu/2configs/deployment/rss.euer.krebsco.de.nix new file mode 100644 index 000000000..c827c5a53 --- /dev/null +++ b/makefu/2configs/deployment/rss.euer.krebsco.de.nix @@ -0,0 +1,14 @@ +let + fqdn = "rss.euer.krebsco.de"; +in { + services.tt-rss = { + enable = true; + virtualHost = fqdn; + selfUrlPath = "https://${fqdn}"; + }; + services.nginx.virtualHosts."${fqdn}" = { + enableACME = true; + forceSSL = true; + }; +} + -- cgit v1.2.3 From 92c1df38249f4b0d563ce62e3df9aef7161fb8cd Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:43:11 +0100 Subject: ma tools: update tool deployment --- makefu/2configs/tools/extra-gui.nix | 1 + makefu/2configs/tools/mobility.nix | 3 ++- makefu/2configs/tools/studio.nix | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/makefu/2configs/tools/extra-gui.nix b/makefu/2configs/tools/extra-gui.nix index 5f8614719..7c01104a0 100644 --- a/makefu/2configs/tools/extra-gui.nix +++ b/makefu/2configs/tools/extra-gui.nix @@ -4,6 +4,7 @@ users.users.makefu.packages = with pkgs;[ # media gimp + mirage inkscape libreoffice # skype diff --git a/makefu/2configs/tools/mobility.nix b/makefu/2configs/tools/mobility.nix index 11151003d..0cf218d46 100644 --- a/makefu/2configs/tools/mobility.nix +++ b/makefu/2configs/tools/mobility.nix @@ -11,5 +11,6 @@ opensc pcsctools libu2f-host ]; - # boot.extraModulePackages = [ config.boot.kernelPackages.exfat-nofuse ]; + boot.extraModulePackages = [ config.boot.kernelPackages.exfat-nofuse ]; + boot.supportedFilesystems = [ "exfat" ]; } diff --git a/makefu/2configs/tools/studio.nix b/makefu/2configs/tools/studio.nix index e0c68167f..2c8ca399d 100644 --- a/makefu/2configs/tools/studio.nix +++ b/makefu/2configs/tools/studio.nix @@ -11,7 +11,7 @@ pactl load-module module-null-sink sink_name=stream sink_properties=device.description="Streaming" pactl load-module module-loopback source=alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo.monitor sink=stream pactl load-module module-loopback source=alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo sink=stream - darkice -c ~/lol.conf + darkice -c ./lol.conf '') ]; } -- cgit v1.2.3 From e3c233af83fb54fb3b672ea692eea3a019cf032e Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:43:43 +0100 Subject: ma hw/bluetooth: do not override blueman --- makefu/2configs/hw/bluetooth.nix | 6 ------ 1 file changed, 6 deletions(-) diff --git a/makefu/2configs/hw/bluetooth.nix b/makefu/2configs/hw/bluetooth.nix index 972753080..e6a534b7b 100644 --- a/makefu/2configs/hw/bluetooth.nix +++ b/makefu/2configs/hw/bluetooth.nix @@ -40,10 +40,4 @@ ''; }; services.dbus.packages = [ pkgs.blueman ]; - nixpkgs.overlays = [ - (self: super: { - blueman = super.blueman.overrideAttrs (oldAttrs: { - buildInputs = oldAttrs.buildInputs ++ [ self.gnome3.adwaita-icon-theme ]; - }); - })]; } -- cgit v1.2.3 From 807f4a4d1cff8b0e2c6de3528c67947db131ca68 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:46:05 +0100 Subject: ma 2configs: cleanup --- makefu/2configs/hw/cc2531.nix | 10 ++++ makefu/2configs/main-laptop.nix | 9 ++-- makefu/2configs/minimal.nix | 6 +-- makefu/2configs/mqtt.nix | 2 +- makefu/2configs/nginx/rompr.nix | 1 - makefu/2configs/nur.nix | 6 ++- makefu/2configs/sickbeard/cheetah3.nix | 25 ++++++++++ makefu/2configs/sickbeard/debug.patch | 91 ++++++++++++++++++++++++++++++++++ makefu/2configs/sickbeard/sickgear.nix | 16 +++--- 9 files changed, 147 insertions(+), 19 deletions(-) create mode 100644 makefu/2configs/hw/cc2531.nix create mode 100644 makefu/2configs/sickbeard/cheetah3.nix create mode 100644 makefu/2configs/sickbeard/debug.patch diff --git a/makefu/2configs/hw/cc2531.nix b/makefu/2configs/hw/cc2531.nix new file mode 100644 index 000000000..3bc2c6834 --- /dev/null +++ b/makefu/2configs/hw/cc2531.nix @@ -0,0 +1,10 @@ +{ config, lib, pkgs, ... }: + +{ + + users.users.${config.krebs.build.user.name}.extraGroups = [ "dialout" ]; + + services.udev.extraRules = '' + SUBSYSTEM=="tty", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16a8", SYMLINK+="cc2531", MODE="0660", GROUP="dailout" + ''; +} diff --git a/makefu/2configs/main-laptop.nix b/makefu/2configs/main-laptop.nix index 315fc4706..cb78c823f 100644 --- a/makefu/2configs/main-laptop.nix +++ b/makefu/2configs/main-laptop.nix @@ -68,11 +68,10 @@ in { }; security.sudo.extraConfig = "${config.krebs.power-action.user} ALL= (root) NOPASSWD: ${pkgs.systemd}/bin/systemctl suspend"; - services.redshift = { - enable = true; - latitude = "48.7"; - longitude = "9.1"; - }; + services.redshift.enable = true; + location.latitude = 48.7; + location.longitude = 9.1; + systemd.services.look-up = { startAt = "*:30"; serviceConfig = { diff --git a/makefu/2configs/minimal.nix b/makefu/2configs/minimal.nix index cb2ef09e3..ad4c128ec 100644 --- a/makefu/2configs/minimal.nix +++ b/makefu/2configs/minimal.nix @@ -74,11 +74,7 @@ }; # suppress chrome autit event messages - security.audit = { - rules = [ - "-a task,never" - ]; - }; + security.audit.rules = [ "-a task,never" ]; # Enable IPv6 Privacy Extensions boot.kernel.sysctl = { diff --git a/makefu/2configs/mqtt.nix b/makefu/2configs/mqtt.nix index 8b77df962..9d1da8392 100644 --- a/makefu/2configs/mqtt.nix +++ b/makefu/2configs/mqtt.nix @@ -6,7 +6,7 @@ users = {}; # TODO: secure that shit aclExtraConf = '' - pattern readwrite /# + pattern readwrite # ''; allowAnonymous = true; }; diff --git a/makefu/2configs/nginx/rompr.nix b/makefu/2configs/nginx/rompr.nix index 8c1fbc53b..c7dc3ff17 100644 --- a/makefu/2configs/nginx/rompr.nix +++ b/makefu/2configs/nginx/rompr.nix @@ -15,7 +15,6 @@ let in { services.phpfpm = { - # phpfpm does not have an enable option poolConfigs = { mpd = '' user = ${user} diff --git a/makefu/2configs/nur.nix b/makefu/2configs/nur.nix index 3cb4981e0..891144957 100644 --- a/makefu/2configs/nur.nix +++ b/makefu/2configs/nur.nix @@ -1,6 +1,10 @@ { pkgs, ... }:{ nixpkgs.config.packageOverrides = pkgs: { - nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") { + nur = import (builtins.fetchTarball { + url = "https://github.com/nix-community/NUR/archive/7bfd0117b359d0f72d086ff7e1f0ba3aeaf8d91e.tar.gz"; + sha256 = "0gb2np1r2m9kkz1s374gxdqrwhkzx48iircy00y6mjr7h14rhyxk"; + } + ){ inherit pkgs; }; }; diff --git a/makefu/2configs/sickbeard/cheetah3.nix b/makefu/2configs/sickbeard/cheetah3.nix new file mode 100644 index 000000000..df928edd6 --- /dev/null +++ b/makefu/2configs/sickbeard/cheetah3.nix @@ -0,0 +1,25 @@ +{ lib +, buildPythonPackage +, fetchPypi +}: + +buildPythonPackage rec { + pname = "cheetah3"; + version = "3.2.4"; + + + src = fetchPypi { + pname = "Cheetah3"; + inherit version; + sha256 = "caabb9c22961a3413ac85cd1e5525ec9ca80daeba6555f4f60802b6c256e252b"; + }; + + doCheck = false; + + meta = with lib; { + description = "Cheetah is a template engine and code generation tool"; + homepage = https://cheetahtemplate.org/; + license = licenses.mit; + # maintainers = [ maintainers. ]; + }; +} diff --git a/makefu/2configs/sickbeard/debug.patch b/makefu/2configs/sickbeard/debug.patch new file mode 100644 index 000000000..aa22142c8 --- /dev/null +++ b/makefu/2configs/sickbeard/debug.patch @@ -0,0 +1,91 @@ +diff --git a/SickBeard.py b/SickBeard.py +index 31cfd1e1..10a4ef5e 100755 +--- a/SickBeard.py ++++ b/SickBeard.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python2 ++#!/usr/bin/env python3 + # + # This file is part of SickGear. + # +diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py +index 5c1f7bfe..8999b468 100644 +--- a/sickbeard/providers/generic.py ++++ b/sickbeard/providers/generic.py +@@ -1203,6 +1203,7 @@ class GenericProvider(object): + ep_num = None + if 1 == len(ep_obj_results): + ep_num = ep_obj_results[0].episode ++ logger.log(f'{ep_obj_results[0]}',logger.DEBUG) + logger.log(u'Single episode result.', logger.DEBUG) + elif 1 < len(ep_obj_results): + ep_num = MULTI_EP_RESULT +diff --git a/sickbeard/providers/horriblesubs.py b/sickbeard/providers/horriblesubs.py +index 870e8461..dbdeacc8 100644 +--- a/sickbeard/providers/horriblesubs.py ++++ b/sickbeard/providers/horriblesubs.py +@@ -98,6 +98,7 @@ class HorribleSubsProvider(generic.TorrentProvider): + + results = self._sort_seeding(mode, results + items[mode]) + ++ logger.log(f"{results}",logger.DEBUG) + return results + + def _season_strings(self, *args, **kwargs): +@@ -131,6 +132,7 @@ class HorribleSubsProvider(generic.TorrentProvider): + .find_all('a', href=re.compile('(?i)(torrent$|^magnet:)'))))[0] + except (BaseException, Exception): + pass ++ logger.log(f"{result}",logger.DEBUG) + return result + + +diff --git a/sickbeard/search.py b/sickbeard/search.py +index f4957c3a..dd3a352d 100644 +--- a/sickbeard/search.py ++++ b/sickbeard/search.py +@@ -986,22 +986,26 @@ def search_providers( + + best_result = pick_best_result(found_results[provider_id][cur_search_result], show_obj, quality_list, + filter_rls=orig_thread_name) +- ++ logger.log(f"Best result: {best_result}",logger.DEBUG) + # if all results were rejected move on to the next episode + if not best_result: + continue +- ++ + # filter out possible bad torrents from providers + if 'torrent' == best_result.resultType: ++ logger.log(f"Best result is torrent {best_result.url}",logger.DEBUG) + if not best_result.url.startswith('magnet') and None is not best_result.get_data_func: + best_result.url = best_result.get_data_func(best_result.url) + best_result.get_data_func = None # consume only once + if not best_result.url: + continue + if best_result.url.startswith('magnet'): ++ logger.log("url is magnet link",logger.DEBUG) + if 'blackhole' != sickbeard.TORRENT_METHOD: ++ logger.log(f"Setting content to None because TORRENT_METHODD is not blackhole ({sickbeard.TORRENT_METHOD} instead)",logger.DEBUG) + best_result.content = None + else: ++ logger.log("url is torrent link",logger.DEBUG) + cache_file = ek.ek(os.path.join, sickbeard.CACHE_DIR or helpers.get_system_temp_dir(), + '%s.torrent' % (helpers.sanitize_filename(best_result.name))) + if not helpers.download_file(best_result.url, cache_file, session=best_result.provider.session): +@@ -1044,6 +1048,7 @@ def search_providers( + best_result.after_get_data_func(best_result) + best_result.after_get_data_func = None # consume only once + ++ logger.log(f"After torrent detection",logger.DEBUG) + # add result if its not a duplicate + found = False + for i, result in enumerate(final_results): +@@ -1054,6 +1059,7 @@ def search_providers( + else: + found = True + if not found: ++ logger.log(f"Not already found, adding to best_result to final_results",logger.DEBUG) + final_results += [best_result] + + # check that we got all the episodes we wanted first before doing a match and snatch diff --git a/makefu/2configs/sickbeard/sickgear.nix b/makefu/2configs/sickbeard/sickgear.nix index 1b7a57e8b..281ec1845 100644 --- a/makefu/2configs/sickbeard/sickgear.nix +++ b/makefu/2configs/sickbeard/sickgear.nix @@ -1,16 +1,19 @@ -{ stdenv, fetchFromGitHub, python2, makeWrapper }: +{ stdenv, fetchFromGitHub, python3, makeWrapper }: let - pythonEnv = python2.withPackages(ps: with ps; [ cheetah ]); + pythonEnv = python3.withPackages(ps: with ps; [ + (python3.pkgs.callPackage ./cheetah3.nix {}) + ]); in stdenv.mkDerivation rec { pname = "sickgear"; - version = "0.20.0"; + #version = "0.21.6"; + version = "0.21.7"; src = fetchFromGitHub { owner = "SickGear"; repo = "SickGear"; - rev = "release_${version}"; - sha256 = "1zg95szvfbmwinx1z5nlbmyck7ximvyna0x71yflmadkgf88nv0k"; + rev = "hotfix/${version}"; + sha256 = "0kj8l6xq7vycr6d15lxybnk02b39z0zk4jzy0b2lbapgk0kx3ims"; }; dontBuild = true; @@ -18,12 +21,13 @@ in stdenv.mkDerivation rec { nativeBuildInputs = [ makeWrapper ]; buildInputs = [ pythonEnv ]; + patches = [ ./debug.patch ]; installPhase = '' mkdir -p $out/bin cp -R {autoProcessTV,gui,lib,sickbeard,sickgear.py,SickBeard.py} $out/ - makeWrapper $out/SickBeard.py $out/bin/sickgear + makeWrapper $out/sickgear.py $out/bin/sickgear ''; meta = with stdenv.lib; { -- cgit v1.2.3 From 88ecd06d65e7c18136f78c08291f6b2a6a770664 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:46:41 +0100 Subject: ma omo.r: deploy ham service --- makefu/1systems/omo/config.nix | 1 - makefu/1systems/omo/hw/omo.nix | 11 +++++++---- makefu/1systems/omo/source.nix | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/makefu/1systems/omo/config.nix b/makefu/1systems/omo/config.nix index d00d61fdc..37fb9128d 100644 --- a/makefu/1systems/omo/config.nix +++ b/makefu/1systems/omo/config.nix @@ -85,7 +85,6 @@ in { makefu.mpd.musicDirectory = "/media/cryptX/music"; } - # security # diff --git a/makefu/1systems/omo/hw/omo.nix b/makefu/1systems/omo/hw/omo.nix index 31db335bb..87af2a314 100644 --- a/makefu/1systems/omo/hw/omo.nix +++ b/makefu/1systems/omo/hw/omo.nix @@ -26,9 +26,10 @@ let # |_______| # cryptDisk0 = byid "ata-ST2000DM001-1CH164_Z240XTT6"; cryptDisk0 = byid "ata-ST8000DM004-2CX188_ZCT01PLV"; - cryptDisk1 = byid "ata-TP02000GB_TPW151006050068"; - cryptDisk2 = byid "ata-ST4000DM000-1F2168_Z303HVSG"; + cryptDisk1 = byid "ata-WDC_WD80EZAZ-11TDBA0_7SJPVLYW"; cryptDisk3 = byid "ata-ST8000DM004-2CX188_ZCT01SG4"; + cryptDisk2 = byid "ata-WDC_WD80EZAZ-11TDBA0_7SJPWT5W"; + # cryptDisk3 = byid "ata-WDC_WD20EARS-00MVWB0_WD-WMAZA1786907"; # all physical disks @@ -48,8 +49,8 @@ in { makefu.snapraid = { enable = true; - disks = map toMapper [ 0 2 3 ]; - parity = toMapper 1; + disks = map toMapper [ 0 1 3 ]; + parity = toMapper 2; # find -name PARITY_PARTITION }; fileSystems = let cryptMount = name: @@ -102,6 +103,8 @@ in { "firewire_ohci" "usb_storage" "usbhid" + "raid456" + "megaraid_sas" ]; kernelModules = [ "kvm-intel" ]; diff --git a/makefu/1systems/omo/source.nix b/makefu/1systems/omo/source.nix index 0d42cc9e2..05c17377f 100644 --- a/makefu/1systems/omo/source.nix +++ b/makefu/1systems/omo/source.nix @@ -1,4 +1,5 @@ { name="omo"; torrent = true; + unstable = true; } -- cgit v1.2.3 From 1236ebdb6ce7371868cd5d13d76be58b3124d543 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:47:21 +0100 Subject: ma gum.r: disable unused services --- makefu/1systems/gum/config.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/makefu/1systems/gum/config.nix b/makefu/1systems/gum/config.nix index 3b084d35a..d756a0d6b 100644 --- a/makefu/1systems/gum/config.nix +++ b/makefu/1systems/gum/config.nix @@ -21,11 +21,12 @@ in { ]; }; } + # - + # @@ -89,8 +90,8 @@ in { # services # - - { krebs.exim.enable = mkForce false; } + # + { krebs.exim.enable = mkDefault true; } # sharing @@ -119,7 +120,7 @@ in { # Removed until move: avoid letsencrypt ban ### Web - # + # @@ -131,10 +132,14 @@ in { # # - + # + + + + -- cgit v1.2.3 From 51aeea88919487f5379f41007bd0416db4ea5965 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:48:14 +0100 Subject: ma x.r: disable gum-client --- makefu/1systems/x/config.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makefu/1systems/x/config.nix b/makefu/1systems/x/config.nix index ea18c68ac..4c479875e 100644 --- a/makefu/1systems/x/config.nix +++ b/makefu/1systems/x/config.nix @@ -58,7 +58,7 @@ # Krebs - + # # @@ -103,6 +103,7 @@ # # + @@ -142,7 +143,6 @@ ]; }; } - ]; makefu.server.primary-itf = "wlp3s0"; -- cgit v1.2.3 From 947e68fb25364b62a6336fb9289a7d127294b588 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:48:56 +0100 Subject: ma krops: also deploy unstable if required --- makefu/krops.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/makefu/krops.nix b/makefu/krops.nix index 6913a5c63..13a228d9d 100644 --- a/makefu/krops.nix +++ b/makefu/krops.nix @@ -46,6 +46,12 @@ }; }; } + (lib.mkIf (host-src.unstable) { + nixpkgs-unstable.git = { + url = "https://github.com/nixos/nixpkgs-channels"; + ref = (lib.importJSON ../krebs/nixpkgs-unstable.json).rev; + }; + }) (lib.mkIf (host-src.torrent) { torrent-secrets = if test then { file = toString ./0tests/data/secrets; @@ -71,7 +77,7 @@ (lib.mkIf ( host-src.home-manager ) { home-manager.git = { url = https://github.com/rycee/home-manager; - ref = "f856c78a4a220f44b64ce5045f228cbb9d4d9f31"; + ref = "9781f37"; }; }) ]; -- cgit v1.2.3 From 6cc25488bf92b3d5345dae3ea93b66f7652b6255 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:50:18 +0100 Subject: shack: update node-light, update glados --- krebs/2configs/shack/glados/default.nix | 5 ++++- krebs/2configs/shack/glados/switch/power.nix | 32 ++++++++++++++++++++++++++++ krebs/2configs/shack/node-light.nix | 6 +++--- 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 krebs/2configs/shack/glados/switch/power.nix diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix index 3f3b1cac5..920f2ed2f 100644 --- a/krebs/2configs/shack/glados/default.nix +++ b/krebs/2configs/shack/glados/default.nix @@ -91,7 +91,10 @@ in { retain = true; }; }; - switch = wasser.switch; + switch = + wasser.switch + ++ (import ./switch/power.nix) + ; light = []; media_player = [ { platform = "mpd"; diff --git a/krebs/2configs/shack/glados/switch/power.nix b/krebs/2configs/shack/glados/switch/power.nix new file mode 100644 index 000000000..4e9a45c28 --- /dev/null +++ b/krebs/2configs/shack/glados/switch/power.nix @@ -0,0 +1,32 @@ +# 1 - haupt +# 2 - dusche +# 3 - warmwasser +# 4 - or +# 5 - kueche +let + nodelight = type: ident: name: { + platform = "mqtt"; + name = "${type} ${name}"; + command_topic = "${type}/${toString ident}/command"; + state_topic = "${type}/${toString ident}/state"; + payload_on = "on"; + payload_off = "off"; + }; + power = nodelight "power"; + light = ident: name: { icon = "mdi:lightbulb";} // nodelight "light" ident name; +in +[ + (power 1 "Hauptschalter") + (power 2 "Dusche") + (power 3 "Warmwasser") + (power 4 "Optionsräume") + (power 5 "Küche") + (light 1 "Decke Lounge 1") + (light 2 "Decke Lounge 2") + (light 3 "Decke Lounge 3") + (light 4 "Decke Lounge 4") + (light 5 "Decke Lounge 5") + (light 6 "Decke Lounge 6") + (light 7 "Decke Lounge 7") + (light 8 "Decke Lounge 8") +] diff --git a/krebs/2configs/shack/node-light.nix b/krebs/2configs/shack/node-light.nix index 9e3828463..b471f2af5 100644 --- a/krebs/2configs/shack/node-light.nix +++ b/krebs/2configs/shack/node-light.nix @@ -4,9 +4,9 @@ let pkg = pkgs.callPackage ( pkgs.fetchgit { url = "https://git.shackspace.de/rz/node-light.git"; - rev = "9c3fe451897cf170fb192a2643180fdfe22388e8"; - sha256 = "1zsc38idg452r8wpcna5m3yqx0ri11bd1bw60bl0kpz96dqqnyba"; - }) { mkYarnPackage = pkgs.yarn2nix-moretea.mkYarnPackage; }; + rev = "90a9347b73af3a9960bd992e6293b357226ef6a0"; + sha256 = "1av9w3w8aknlra25jw6gqxzbb01i9kdlfziy29lwz7mnryjayvwk"; + }) { }; home = "/var/lib/node-light"; port = "8082"; in { -- cgit v1.2.3 From 345fc92cbf1975da935909e3769935e733890e88 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 10:51:34 +0100 Subject: ma gum.r: add board.euer, rss.euer --- krebs/3modules/makefu/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/krebs/3modules/makefu/default.nix b/krebs/3modules/makefu/default.nix index 56d313528..c76ed0ad1 100644 --- a/krebs/3modules/makefu/default.nix +++ b/krebs/3modules/makefu/default.nix @@ -182,6 +182,8 @@ in { gum IN A ${nets.internet.ip4.addr} io IN NS gum.krebsco.de. iso.euer IN A ${nets.internet.ip4.addr} + board.euer IN A ${nets.internet.ip4.addr} + rss.euer IN A ${nets.internet.ip4.addr} mediengewitter IN CNAME over.dose.io. mon.euer IN A ${nets.internet.ip4.addr} netdata.euer IN A ${nets.internet.ip4.addr} @@ -202,7 +204,6 @@ in { ip6.addr = "2a01:4f8:191:12f6::2"; aliases = [ "gum.i" - "nextgum.i" ]; }; wiregrill = { @@ -238,6 +239,7 @@ in { "tracker.makefu.r" "wiki.gum.r" "wiki.makefu.r" + "warrior.gum.r" "sick.makefu.r" ]; }; -- cgit v1.2.3 From 59aa15467972da51d3e051c8cb0bccfe6bdec3ea Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 11:58:30 +0100 Subject: krebs test-secrets: add darksky.apikey --- krebs/0tests/data/secrets/hass/darksky.apikey | 1 + 1 file changed, 1 insertion(+) create mode 100644 krebs/0tests/data/secrets/hass/darksky.apikey diff --git a/krebs/0tests/data/secrets/hass/darksky.apikey b/krebs/0tests/data/secrets/hass/darksky.apikey new file mode 100644 index 000000000..4932cd639 --- /dev/null +++ b/krebs/0tests/data/secrets/hass/darksky.apikey @@ -0,0 +1 @@ +LOL -- cgit v1.2.3 From a2e3c0488a6a7a63ffd34abc5fd8ba84e4e93155 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 12:02:13 +0100 Subject: ma sickgear: bump to latest revision, not use hotfix branch --- makefu/2configs/sickbeard/sickgear.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/makefu/2configs/sickbeard/sickgear.nix b/makefu/2configs/sickbeard/sickgear.nix index 281ec1845..9746ee073 100644 --- a/makefu/2configs/sickbeard/sickgear.nix +++ b/makefu/2configs/sickbeard/sickgear.nix @@ -7,13 +7,13 @@ let in stdenv.mkDerivation rec { pname = "sickgear"; #version = "0.21.6"; - version = "0.21.7"; + version = "0.21.21"; src = fetchFromGitHub { owner = "SickGear"; repo = "SickGear"; - rev = "hotfix/${version}"; - sha256 = "0kj8l6xq7vycr6d15lxybnk02b39z0zk4jzy0b2lbapgk0kx3ims"; + rev = "release_${version}"; + sha256 = "15nlxg2867l846qqxklmfyqmn5nc01ksd4lpwbrbjdzpk4y3xi78"; }; dontBuild = true; -- cgit v1.2.3 From b1c4cd5b1c659853a6b1057786c5e333e5b98604 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 13 Mar 2020 12:49:54 +0100 Subject: ma gum.r: fix cgit.euer.krebsco.de --- makefu/1systems/gum/config.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/makefu/1systems/gum/config.nix b/makefu/1systems/gum/config.nix index d756a0d6b..8603d7696 100644 --- a/makefu/1systems/gum/config.nix +++ b/makefu/1systems/gum/config.nix @@ -176,7 +176,8 @@ in { services.nginx.virtualHosts."cgit.euer.krebsco.de" = { forceSSL = true; enableACME = true; - locations."/".proxyPass = "http://cgit.gum.r"; + locations."/".proxyPass = "http://localhost/"; + locations."/".extraConfig = ''proxy_set_header Host cgit;''; }; krebs.build.host = config.krebs.hosts.gum; -- cgit v1.2.3 From 6ef2bcc9f1202bf1916bc23b44a491040da98c07 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 18 Mar 2020 19:54:41 +0100 Subject: add ssh.git.shackspace.de server keys via variable avoid some weird rate limiting which is in place --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3ff991aa4..4a7a4e605 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ before_script: # prepare git fetching of secrets - echo "$gitlab_deploy_privkey" > ~/.ssh/gitlab_deploy.key - chmod 600 ~/.ssh/gitlab_deploy.key - - ssh-keyscan -H 'ssh.git.shackspace.de' >> ~/.ssh/known_hosts + - echo "$ssh_git_shackspace_serverkey" >> ~/.ssh/known_hosts # import secret key for secrets - echo "$secrets_gpg_key" | gpg --import deployment test: -- cgit v1.2.3 From cbd9b1923236566893f12a9ce96bec7c9f59fcda Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 19 Mar 2020 13:15:04 +0100 Subject: ma pkgs.hydra-check: 1.0.0 -> 1.1.0 --- makefu/5pkgs/custom/hydra-check/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/makefu/5pkgs/custom/hydra-check/default.nix b/makefu/5pkgs/custom/hydra-check/default.nix index 512ceec9f..cfaaaab73 100644 --- a/makefu/5pkgs/custom/hydra-check/default.nix +++ b/makefu/5pkgs/custom/hydra-check/default.nix @@ -2,13 +2,13 @@ buildPythonPackage rec { name = "hydra-check"; - version = "1.0.0"; + version = "1.1.0"; src = fetchFromGitHub { - owner = "makefu"; + owner = "nix-community"; repo = "hydra-check"; rev = version; - sha256 = "0359s9rvl2q23a3yddhbn6w2sd5r1f1jl6whyik7qql7blpcvyi7"; + sha256 = "1q4n5l238lnzcms3z1ax4860inaliawqlxv7nf1wb4knl4wr26fk"; }; propagatedBuildInputs = [ docopt -- cgit v1.2.3 From f54afe0cc6357ede5f9a3ae0cd1acc58d0b66aaf Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 19 Mar 2020 15:18:20 +0100 Subject: ma pkgs.liveproxy: fix licensing --- makefu/5pkgs/custom/liveproxy/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefu/5pkgs/custom/liveproxy/default.nix b/makefu/5pkgs/custom/liveproxy/default.nix index 195879c89..ba5ddee66 100644 --- a/makefu/5pkgs/custom/liveproxy/default.nix +++ b/makefu/5pkgs/custom/liveproxy/default.nix @@ -24,7 +24,7 @@ buildPythonPackage rec { meta = with lib; { description = "LiveProxy is a local Proxyserver between Streamlink and an URL"; homepage = https://github.com/back-to/liveproxy; - license = licenses.BSD 2-Clause "Simplified" License; + license = lib.licenses.bsd2; # maintainers = [ maintainers. ]; }; } -- cgit v1.2.3 From 8e3cd9fcffc473706a3ebafa5cb80f7a75c29aa5 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 19 Mar 2020 16:04:03 +0100 Subject: ma pkgs.libcoap: rip --- makefu/5pkgs/libcoap/default.nix | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 makefu/5pkgs/libcoap/default.nix diff --git a/makefu/5pkgs/libcoap/default.nix b/makefu/5pkgs/libcoap/default.nix deleted file mode 100644 index 7e8d03edd..000000000 --- a/makefu/5pkgs/libcoap/default.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ lib, stdenv, fetchFromGitHub, autoreconfHook, autoconf-archive, pkgconfig, -gettext, asciidoc, doxygen, libxml2, libxslt, docbook_xsl, ... }: -stdenv.mkDerivation rec { - name = "libcoap-${version}"; - version = "4.1.2"; - - src = fetchFromGitHub { - owner = "obgm"; - repo = "libcoap"; - rev = "v${version}"; - sha256 = "0f0qq15480ja1s03vn8lzw4b3mzdgy46hng4aigi6i6qbzf29kf5"; - }; - - patchPhase = '' - sed -i 's/$(A2X)/& --no-xmllint/' examples/Makefile.am - ''; - buildInputs = [ gettext asciidoc doxygen libxml2.bin libxslt docbook_xsl]; - nativeBuildInputs = [ autoreconfHook autoconf-archive pkgconfig ]; - - meta = { - description = ""; - homepage = http://coap.technology; - license = stdenv.lib.licenses.gpl2; - platforms = stdenv.lib.platforms.linux; - maintainers = with stdenv.lib.maintainers; [ makefu ]; - }; -} -- cgit v1.2.3 [cgit] Unable to lock slot /tmp/cgit/27000000.lock: No such file or directory (2)