diff options
author | Martin Weinelt <hexa@darmstadt.ccc.de> | 2020-07-01 19:17:01 +0200 |
---|---|---|
committer | Martin Weinelt <hexa@darmstadt.ccc.de> | 2020-07-07 01:43:44 +0200 |
commit | 1093962cf04c9d25f5c8cd9413c3be122f92fbbb (patch) | |
tree | 6969df9870da06777ab39f205ffd701d9315d88a /nixos/tests/home-assistant.nix | |
parent | 963de34c62d930b0132e69ab28c4f6f2486a21e7 (diff) |
nixos/tests/home-assistant: replace internal mqtt broker with mosquitto
The internal broker was deprecated since 0.92.0 and removed in 0.112.0.
Diffstat (limited to 'nixos/tests/home-assistant.nix')
-rw-r--r-- | nixos/tests/home-assistant.nix | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/nixos/tests/home-assistant.nix b/nixos/tests/home-assistant.nix index 0d1fcedcd857..a93a28d877a3 100644 --- a/nixos/tests/home-assistant.nix +++ b/nixos/tests/home-assistant.nix @@ -2,6 +2,7 @@ import ./make-test-python.nix ({ pkgs, ... }: let configDir = "/var/lib/foobar"; + mqttUsername = "homeassistant"; mqttPassword = "secret"; in { name = "home-assistant"; @@ -11,6 +12,15 @@ in { nodes.hass = { pkgs, ... }: { environment.systemPackages = with pkgs; [ mosquitto ]; + services.mosquitto = { + enable = true; + users = { + "${mqttUsername}" = { + acl = [ "pattern readwrite #" ]; + password = mqttPassword; + }; + }; + }; services.home-assistant = { inherit configDir; enable = true; @@ -23,8 +33,11 @@ in { elevation = 0; }; frontend = {}; - # uses embedded mqtt broker - mqtt.password = mqttPassword; + mqtt = { + broker = "127.0.0.1"; + username = mqttUsername; + password = mqttPassword; + }; binary_sensor = [{ platform = "mqtt"; state_topic = "home-assistant/test"; @@ -64,10 +77,10 @@ in { with subtest("Toggle a binary sensor using MQTT"): # wait for broker to become available hass.wait_until_succeeds( - "mosquitto_sub -V mqttv311 -t home-assistant/test -u homeassistant -P '${mqttPassword}' -W 1 -t '*'" + "mosquitto_sub -V mqttv311 -t home-assistant/test -u ${mqttUsername} -P '${mqttPassword}' -W 1 -t '*'" ) hass.succeed( - "mosquitto_pub -V mqttv311 -t home-assistant/test -u homeassistant -P '${mqttPassword}' -m let_there_be_light" + "mosquitto_pub -V mqttv311 -t home-assistant/test -u ${mqttUsername} -P '${mqttPassword}' -m let_there_be_light" ) with subtest("Print log to ease debugging"): output_log = hass.succeed("cat ${configDir}/home-assistant.log") |