Home Assistant: Difference between revisions

imported>Abowen
Add firewall for containers
Mfed3 (talk | contribs)
Combine declarative and UI defined automations: - Added another example for how to declaratively make "entity_id" customizations that will generate yaml code for them.
Line 374: Line 374:
</syntaxHighlight>
</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:
=== Declarative Nix Configuration Examples ===
 
==== Entity Customization ====
You can declaratively define how entities appear in the GUI with respect to their display names (friendly_name) the "show as" (device_class) and the icon displayed (icon). See this page for more documentation and how the yaml will ultimately be generated: https://www.home-assistant.io/docs/configuration/customizing-devices/. <syntaxhighlight lang="nix">
    config = {
      default_config = {};
      homeassistant = {
        # MUST be at the top or will break entire configuration
        customize = {
          # Declare all "entity_id" objects here at this level to customize them
          "binary_sensor.name" = {
            # Custom name however you want the entity to appear in the GUI
            friendly_name = "friendlyname";
            # See https://www.home-assistant.io/integrations/binary_sensor/ for documentation
            device_class = "deviceclass";
            # See https://www.home-assistant.io/docs/configuration/customizing-devices/#icon for documentation
            icon = "mdi:iconname";
          };
        };
      };
    };
 
</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>