ma bureautomation: prepare dwd_pollen, update presence

This commit is contained in:
makefu 2019-06-17 07:54:31 +02:00
parent 64eee34bbe
commit ea8d45793e
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225
6 changed files with 113 additions and 13 deletions

View File

@ -24,22 +24,20 @@ in {
./ota.nix ./ota.nix
]; ];
services.logstash = { services.logstash = {
package = pkgs.logstash5; package = pkgs.logstash7;
plugins = [ pkgs.logstash-output-exec ];
enable = true; enable = true;
inputConfig = '' inputConfig = ''
http { http {
port => ${toString port} port => ${toString port}
host => "127.0.0.1" host => "127.0.0.1"
type => "schlechteluft"
} }
''; '';
filterConfig = ''
'';
outputConfig = '' outputConfig = ''
stdout { codec => json } if [type] == "schlechteluft" {
exec { command => "${runit} '%{ruleName}' '%{state}'" } exec { command => "${runit} '%{ruleName}' '%{state}'" }
''; }
extraSettings = ''
path.plugins: [ "${pkgs.logstash-output-exec}" ]
''; '';
}; };
} }

View File

@ -1,3 +1,6 @@
# requires `opkg install luci-mod-rpc` on router
# see https://www.home-assistant.io/components/luci/
[ [
{ platform = "luci"; { platform = "luci";
name = "router"; name = "router";

View File

@ -0,0 +1,32 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, python
, voluptuous
}:
buildPythonPackage rec {
format = "other";
pname = "dwd_pollen";
version = "0.1";
src = fetchFromGitHub {
owner = "marcschumacher";
repo = "dwd_pollen";
rev = version;
sha256 = "1af2mx99gv2hk1ad53g21fwkdfdbymqcdl3jvzd1yg7dgxlkhbj1";
};
propagatedBuildInputs = [
voluptuous
];
installPhase = ''
install -D -t $out/${python.sitePackages}/homeassistant/components/sensor/dwd_pollen *
'';
meta = with lib; {
description = "Home Assistant component to retrieve Pollen data from DWD (Germany)";
homepage = https://github.com/marcschumacher/dwd_pollen;
license = licenses.mit;
maintainers = [ maintainers.makefu ];
};
}

View File

@ -0,0 +1,27 @@
{ lib
, buildPythonPackage
, fetchPypi
, requests
}:
buildPythonPackage rec {
pname = "gtts-token";
version = "1.1.3";
src = fetchPypi {
pname = "gTTS-token";
inherit version;
sha256 = "9d6819a85b813f235397ef931ad4b680f03d843c9b2a9e74dd95175a4bc012c5";
};
propagatedBuildInputs = [
requests
];
meta = with lib; {
description = "Calculates a token to run the Google Translate text to speech";
homepage = https://github.com/boudewijn26/gTTS-token;
license = licenses.mit;
# maintainers = [ maintainers. ];
};
}

View File

@ -1,12 +1,32 @@
{ pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
kodi-host = "192.168.8.11"; kodi-host = "192.168.8.11";
in { in {
networking.firewall.allowedTCPPorts = [ 8123 ]; networking.firewall.allowedTCPPorts = [ 8123 ];
state = [ "/var/lib/hass/known_devices.yaml" ]; state = [ "/var/lib/hass/known_devices.yaml" ];
services.home-assistant = { services.home-assistant = let
dwd_pollen = pkgs.fetchFromGitHub {
owner = "marcschumacher";
repo = "dwd_pollen";
rev = "0.1";
sha256 = "1af2mx99gv2hk1ad53g21fwkdfdbymqcdl3jvzd1yg7dgxlkhbj1";
};
in {
enable = true; enable = true;
package = pkgs.home-assistant.override { python3 = pkgs.python36; }; package = (pkgs.home-assistant.overrideAttrs (old: {
# TODO: find correct python package
postInstall = ''
cp -r ${dwd_pollen} $out/lib/python3.7/site-packages/homeassistant/components/dwd_pollen
'';
})).override {
extraPackages = ps: with ps; [
pkgs.pico2wave
python-forecastio jsonrpc-async jsonrpc-websocket
(callPackage ./gtts-token.nix { })
];
};
autoExtraComponents = true;
config = { config = {
homeassistant = { homeassistant = {
name = "Bureautomation"; name = "Bureautomation";
@ -84,6 +104,7 @@ in {
(import ./binary_sensor/motion.nix); (import ./binary_sensor/motion.nix);
sensor = sensor =
(import ./sensor/pollen.nix) ++
(import ./sensor/espeasy.nix) ++ (import ./sensor/espeasy.nix) ++
((import ./sensor/outside.nix) {inherit lib;}) ++ ((import ./sensor/outside.nix) {inherit lib;}) ++
(import ./sensor/influxdb.nix) ++ (import ./sensor/influxdb.nix) ++
@ -99,6 +120,7 @@ in {
frontend = { }; frontend = { };
http = { http = {
# TODO: https://github.com/home-assistant/home-assistant/issues/16149 # TODO: https://github.com/home-assistant/home-assistant/issues/16149
base_url = "http://192.168.8.11:8123";
api_password = "sistemas"; api_password = "sistemas";
trusted_networks = [ trusted_networks = [
"127.0.0.1/32" "127.0.0.1/32"
@ -110,7 +132,18 @@ in {
conversation = {}; conversation = {};
history = {}; history = {};
logbook = {}; logbook = {};
tts = [ { platform = "google";} ]; tts = [
{ platform = "google";
language = "de";
}
{ platform = "voicerss";
api_key = builtins.readFile <secrets/hass/voicerss.apikey>;
language = "de-de";
}
{ platform = "picotts";
language = "de-DE";
}
];
recorder = {}; recorder = {};
sun = {}; sun = {};
telegram_bot = [ telegram_bot = [
@ -147,6 +180,7 @@ in {
"device_tracker.daniel_phone" "device_tracker.daniel_phone"
"device_tracker.carsten_phone" "device_tracker.carsten_phone"
"device_tracker.thierry_phone" "device_tracker.thierry_phone"
"device_tracker.frank_phone"
# "person.thorsten" # "person.thorsten"
# "person.felix" # "person.felix"
# "person.ecki" # "person.ecki"
@ -181,7 +215,6 @@ in {
"sensor.dark_sky_uv_index" "sensor.dark_sky_uv_index"
# "sensor.dark_sky_pressure" # "sensor.dark_sky_pressure"
"sensor.dark_sky_hourly_summary" "sensor.dark_sky_hourly_summary"
"device_tracker.router"
]; ];
}; };
# only for automation # only for automation

View File

@ -0,0 +1,7 @@
[ {
platform = "dwd_pollen";
partsregion_ids = [
112
];
}
]