ma ham: use home-assistant from unstable, enable androidtv support

This commit is contained in:
makefu 2020-03-03 21:12:51 +01:00
parent 843ee70248
commit 2563c59e73
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225
5 changed files with 134 additions and 48 deletions

View File

@ -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. ];
};
}

View File

@ -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. ];
};
}

View File

@ -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. ];
};
}

View File

@ -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";
};
}
];
}
]

View File

@ -4,13 +4,14 @@
## wake-on-lan server
##
let
upkgs = (import <nixpkgs-unstable> {}).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
};