Home Assistant: Difference between revisions

Mfed3 (talk | contribs)
Declarative Nix Configuration Examples: - Added another example of how to include multiple conditions and multiple actions
Mfed3 (talk | contribs)
Automations: - Added another 2 examples for some more Trigger types (time based, duration based)
Line 456: Line 456:
             }
             }
           ];
           ];
        }
</syntaxhighlight>
==== Trigger Using Numeric State ====
<syntaxhighlight lang="nix">
        {
          alias = "Some Name";
          trigger = {
            platform = "numeric_state";
            entity_id = "sensor.batteries";
            below = "45";
          };
          action = {
            service = "notify.notify";
            data = {
              message = "Low Battery Detected";
            };
          };
        }
</syntaxhighlight>
==== Trigger Checking for Entity State Missing / Changing to Unknown ====
<syntaxhighlight lang="nix">
        {
          alias = "Object Went Unknown";
          trigger = {
            platform = "state";
            entity_id = "switch.someid";
            to = "unknown";
            for = "00:5:00";
          };
          action = {
            service = "notify.notify";
            data = {
              message = "Object Went Offline";
            };
          };
        }
</syntaxhighlight>
==== Time Based Trigger, Setting Data Field On Entity Such as Thermostat ====
<syntaxhighlight lang="nix">
        {
          alias = "Do Something At Certain Time";
          trigger = {
            platform = "time";
            at = "23:00:00";
          };
          action = {
            service = "climate.set_temperature";
            entity_id = "climate.thermostat";
            data = {
              temperature = "68";
            };
          };
         }
         }