Add automation example to NUT (#38389)

* Add Automation example documentation

* Apply CodeRabbit suggestions

* Update source/_integrations/nut.markdown

Add sub-heading for Prerequisites in example

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>

* Update source/_integrations/nut.markdown

Change prerequisites from sentence to bulleted list

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>

* Update source/_integrations/nut.markdown

Add sub header for YAML example

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>

* Remove conditions from example

Co-authored-by: Franck Nijhof <frenck@frenck.nl>

* Remove description and enquote alias in example

Co-authored-by: Franck Nijhof <frenck@frenck.nl>

* Remove mode of single since default

Co-authored-by: Franck Nijhof <frenck@frenck.nl>

* Enquote message string

Co-authored-by: Franck Nijhof <frenck@frenck.nl>

* Add enquote and lower case to notify title in example

* Clarify device and sensor name

* Clarify example is YAML

* Change comment capitalization to match other requested change

---------

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
tdfountain 2025-04-13 23:25:48 -07:00 committed by GitHub
parent c3434cc24d
commit e0753750fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -290,6 +290,48 @@ An action is available for each parameterless NUT
[command](https://networkupstools.org/docs/user-manual.chunked/apcs03.html)
supported.
## Automation example
Home Assistant {% term automations %} can be created to monitor and
take actions on one or more power devices using NUT.
The following example illustrates how to use this integration in a
Home Assistant automation. This example is just a starting point, and
you can use it as inspiration to create your own automations.
### UPS Power Failure Notification
The following example sends a notification to your mobile device when
a monitored UPS loses power and begins using the battery.
#### Prerequisites
- The NUT integration must be installed and
configured.
- Your mobile device must be configured for
notification.
- In the example below, the NUT server device is `ups` with the status
sensor named `ups_status`. You must change the YAML sensor name to
match your system.
#### Example in YAML
```yaml
# Send notification on UPS power failure
automation:
alias: "NUT Power failure notification"
triggers:
- trigger: state
entity_id:
- sensor.ups_status
to: "On Battery Battery Discharging"
actions:
- action: notify.notify
data:
title: "UPS power failure"
message: "The UPS lost power and is now on battery"
```
## Example resources
Given the following example output from NUT (your variables may differ):