From e0753750fd8511c522c40b1ae6b22f71a583678e Mon Sep 17 00:00:00 2001 From: tdfountain <174762217+tdfountain@users.noreply.github.com> Date: Sun, 13 Apr 2025 23:25:48 -0700 Subject: [PATCH] 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 * Remove description and enquote alias in example Co-authored-by: Franck Nijhof * Remove mode of single since default Co-authored-by: Franck Nijhof * Enquote message string Co-authored-by: Franck Nijhof * 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 --- source/_integrations/nut.markdown | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/source/_integrations/nut.markdown b/source/_integrations/nut.markdown index 2f58fc60784..42e2dab454a 100644 --- a/source/_integrations/nut.markdown +++ b/source/_integrations/nut.markdown @@ -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):