Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏡 Home Assistant Refresh #340251

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 139 additions & 69 deletions nixos/modules/services/home-automation/home-assistant.nix

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ in {
hledger-web = handleTest ./hledger-web.nix {};
hocker-fetchdocker = handleTest ./hocker-fetchdocker {};
hockeypuck = handleTest ./hockeypuck.nix { };
home-assistant = handleTest ./home-assistant.nix {};
home-assistant = runTest ./home-assistant.nix;
hostname = handleTest ./hostname.nix {};
hound = handleTest ./hound.nix {};
hub = handleTest ./git/hub.nix {};
Expand Down
37 changes: 20 additions & 17 deletions nixos/tests/home-assistant.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import ./make-test-python.nix ({ pkgs, lib, ... }:
{
lib,
...
}:

let
configDir = "/var/lib/foobar";
Expand Down Expand Up @@ -32,24 +35,24 @@ in {
});

# provide component dependencies explicitly from the module
extraComponents = [
integrations = [
"mqtt"
];

# provide package for postgresql support
extraPackages = python3Packages: with python3Packages; [
extraPythonPackages = python3Packages: with python3Packages; [
psycopg2
];

# test loading custom components
customComponents = with pkgs.home-assistant-custom-components; [
# test loading community maintained integration packages
integrationPackages = with pkgs.home-assistant-custom-components; [
prometheus_sensor
# tests loading multiple components from a single package
spook
];

# test loading lovelace modules
customLovelaceModules = with pkgs.home-assistant-custom-lovelace-modules; [
# test loading lovelace resource modules
lovelaceResourcePackages = with pkgs.home-assistant-custom-lovelace-modules; [
mini-graph-card
];

Expand Down Expand Up @@ -122,14 +125,14 @@ in {
# Cause a configuration change that requires a service restart as we added a new runtime dependency
specialisation.newFeature = {
inheritParentConfig = true;
configuration.services.home-assistant.config.backup = {};
configuration.services.home-assistant.config.prometheus = {};
};

specialisation.removeCustomThings = {
inheritParentConfig = true;
configuration.services.home-assistant = {
customComponents = lib.mkForce [];
customLovelaceModules = lib.mkForce [];
integrationPackages = lib.mkForce [];
lovelaceResourcePackages = lib.mkForce [];
};
};
};
Expand Down Expand Up @@ -206,25 +209,25 @@ in {
with subtest("Check extra components are considered in systemd unit hardening"):
hass.succeed("systemctl show -p DeviceAllow home-assistant.service | grep -q char-ttyUSB")

with subtest("Check service reloads when configuration changes"):
with subtest("Check service restart from SIGHUP"):
pid = hass.succeed("systemctl show --property=MainPID home-assistant.service")
cursor = get_journal_cursor()
hass.succeed("${system}/specialisation/differentName/bin/switch-to-configuration test")
new_pid = hass.succeed("systemctl show --property=MainPID home-assistant.service")
assert pid == new_pid, "The PID of the process should not change between process reloads"
wait_for_homeassistant(cursor)
new_pid = hass.succeed("systemctl show --property=MainPID home-assistant.service")
assert pid != new_pid, "The PID of the process must change after sending SIGHUP"

with subtest("Check service restarts when dependencies change"):
pid = new_pid
cursor = get_journal_cursor()
hass.succeed("${system}/specialisation/newFeature/bin/switch-to-configuration test")
new_pid = hass.succeed("systemctl show --property=MainPID home-assistant.service")
assert pid != new_pid, "The PID of the process should change when its PYTHONPATH changess"
wait_for_homeassistant(cursor)
new_pid = hass.succeed("systemctl show --property=MainPID home-assistant.service")
assert pid != new_pid, "The PID of the process must change when its PYTHONPATH changess"

with subtest("Check that new components get setup after restart"):
journal = get_journal_since(cursor)
for domain in ["backup"]:
for domain in ["prometheus"]:
assert f"Setup of domain {domain} took" in journal, f"{domain} setup missing"

with subtest("Check custom components and custom lovelace modules get removed"):
Expand All @@ -242,4 +245,4 @@ in {
hass.log(hass.succeed("systemctl cat home-assistant.service"))
hass.log(hass.succeed("systemd-analyze security home-assistant.service"))
'';
})
}
21 changes: 21 additions & 0 deletions pkgs/servers/home-assistant/autocalling-package-set.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
lib,
callPackage,
baseDirectory,
}:

let
inherit (lib)
filterAttrs
mapAttrs'
nameValuePair
;

inherit (builtins)
readDir
;

toPackageAttribute =
dir: type: nameValuePair dir (callPackage (baseDirectory + "/${dir}/default.nix") { });
in
mapAttrs' toPackageAttribute (filterAttrs (_: type: type == "directory") (readDir baseDirectory))
2 changes: 1 addition & 1 deletion pkgs/servers/home-assistant/custom-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ buildHomeAssistantComponent {
# owner, repo, rev, hash
};

propagatedBuildInputs = [
dependencies = [
# python requirements, as specified in manifest.json
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-k5pCgPM5xjVfWjOcr0UDFzYl/8z7yUwgYdBmC3+2F5k=";
};

propagatedBuildInputs = [
dependencies = [
ulid-transform
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-ucSaQWMS6ZwXHnw5Ct/STxpl1JjBRua3edrLvBAsdyw=";
};

propagatedBuildInputs = [
dependencies = [
requests
];

Expand Down
86 changes: 7 additions & 79 deletions pkgs/servers/home-assistant/custom-components/default.nix
Original file line number Diff line number Diff line change
@@ -1,82 +1,10 @@
{ callPackage
}:

{
adaptive_lighting = callPackage ./adaptive_lighting {};

alarmo = callPackage ./alarmo {};

auth-header = callPackage ./auth-header {};

awtrix = callPackage ./awtrix {};

better_thermostat = callPackage ./better_thermostat {};

dwd = callPackage ./dwd { };

elevenlabs_tts = callPackage ./elevenlabs_tts {};

emporia_vue = callPackage ./emporia_vue {};

epex_spot = callPackage ./epex_spot {};

frigate = callPackage ./frigate {};

garmin_connect = callPackage ./garmin_connect {};

govee-lan = callPackage ./govee-lan {};

gpio = callPackage ./gpio {};

homematicip_local = callPackage ./homematicip_local { };

indego = callPackage ./indego { };

local_luftdaten = callPackage ./local_luftdaten { };

localtuya = callPackage ./localtuya {};

mass = callPackage ./mass { };

midea_ac_lan = callPackage ./midea_ac_lan {};

midea-air-appliances-lan = callPackage ./midea-air-appliances-lan {};

miele = callPackage ./miele {};

moonraker = callPackage ./moonraker {};

ntfy = callPackage ./ntfy {};

omnik_inverter = callPackage ./omnik_inverter {};

prometheus_sensor = callPackage ./prometheus_sensor {};

samsungtv-smart = callPackage ./samsungtv-smart {};

sensi = callPackage ./sensi {};

smartir = callPackage ./smartir {};

smartthinq-sensors = callPackage ./smartthinq-sensors {};

solis-sensor = callPackage ./solis-sensor {};

somweb = callPackage ./somweb {};

spook = callPackage ./spook {};

tuya_local = callPackage ./tuya_local {};

volkswagen_we_connect_id = callPackage ./volkswagen_we_connect_id { };

volkswagencarnet = callPackage ./volkswagencarnet { };

waste_collection_schedule = callPackage ./waste_collection_schedule {};

xiaomi_gateway3 = callPackage ./xiaomi_gateway3 {};

xiaomi_miot = callPackage ./xiaomi_miot {};
callPackage,
lib,
...
}:

yassi = callPackage ./yassi {};
import ../autocalling-package-set.nix {
inherit callPackage lib;
baseDirectory = ./.;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-6NrRuBjpulT66pVUfW9ujULL5HSzfgyic1pKEBRupNA=";
};

propagatedBuildInputs = [
dependencies = [
pyemvue
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-BwNDI2OMF6bXqFcdr0AJgj9Gb6Uz8BWOfE7M4jqzQJc=";
};

propagatedBuildInputs = [
dependencies = [
beautifulsoup4
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ buildHomeAssistantComponent {

dontBuild = true;

propagatedBuildInputs = [
dependencies = [
govee-led-wez
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-JyyJPI0lbZLJj+016WgS1KXU5rnxUmRMafel4/wKsYk=";
};

propagatedBuildInputs = [ libgpiod ];
dependencies = [ libgpiod ];

meta = with lib; {
description = "Home Assistant GPIO custom integration";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-Fl8qwsW9NdjnYdu7IGQDelXTLqNx5ioUoxkhv+p5L0I=";
};

propagatedBuildInputs = [ midea-beautiful-air ];
dependencies = [ midea-beautiful-air ];

meta = with lib; {
description = "Home Assistant custom component adding support for controlling Midea air conditioners and dehumidifiers on local network";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-J9n4PFcd87L301B2YktrLcxp5Vu1HwDeCYnrMEJ0+TA=";
};

propagatedBuildInputs = [
dependencies = [
flatdict
pymiele
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-J44JLV9w3ibVoPMEkDdti07fU2hxe46KK4WKQQ/Gn7c=";
};

propagatedBuildInputs = [
dependencies = [
moonraker-api
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-OGCAJsAsnUjwaLR8lCBdU+ghVOGFF0mT73t5JtcngUA=";
};

propagatedBuildInputs = [
dependencies = [
requests
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-O1NxT7u27xLydPqEqH72laU0tlYVrMPo0TwWIVNJ+0Q=";
};

propagatedBuildInputs = [
dependencies = [
omnikinverter
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-NbK9h0nvcWNSwsc04YgjqKl+InijxftPJ3SLCQF/Hns=";
};

propagatedBuildInputs = [
dependencies = [
websockets
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ buildHomeAssistantComponent rec {
})
];

propagatedBuildInputs = [
dependencies = [
aiofiles
broadlink
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-tLq4sqeKmjEDDaowA8ouH/mI7jQfq49kkt/a8+40rhQ=";
};

propagatedBuildInputs = [
dependencies = [
charset-normalizer
pycountry
xmltodict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-C8aY23e6iWANbhCRQYNHx+3fomVO+7qdxj+qfv+K3JM=";
};

propagatedBuildInputs = [ zigpy ];
dependencies = [ zigpy ];

dontBuild = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-wR5N6a+g4TE9cRv1k4zExCWiui7ZHwK54j0oUxnhcR0=";
};

propagatedBuildInputs = [
dependencies = [
hap-python
micloud
pyqrcode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildHomeAssistantComponent rec {
hash = "sha256-pkwkXI05zDMEXPoE90YJBxoPYlzmSHH/BLExq0J1JrQ=";
};

propagatedBuildInputs = [ pysmartthings ];
dependencies = [ pysmartthings ];

meta = with lib; {
description = "HomeAssistant integration for Samsung Soundbars";
Expand Down
Loading
Loading