Home Assistant: Difference between revisions

N42 (talk | contribs)
update heading level
Hexa (talk | contribs)
m url fix
 
(16 intermediate revisions by 6 users not shown)
Line 5: Line 5:
NixOS provides native support for [https://www.home-assistant.io/faq/ha-vs-hassio/ Home Assistant Core] and offers integration facilities for most pieces of its comprehensive ecosystem:
NixOS provides native support for [https://www.home-assistant.io/faq/ha-vs-hassio/ Home Assistant Core] and offers integration facilities for most pieces of its comprehensive ecosystem:


* As of the 2025.1.2 release we support roughly 91.1% (1185/1302) of the built-in integrations
* As of the 2026.2.0 release we support over 98% (1375/1394) of the built-in integrations
* We support [https://github.com/NixOS/nixpkgs/tree/master/pkgs/servers/home-assistant/custom-components custom components] through the <code>[https://search.nixos.org/options?channel=unstable&show=services.home-assistant.customComponents&from=0&size=50&sort=relevance&type=packages&query=services.home-assistant.customComponents services.home-assistant.customComponents]</code> option
* We support [https://github.com/NixOS/nixpkgs/tree/master/pkgs/servers/home-assistant/custom-components custom components] through the <code>[https://search.nixos.org/options?channel=unstable&show=services.home-assistant.customComponents&from=0&size=50&sort=relevance&type=packages&query=services.home-assistant.customComponents services.home-assistant.customComponents]</code> option
* We support source-built [https://github.com/NixOS/nixpkgs/tree/master/pkgs/servers/home-assistant/custom-lovelace-modules custom lovelace modules] mostly through [https://search.nixos.org/options?channel=unstable&show=services.home-assistant.customLovelaceModules&from=0&size=50&sort=relevance&type=packages&query=services.home-assistant.customLovelaceModules services.home-assistant.customLovelaceModules] option
* We support source-built [https://github.com/NixOS/nixpkgs/tree/master/pkgs/servers/home-assistant/custom-lovelace-modules custom lovelace modules] mostly through [https://search.nixos.org/options?channel=unstable&show=services.home-assistant.customLovelaceModules&from=0&size=50&sort=relevance&type=packages&query=services.home-assistant.customLovelaceModules services.home-assistant.customLovelaceModules] option
* We do not support [https://www.home-assistant.io/addons/ addons], which are used to deploy additional services, that are configurable from Home Assistant on their operating system
* We do not support [https://www.home-assistant.io/addons/ apps] (previously addons), which are used to deploy additional services, that are configurable from Home Assistant on their operating system
** NixOS has native support for various services, that integrate with Home Assistant, e.g. [[Mosquitto]], [[Music-Assistant]], [[Wyoming]], [[zigbee2mqtt]], [[Z-Wave JS]]
** NixOS has native support for various services, that integrate with Home Assistant, e.g. [[EVCC]], [[Frigate]], [[Mosquitto]], [[Music-Assistant]], [[Wyoming]], [[zigbee2mqtt]], [[Z-Wave JS]]


== Support ==
== Support ==
Line 27: Line 27:
Example:
Example:
* [https://myme.no/posts/2021-11-25-nixos-home-assistant.html NixOS: Headless Home Assistant VM (myme.no)] using libvirt
* [https://myme.no/posts/2021-11-25-nixos-home-assistant.html NixOS: Headless Home Assistant VM (myme.no)] using libvirt
* [https://balisong.dev/blog/running-home-assistant-os-as-a-vm-in-a-nixos-host/ Running Home Assistant OS as a VM in a NixOS Host] using incus


=== OCI container ===
=== OCI container ===
Line 196: Line 197:
We provide a way to declaratively manage custom lovelace modules through the NixOS module with the [https://search.nixos.org/options?channel=unstable&show=services.home-assistant.customLovelaceModules&from=0&size=50&sort=relevance&type=packages&query=home-assistant services.home-assistant.customLovelaceModules] option.
We provide a way to declaratively manage custom lovelace modules through the NixOS module with the [https://search.nixos.org/options?channel=unstable&show=services.home-assistant.customLovelaceModules&from=0&size=50&sort=relevance&type=packages&query=home-assistant services.home-assistant.customLovelaceModules] option.


Custom components can be found under [https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=home-assistant-custom-lovelace-modules pkgs.home-assistant-custom-lovelace-modules].
When a custom module is configured, the generated Home Assistant configuration file (eg. <code>/var/lib/hass/configuration.yaml</code>) will list the module in the <code>lovelace</code> config section as a new resource. If your lovelace configuration mode is <code>yaml</code>, the custom module should be loaded automatically.
 
However, if your lovelace configuration mode is <code>storage</code> (the default), then the Home Assistant lovelace module will ignore the custom module resource. In that case you additionally need to add the custom module through the lovelace UI in the Resources tab with its path like <code>/local/nixos-lovelace-modules/<module-entrypoint></code>.
 
Available custom components can be found under [https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=home-assistant-custom-lovelace-modules pkgs.home-assistant-custom-lovelace-modules].


= Tracking the latest release =  
= Tracking the latest release =  
Line 413: Line 418:
         {
         {
           alias = "Name To Display in Automations List";
           alias = "Name To Display in Automations List";
           trigger = {
           triggers = {
             platform = "state";
             trigger = "state";
             entity_id = "binary_sensor.someid1";
             entity_id = "binary_sensor.someid1";
             to = "off";
             to = "off";
             for = "00:10:00";
             for = "00:10:00";
           };
           };
           condition = {
           conditions = {
             condition = "state";
             condition = "state";
             entity_id = "binary_sensor.someid2";
             entity_id = "binary_sensor.someid2";
             state = "on";
             state = "on";
           };
           };
           action = {
           actions = {
             service = "light.turn_off";
             action = "light.turn_off";
             entity_id = "light.someid";
             entity_id = "light.someid";
           };
           };
Line 435: Line 440:
         {
         {
           alias = "Name in Automations GUI";
           alias = "Name in Automations GUI";
           trigger = {
           triggers = {
             platform = "state";
             trigger = "state";
             entity_id = "binary_sensor.someid";
             entity_id = "binary_sensor.someid";
             to = "on";
             to = "on";
           };
           };
           condition = [
           conditions = [
             {
             {
               condition = "state";
               condition = "state";
Line 452: Line 457:
             }
             }
           ];
           ];
           action = [
           actions = [
             {
             {
               service = "notify.notify";
               action = "notify.notify";
               data = {
               data = {
                 message = "Some Notification";
                 message = "Some Notification";
Line 460: Line 465:
             }
             }
             {
             {
               service = "siren.turn_on";
               action = "siren.turn_on";
               entity_id = "siren.someid";
               entity_id = "siren.someid";
             }
             }
Line 472: Line 477:
         {
         {
           alias = "Some Name";
           alias = "Some Name";
           trigger = {
           triggers = {
             platform = "numeric_state";
             trigger = "numeric_state";
             entity_id = "sensor.batteries";
             entity_id = "sensor.batteries";
             below = "45";
             below = "45";
           };
           };
           action = {
           actions = {
             service = "notify.notify";
             action = "notify.notify";
             data = {
             data = {
               message = "Low Battery Detected";
               message = "Low Battery Detected";
Line 490: Line 495:
         {
         {
           alias = "Object Went Unknown";
           alias = "Object Went Unknown";
           trigger = {
           triggers = {
             platform = "state";
             trigger = "state";
             entity_id = "switch.someid";
             entity_id = "switch.someid";
             to = "unknown";
             to = "unknown";
             for = "00:5:00";
             for = "00:5:00";
           };
           };
           action = {
           actions = {
             service = "notify.notify";
             action = "notify.notify";
             data = {
             data = {
               message = "Object Went Offline";
               message = "Object Went Offline";
Line 510: Line 515:
         {
         {
           alias = "Do Something At Certain Time";
           alias = "Do Something At Certain Time";
           trigger = {
           triggers = {
             platform = "time";
             trigger = "time";
             at = "23:00:00";
             at = "23:00:00";
           };
           };
           action = {
           actions = {
             service = "climate.set_temperature";
             action = "climate.set_temperature";
             entity_id = "climate.thermostat";
             entity_id = "climate.thermostat";
             data = {
             data = {
Line 525: Line 530:
</syntaxhighlight>If you did not create any automations through the UI, Home Assistant will fail loading because the <code>automations.yaml</code> file does not exist yet, and it will fail including it. To avoid that, add a systemd tmpfiles.d rule:
</syntaxhighlight>If you did not create any automations through the UI, Home Assistant will fail loading because the <code>automations.yaml</code> file does not exist yet, and it will fail including it. To avoid that, add a systemd tmpfiles.d rule:


<syntaxHighlight lang=nix>
<syntaxhighlight lang="nix">
systemd.tmpfiles.rules = [
systemd.tmpfiles.rules = [
   "f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass"
   "f ${config.services.home-assistant.configDir}/automations.yaml 0644 hass hass"
];
];
</syntaxHighlight>
</syntaxhighlight>


== Trust a private certificate authority ==
== Trust a private certificate authority ==
Line 561: Line 566:
When developing Home Assistant for some test dependencies additional libraries are needed.
When developing Home Assistant for some test dependencies additional libraries are needed.
A nix-shell expression for this is available [https://github.com/nix-community/nix-environments/tree/master/envs/home-assistant here].
A nix-shell expression for this is available [https://github.com/nix-community/nix-environments/tree/master/envs/home-assistant here].
= Further reading =
* [https://nixcademy.com/posts/auto-update-containers/ Run and Auto-Update Docker (Home Assistant) Containers on NixOS], Nixcademy


[[Category:Applications]]
[[Category:Applications]]