Home Assistant: Difference between revisions
→More Declarative Nix Configuration Examples: Added alarm control panel example |
→More Declarative Nix Configuration Examples: - Added more examples of how to declaratively define Groups / Helpers |
||
Line 428: | Line 428: | ||
]; | ]; | ||
</syntaxhighlight> | |||
=== Groups / Helpers === | |||
You can declaratively define groups rather than setting them up in the GUI, and customize their unique_id, platform, type, and entitiy_id's associated. See https://www.home-assistant.io/integrations/group/ for more documentation. Can be used in conjunction with "Entity Customization" section above for additional flexibility by plugging in the "unique_id" then changing the "friendly_name", "icon", "device_class" etc. | |||
==== Binary Sensor Group ==== | |||
Example of Door and Window Sensor Group that could be used in an Automation for triggering an alarm system if any door or window is opened.<syntaxhighlight lang="nix"> | |||
# Door and Window Sensor Group | |||
"binary_sensor" = [ | |||
{ | |||
unique_id = "binary_sensor.all_door_and_window_sensors"; | |||
platform = "group"; | |||
device_class = "door"; | |||
entities = [ | |||
"binary_sensor.sensor_1" | |||
"binary_sensor.sensor_2" | |||
"binary_sensor.sensor_3" | |||
]; | |||
} | |||
]; | |||
</syntaxhighlight> | |||
==== Sensor Group ==== | |||
Example of Sensor group using "min" mode that could be used in an Automation to trigger a Low Battery Alert across all batteries in the group.<syntaxhighlight lang="nix"> | |||
# Sensor Battery Group | |||
"sensor" = [ | |||
{ | |||
unique_id = "sensor.all_batteries"; | |||
platform = "group"; | |||
type = "min"; | |||
# Use this or else if any go to "unknown" the group will show unknown | |||
ignore_non_numeric = "true"; | |||
device_class = "battery"; | |||
entities = [ | |||
"sensor.battery_1" | |||
"sensor.battery_2" | |||
"sensor.battery_3" | |||
]; | |||
} | |||
]; | |||
</syntaxhighlight> | </syntaxhighlight> |