Merge pull request #91154 from Mic92/homeassistant
This commit is contained in:
commit
9aa668ef04
@ -240,6 +240,7 @@ in {
|
|||||||
'');
|
'');
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${package}/bin/hass --config '${cfg.configDir}'";
|
ExecStart = "${package}/bin/hass --config '${cfg.configDir}'";
|
||||||
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
||||||
User = "hass";
|
User = "hass";
|
||||||
Group = "hass";
|
Group = "hass";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
|
@ -2,69 +2,53 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
|||||||
|
|
||||||
let
|
let
|
||||||
configDir = "/var/lib/foobar";
|
configDir = "/var/lib/foobar";
|
||||||
apiPassword = "some_secret";
|
mqttPassword = "secret";
|
||||||
mqttPassword = "another_secret";
|
|
||||||
hassCli = "hass-cli --server http://hass:8123 --password '${apiPassword}'";
|
|
||||||
in {
|
in {
|
||||||
name = "home-assistant";
|
name = "home-assistant";
|
||||||
meta = with pkgs.stdenv.lib; {
|
meta = with pkgs.stdenv.lib; {
|
||||||
maintainers = with maintainers; [ dotlambda ];
|
maintainers = with maintainers; [ dotlambda ];
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes = {
|
nodes.hass = { pkgs, ... }: {
|
||||||
hass =
|
environment.systemPackages = with pkgs; [ mosquitto ];
|
||||||
{ pkgs, ... }:
|
services.home-assistant = {
|
||||||
{
|
inherit configDir;
|
||||||
environment.systemPackages = with pkgs; [
|
enable = true;
|
||||||
mosquitto home-assistant-cli
|
config = {
|
||||||
];
|
homeassistant = {
|
||||||
services.home-assistant = {
|
name = "Home";
|
||||||
inherit configDir;
|
time_zone = "UTC";
|
||||||
enable = true;
|
latitude = "0.0";
|
||||||
package = pkgs.home-assistant.override {
|
longitude = "0.0";
|
||||||
extraPackages = ps: with ps; [ hbmqtt ];
|
elevation = 0;
|
||||||
};
|
};
|
||||||
config = {
|
frontend = {};
|
||||||
homeassistant = {
|
# uses embedded mqtt broker
|
||||||
name = "Home";
|
mqtt.password = mqttPassword;
|
||||||
time_zone = "UTC";
|
binary_sensor = [{
|
||||||
latitude = "0.0";
|
platform = "mqtt";
|
||||||
longitude = "0.0";
|
state_topic = "home-assistant/test";
|
||||||
elevation = 0;
|
payload_on = "let_there_be_light";
|
||||||
auth_providers = [
|
payload_off = "off";
|
||||||
{
|
}];
|
||||||
type = "legacy_api_password";
|
logger = {
|
||||||
api_password = apiPassword;
|
default = "info";
|
||||||
}
|
logs."homeassistant.components.mqtt" = "debug";
|
||||||
];
|
|
||||||
};
|
|
||||||
frontend = { };
|
|
||||||
mqtt = { # Use hbmqtt as broker
|
|
||||||
password = mqttPassword;
|
|
||||||
};
|
|
||||||
binary_sensor = [
|
|
||||||
{
|
|
||||||
platform = "mqtt";
|
|
||||||
state_topic = "home-assistant/test";
|
|
||||||
payload_on = "let_there_be_light";
|
|
||||||
payload_off = "off";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
lovelaceConfig = {
|
|
||||||
title = "My Awesome Home";
|
|
||||||
views = [ {
|
|
||||||
title = "Example";
|
|
||||||
cards = [ {
|
|
||||||
type = "markdown";
|
|
||||||
title = "Lovelace";
|
|
||||||
content = "Welcome to your **Lovelace UI**.";
|
|
||||||
} ];
|
|
||||||
} ];
|
|
||||||
};
|
|
||||||
lovelaceConfigWritable = true;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
lovelaceConfig = {
|
||||||
|
title = "My Awesome Home";
|
||||||
|
views = [{
|
||||||
|
title = "Example";
|
||||||
|
cards = [{
|
||||||
|
type = "markdown";
|
||||||
|
title = "Lovelace";
|
||||||
|
content = "Welcome to your **Lovelace UI**.";
|
||||||
|
}];
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
lovelaceConfigWritable = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
@ -77,28 +61,13 @@ in {
|
|||||||
with subtest("Check that Home Assistant's web interface and API can be reached"):
|
with subtest("Check that Home Assistant's web interface and API can be reached"):
|
||||||
hass.wait_for_open_port(8123)
|
hass.wait_for_open_port(8123)
|
||||||
hass.succeed("curl --fail http://localhost:8123/lovelace")
|
hass.succeed("curl --fail http://localhost:8123/lovelace")
|
||||||
assert "API running" in hass.succeed(
|
|
||||||
"curl --fail -H 'x-ha-access: ${apiPassword}' http://localhost:8123/api/"
|
|
||||||
)
|
|
||||||
with subtest("Toggle a binary sensor using MQTT"):
|
with subtest("Toggle a binary sensor using MQTT"):
|
||||||
assert '"state": "off"' in hass.succeed(
|
# wait for broker to become available
|
||||||
"curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}'"
|
|
||||||
)
|
|
||||||
hass.wait_until_succeeds(
|
hass.wait_until_succeeds(
|
||||||
"mosquitto_pub -V mqttv311 -t home-assistant/test -u homeassistant -P '${mqttPassword}' -m let_there_be_light"
|
"mosquitto_sub -V mqttv311 -t home-assistant/test -u homeassistant -P '${mqttPassword}' -W 1 -t '*'"
|
||||||
)
|
|
||||||
assert '"state": "on"' in hass.succeed(
|
|
||||||
"curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}'"
|
|
||||||
)
|
|
||||||
with subtest("Toggle a binary sensor using hass-cli"):
|
|
||||||
assert '"state": "on"' in hass.succeed(
|
|
||||||
"${hassCli} --output json state get binary_sensor.mqtt_binary_sensor"
|
|
||||||
)
|
)
|
||||||
hass.succeed(
|
hass.succeed(
|
||||||
"${hassCli} state edit binary_sensor.mqtt_binary_sensor --json='{\"state\": \"off\"}'"
|
"mosquitto_pub -V mqttv311 -t home-assistant/test -u homeassistant -P '${mqttPassword}' -m let_there_be_light"
|
||||||
)
|
|
||||||
assert '"state": "off"' in hass.succeed(
|
|
||||||
"curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}'"
|
|
||||||
)
|
)
|
||||||
with subtest("Print log to ease debugging"):
|
with subtest("Print log to ease debugging"):
|
||||||
output_log = hass.succeed("cat ${configDir}/home-assistant.log")
|
output_log = hass.succeed("cat ${configDir}/home-assistant.log")
|
||||||
@ -107,5 +76,9 @@ in {
|
|||||||
|
|
||||||
with subtest("Check that no errors were logged"):
|
with subtest("Check that no errors were logged"):
|
||||||
assert "ERROR" not in output_log
|
assert "ERROR" not in output_log
|
||||||
|
|
||||||
|
# example line: 2020-06-20 10:01:32 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on home-assistant/test: b'let_there_be_light'
|
||||||
|
with subtest("Check we received the mosquitto message"):
|
||||||
|
assert "let_there_be_light" in output_log
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
, dateutil
|
, dateutil
|
||||||
, pytz
|
, pytz
|
||||||
, six
|
, six
|
||||||
|
, msgpack
|
||||||
|
, fetchpatch
|
||||||
}:
|
}:
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
@ -16,9 +18,16 @@ buildPythonPackage rec {
|
|||||||
sha256 = "9bcaafd57ac152b9824ab12ed19f204206ef5df8af68404770554c5b55b475f6";
|
sha256 = "9bcaafd57ac152b9824ab12ed19f204206ef5df8af68404770554c5b55b475f6";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
(fetchpatch {
|
||||||
|
url = "https://github.com/influxdata/influxdb-python/commit/cc41e290f690c4eb67f75c98fa9f027bdb6eb16b.patch";
|
||||||
|
sha256 = "1fb9qrq1kp24pixjwvzhdy67z3h0wnj92aj0jw0a25fd0rdxdvg4";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
# ImportError: No module named tests
|
# ImportError: No module named tests
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
propagatedBuildInputs = [ requests dateutil pytz six ];
|
propagatedBuildInputs = [ requests dateutil pytz six msgpack ];
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
description = "Python client for InfluxDB";
|
description = "Python client for InfluxDB";
|
||||||
|
@ -38,9 +38,10 @@ buildPythonPackage rec {
|
|||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
sed -i \
|
sed -i \
|
||||||
-e 's!click>=6.0,<7.0!click!' \
|
-e 's!click>=.*!click!' \
|
||||||
-e 's!keyring>=8.0,<9.0!keyring!' \
|
-e 's!keyring>=.*!keyring!' \
|
||||||
-e 's!keyrings.alt>=1.0,<2.0!keyrings.alt!' \
|
-e 's!keyrings.alt>=.*!keyrings.alt!' \
|
||||||
|
-e 's!tzlocal==.*!tzlocal!' \
|
||||||
requirements.txt
|
requirements.txt
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Do not edit!
|
# Do not edit!
|
||||||
|
|
||||||
{
|
{
|
||||||
version = "0.111.0";
|
version = "0.111.4";
|
||||||
components = {
|
components = {
|
||||||
"abode" = ps: with ps; [ ]; # missing inputs: abodepy
|
"abode" = ps: with ps; [ ]; # missing inputs: abodepy
|
||||||
"acer_projector" = ps: with ps; [ pyserial];
|
"acer_projector" = ps: with ps; [ pyserial];
|
||||||
@ -796,7 +796,7 @@
|
|||||||
"telnet" = ps: with ps; [ ];
|
"telnet" = ps: with ps; [ ];
|
||||||
"temper" = ps: with ps; [ ]; # missing inputs: temperusb
|
"temper" = ps: with ps; [ ]; # missing inputs: temperusb
|
||||||
"template" = ps: with ps; [ ];
|
"template" = ps: with ps; [ ];
|
||||||
"tensorflow" = ps: with ps; [ numpy pillow protobuf tensorflow];
|
"tensorflow" = ps: with ps; [ numpy pillow protobuf]; # missing inputs: tensorflow
|
||||||
"tesla" = ps: with ps; [ ]; # missing inputs: teslajsonpy
|
"tesla" = ps: with ps; [ ]; # missing inputs: teslajsonpy
|
||||||
"tfiac" = ps: with ps; [ ]; # missing inputs: pytfiac
|
"tfiac" = ps: with ps; [ ]; # missing inputs: pytfiac
|
||||||
"thermoworks_smoke" = ps: with ps; [ stringcase]; # missing inputs: thermoworks_smoke
|
"thermoworks_smoke" = ps: with ps; [ stringcase]; # missing inputs: thermoworks_smoke
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ stdenv, lib, fetchurl, fetchFromGitHub, fetchpatch, python3, protobuf3_6
|
{ stdenv, nixosTests, lib, fetchurl, fetchFromGitHub, fetchpatch, python3, protobuf3_6
|
||||||
|
|
||||||
# Look up dependencies of specified components in component-packages.nix
|
# Look up dependencies of specified components in component-packages.nix
|
||||||
, extraComponents ? [ ]
|
, extraComponents ? [ ]
|
||||||
@ -22,11 +22,6 @@ let
|
|||||||
defaultOverrides = [
|
defaultOverrides = [
|
||||||
# Override the version of some packages pinned in Home Assistant's setup.py
|
# Override the version of some packages pinned in Home Assistant's setup.py
|
||||||
|
|
||||||
# used by check_config script
|
|
||||||
# can be unpinned once https://github.com/home-assistant/home-assistant/issues/11917 is resolved
|
|
||||||
(mkOverride "colorlog" "4.0.2"
|
|
||||||
"3cf31b25cbc8f86ec01fef582ef3b840950dea414084ed19ab922c8b493f9b42")
|
|
||||||
|
|
||||||
# required by the sun/moon plugins
|
# required by the sun/moon plugins
|
||||||
# https://github.com/home-assistant/core/issues/36636
|
# https://github.com/home-assistant/core/issues/36636
|
||||||
(mkOverride "astral" "1.10.1"
|
(mkOverride "astral" "1.10.1"
|
||||||
@ -72,7 +67,7 @@ let
|
|||||||
extraBuildInputs = extraPackages py.pkgs;
|
extraBuildInputs = extraPackages py.pkgs;
|
||||||
|
|
||||||
# Don't forget to run parse-requirements.py after updating
|
# Don't forget to run parse-requirements.py after updating
|
||||||
hassVersion = "0.111.0";
|
hassVersion = "0.111.4";
|
||||||
|
|
||||||
in with py.pkgs; buildPythonApplication rec {
|
in with py.pkgs; buildPythonApplication rec {
|
||||||
pname = "homeassistant";
|
pname = "homeassistant";
|
||||||
@ -91,7 +86,7 @@ in with py.pkgs; buildPythonApplication rec {
|
|||||||
owner = "home-assistant";
|
owner = "home-assistant";
|
||||||
repo = "core";
|
repo = "core";
|
||||||
rev = version;
|
rev = version;
|
||||||
sha256 = "0zg7fng3cfksn4hr8vixsmj8cbag8h4dg4qi69n56hc71rnpl9kw";
|
sha256 = "08dkqczpmdaz8k9fsshgvgma7i7sffzgmhsi49qki7vwn20hl2hf";
|
||||||
};
|
};
|
||||||
|
|
||||||
propagatedBuildInputs = [
|
propagatedBuildInputs = [
|
||||||
@ -128,6 +123,9 @@ in with py.pkgs; buildPythonApplication rec {
|
|||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit (py.pkgs) hass-frontend;
|
inherit (py.pkgs) hass-frontend;
|
||||||
|
tests = {
|
||||||
|
inherit (nixosTests) home-assistant;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
|
@ -4,11 +4,11 @@ buildPythonPackage rec {
|
|||||||
# the frontend version corresponding to a specific home-assistant version can be found here
|
# the frontend version corresponding to a specific home-assistant version can be found here
|
||||||
# https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/frontend/manifest.json
|
# https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/frontend/manifest.json
|
||||||
pname = "home-assistant-frontend";
|
pname = "home-assistant-frontend";
|
||||||
version = "20200603.2";
|
version = "20200603.3";
|
||||||
|
|
||||||
src = fetchPypi {
|
src = fetchPypi {
|
||||||
inherit pname version;
|
inherit pname version;
|
||||||
sha256 = "1p99f5q8frk5k5lh1gjxyq539p1iv9fslpbfirh8njx3d0a85l84";
|
sha256 = "12bbvqckry6yr7409dir49pjcaa31z74fy6vb0mgr9xzvri5c2s8";
|
||||||
};
|
};
|
||||||
|
|
||||||
# no Python tests implemented
|
# no Python tests implemented
|
||||||
|
34
pkgs/servers/home-assistant/update.sh
Executable file
34
pkgs/servers/home-assistant/update.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -p nix -p jq -p curl -p bash -p git -p nix-update -i bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
CURRENT_VERSION=$(nix eval --raw '(with import ../../.. {}; home-assistant.version)')
|
||||||
|
TARGET_VERSION=$(curl https://api.github.com/repos/home-assistant/core/releases/latest | jq -r '.name')
|
||||||
|
MANIFEST=$(curl https://raw.githubusercontent.com/home-assistant/core/${TARGET_VERSION}/homeassistant/components/frontend/manifest.json)
|
||||||
|
FRONTEND_VERSION=$(echo $MANIFEST | jq -r '.requirements[] | select(startswith("home-assistant-frontend")) | sub(".*==(?<vers>.*)"; .vers)')
|
||||||
|
|
||||||
|
if [[ "$CURRENT_VERSION" == "$TARGET_VERSION" ]]; then
|
||||||
|
echo "home-assistant is up-to-date: ${CURRENT_VERSION}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
sed -i -e "s/version =.*/version = \"${TARGET_VERSION}\";/" \
|
||||||
|
component-packages.nix
|
||||||
|
|
||||||
|
sed -i -e "s/hassVersion =.*/hassVersion = \"${TARGET_VERSION}\";/" \
|
||||||
|
default.nix
|
||||||
|
|
||||||
|
./parse-requirements.py
|
||||||
|
(
|
||||||
|
cd ../../..
|
||||||
|
nix-update --version "$FRONTEND_VERSION" home-assistant.hass-frontend
|
||||||
|
nix-update --version "$TARGET_VERSION" --build home-assistant
|
||||||
|
)
|
||||||
|
|
||||||
|
git add ./component-packages.nix ./default.nix ./frontend.nix
|
||||||
|
git commit -m "homeassistant: ${CURRENT_VERSION} -> ${TARGET_VERSION}"
|
Loading…
Reference in New Issue
Block a user