git.iko.soy/typeable/nixpkgs
on master help sign in
home-assistant-cli: init at 0.3.0
commit52b1973283aca1c36852e25da97a8e8f06e6d642 authorRobert Schütz <robert.schuetz@stud.uni-heidelberg.de> dateWed 12 Dec 2018, 14:00 (8 years ago) parent407f9ba
3 files changed+44−1
nixos/tests/home-assistant.nix+7−1 pkgs/servers/home-assistant/cli.nix+35 pkgs/top-level/all-packages.nix+2
nixos/tests/home-assistant.nix+7−1
@@ -4,6 +4,7 @@ let
44 configDir = "/var/lib/foobar";
55 apiPassword = "some_secret";
66 mqttPassword = "another_secret";
7+ hassCli = "hass-cli --server http://hass:8123 --password '${apiPassword}'";
78
89in {
910 name = "home-assistant";
@@ -16,7 +17,7 @@ in {
1617 { pkgs, ... }:
1718 {
1819 environment.systemPackages = with pkgs; [
19− mosquitto
20+ mosquitto home-assistant-cli
2021 ];
2122 services.home-assistant = {
2223 inherit configDir;
@@ -71,6 +72,11 @@ in {
7172 $hass->waitUntilSucceeds("mosquitto_pub -V mqttv311 -t home-assistant/test -u homeassistant -P '${mqttPassword}' -m let_there_be_light");
7273 $hass->succeed("curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}' | grep -qF '\"state\": \"on\"'");
7374
75+ # Toggle a binary sensor using hass-cli
76+ $hass->succeed("${hassCli} entity get binary_sensor.mqtt_binary_sensor | grep -qF '\"state\": \"on\"'");
77+ $hass->succeed("${hassCli} entity edit binary_sensor.mqtt_binary_sensor --json='{\"state\": \"off\"}'");
78+ $hass->succeed("curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}' | grep -qF '\"state\": \"off\"'");
79+
7480 # Print log to ease debugging
7581 my $log = $hass->succeed("cat ${configDir}/home-assistant.log");
7682 print "\n### home-assistant.log ###\n";
pkgs/servers/home-assistant/cli.nixnew file+35
@@ -0,0 +1,35 @@
1+{ lib, python3 }:
2+
3+python3.pkgs.buildPythonApplication rec {
4+ pname = "homeassistant-cli";
5+ version = "0.3.0";
6+
7+ src = python3.pkgs.fetchPypi {
8+ inherit pname version;
9+ sha256 = "42d7cb008801d7a448b62aed1fc46dd450ee67397bf16faabb02f691417db4b2";
10+ };
11+
12+ postPatch = ''
13+ # Ignore pinned versions
14+ sed -i "s/'\(.*\)==.*'/'\1'/g" setup.py
15+ '';
16+
17+ propagatedBuildInputs = with python3.pkgs; [
18+ requests pyyaml netdisco click click-log tabulate idna jsonpath_rw jinja2
19+ ];
20+
21+ checkInputs = with python3.pkgs; [
22+ pytest requests-mock
23+ ];
24+
25+ checkPhase = ''
26+ pytest
27+ '';
28+
29+ meta = with lib; {
30+ description = "Command-line tool for Home Asssistant";
31+ homepage = https://github.com/home-assistant/home-assistant-cli;
32+ license = licenses.asl20;
33+ maintainers = with maintainers; [ dotlambda ];
34+ };
35+}
pkgs/top-level/all-packages.nix+2
@@ -13553,6 +13553,8 @@ in
1355313553 python = python36;
1355413554 };
1355513555
13556+ home-assistant-cli = callPackage ../servers/home-assistant/cli.nix { };
13557+
1355613558 hydron = callPackage ../servers/hydron { };
1355713559
1355813560 ircdHybrid = callPackage ../servers/irc/ircd-hybrid { };