<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Antiz</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Antiz"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Antiz"/>
	<updated>2026-05-10T14:19:59Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=32102</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=32102"/>
		<updated>2026-03-01T22:16:46Z</updated>

		<summary type="html">&lt;p&gt;Antiz: Add a note about adding the udev-trigger service to a runlevel for the udev rule to automatically apply at boot&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page shows how to install and configure the Network UPS Tools (NUT) package to monitor and report the statistics for a USB-attached Uninterruptible Power Supply (UPS) and make the UPS status available over the network, so that it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
== Determine UPS USB parameters ==&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine Linux host to see how it appears to the system. Information about the UPS can be seen with the {{ic|dmesg}} command. See the example below.{{Cmd|&amp;lt;nowiki&amp;gt;# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;&#039;idVendor=051d&#039;&#039;&#039; and &#039;&#039;&#039;idProduct=0002&#039;&#039;&#039;. These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
These parameters can also simply be retrieved from {{ic|lsusb}}. See the example below.{{Cmd|&amp;lt;nowiki&amp;gt;# lsusb&lt;br /&gt;
 Bus 001 Device 001: ID 1d6b:0002 Linux 6.12.67-0-rpi dwc_otg_hcd DWC OTG Controller&lt;br /&gt;
 Bus 001 Device 003: ID 0424:2514&lt;br /&gt;
 Bus 001 Device 002: ID 0424:2514&lt;br /&gt;
 Bus 001 Device 004: ID 0463:ffff EATON Ellipse ECO&lt;br /&gt;
 Bus 001 Device 005: ID 0424:7800&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a EATON Ellipse ECO UPS has been detected. We can also see the two important parameters from the ID field, with &#039;&#039;&#039;0463&#039;&#039;&#039; being the &#039;&#039;&#039;idVendor&#039;&#039;&#039; and &#039;&#039;&#039;ffff&#039;&#039;&#039; being the &#039;&#039;&#039;idProduct&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
Install the {{pkg|nut}} package:{{Cmd|# apk add nut}}&lt;br /&gt;
&lt;br /&gt;
== Configuration == &lt;br /&gt;
&lt;br /&gt;
All of the configuration files delivered with the package will be in the {{Path|/etc/nut}} subdirectory. &lt;br /&gt;
&lt;br /&gt;
The following commands rename three original configuration files. {{Cmd|&amp;lt;nowiki&amp;gt;# mv /etc/nut/nut.conf /etc/nut/nut.bak&lt;br /&gt;
# mv /etc/nut/ups.conf /etc/nut/ups.bak&lt;br /&gt;
# mv /etc/nut/upsd.conf /etc/nut/upsd.bak&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Proceed to create the three files with only the configuration parameters needed for our example USB-attached APC Smart-UPS. &lt;br /&gt;
&lt;br /&gt;
To instruct NUT to make the UPS status available on the network, create the {{Path|/etc/nut/nut.conf}} file with content as follows: {{Cat|/etc/nut/nut.conf|&amp;lt;nowiki&amp;gt;MODE=netserver&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
 &lt;br /&gt;
The content of {{Path|/etc/nut/ups.conf}} defines the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB-attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided that it is a USB-attached UPS. Create the file {{Path|/etc/nut/ups.conf}} with content as follows: {{Cat|/etc/nut/ups.conf|&amp;lt;nowiki&amp;gt;[SmartUPS_1000]&lt;br /&gt;
    driver = usbhid-ups&lt;br /&gt;
    port = auto&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
 &lt;br /&gt;
To tell NUT to make the UPS info available on all network interfaces instead of the default i.e localhost only, which is not very useful, create the {{Path|/etc/nut/upsd.conf}} file with content as follows: {{Cat|/etc/nut/upsd.conf|&amp;lt;nowiki&amp;gt;LISTEN 0.0.0.0 3493&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Tip| Replace 0.0.0.0 with the network address of a specific interface if none of the interfaces are appropriate for your situation.}}&lt;br /&gt;
&lt;br /&gt;
=== Configure udev rules ===&lt;br /&gt;
&lt;br /&gt;
To avoid [[#Insufficient permissions on everything|permission errors]], configure &#039;&#039;&#039;udev&#039;&#039;&#039; for giving NUT access to the USB-attached Smart-UPS 1000. Create the file {{Path|/etc/udev/rules.d/62-nut-usbups.rules}} as follows:{{Cat|/etc/udev/rules.d/62-nut-usbups.rules|&amp;lt;nowiki&amp;gt;SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
The &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; in the first part – i.e &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039; – are unique to your UPS. They were found earlier in the [[#Determine UPS USB parameters| Determining UPS USB parameters]] section. The rest of the line tells &#039;&#039;&#039;udev&#039;&#039;&#039; what permissions and group ownership to use, and these should be the same regardless of the UPS make and model.&lt;br /&gt;
&lt;br /&gt;
Use the {{ic|udevadm}} command to tell &#039;&#039;&#039;udev&#039;&#039;&#039; to read in and apply the changes:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# udevadm control --reload &lt;br /&gt;
# udevadm trigger&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Tip|Make sure that the {{ic|udev-trigger}} service is added to a runlevel for the udev rule to automatically apply at boot: {{ic|# rc-update add udev-trigger}}.}}&lt;br /&gt;
{{Note|There is also a file {{Path|/lib/udev/rules.d/62-nut-usbups.rules}} that has information for all of the UPS models that NUT knows about. You may be able to simply copy this rather than constructing your own rules.}}&lt;br /&gt;
&lt;br /&gt;
== Service configuration ==&lt;br /&gt;
&lt;br /&gt;
The service is called {{ic|nut-upsd}} and can be managed using the standard start|stop|restart commands using standard [[OpenRC]] commands.&lt;br /&gt;
&lt;br /&gt;
{{Tip|Remember to [[#Configure udev rules|configure &#039;&#039;&#039;udev&#039;&#039;&#039; rules]] and to [[#Testing the configuration|test the configuration]] before proceeding further.}} &lt;br /&gt;
&lt;br /&gt;
Proceed to start the service as follows: {{Cmd|# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...}}&lt;br /&gt;
&lt;br /&gt;
Notice that the directory {{Path|/run/nut}} is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
[[#Verifying running state|Verify the running state]] before proceeding to configure the automatic startup of the {{ic|nut-upsd}}. If everything looks good, go ahead and set the service to auto-start when the system is booted:{{Cmd|# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default}}&lt;br /&gt;
&lt;br /&gt;
== Using NUT ==&lt;br /&gt;
&lt;br /&gt;
Now, the {{ic|upsc}} command can be run against the name added in {{Path|/etc/nut/ups.conf}} to gather all status information about your UPS. Based on the example used on this wiki page:{{Cmd|$ upsc SmartUPS_1000}}&lt;br /&gt;
One can also gather specific status information by passing them as an argument: {{Cmd|$ upsc SmartUPS_1000 battery.charge}} This is useful to monitor specific values and/or to initiate actions (e.g. from a script) when specific thresholds are reached.&lt;br /&gt;
&lt;br /&gt;
The [[#See also|See also]] section has documentation links about how to configure NUT to do useful things, such as sending an email, initiating a graceful shutdown when the main power is lost, and how to use Home Assistant to keep tabs on your UPS. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting == &lt;br /&gt;
&lt;br /&gt;
=== Testing the configuration ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure that it was detected and that the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the {{Path|/dev/bus/usb}} subdirectories. One of these represents your UPS. If the &#039;&#039;&#039;udev&#039;&#039;&#039; rules work correctly, the file should be the one with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.{{Cmd|# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003}}&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from {{ic|dmesg}} should tip you off as to which directory and file it is. Look at the line below from {{ic|dmesg}} and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of the {{Path|/dev/bus/usb/001/003}}file. {{Cat|/dev/bus/usb/001/003|usb 1-3: Manufacturer: American Power Conversion}}&lt;br /&gt;
&lt;br /&gt;
=== Verifying running state ===&lt;br /&gt;
&lt;br /&gt;
A couple of quick commands will ensure that the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Insufficient permissions on everything ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error message above is due to the USB device having the wrong ownership and permissions. [[#Configure udev rules|Configure &#039;&#039;&#039;udev&#039;&#039;&#039; rules]] and restart the [[#Service configuration|service]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://networkupstools.org/ NUT home page] &lt;br /&gt;
* [https://networkupstools.org/stable-hcl.html list of NUT compatible models]&lt;br /&gt;
* [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant]&lt;br /&gt;
* [[Apcupsd]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;br /&gt;
[[Category:System Administration]]&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>Antiz</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=32101</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=32101"/>
		<updated>2026-03-01T22:10:48Z</updated>

		<summary type="html">&lt;p&gt;Antiz: Update udev rule: Add SUBSYSTEM==&amp;quot;usb&amp;quot; and remove the MODE parameter (which is not needed here)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page shows how to install and configure the Network UPS Tools (NUT) package to monitor and report the statistics for a USB-attached Uninterruptible Power Supply (UPS) and make the UPS status available over the network, so that it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
== Determine UPS USB parameters ==&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine Linux host to see how it appears to the system. Information about the UPS can be seen with the {{ic|dmesg}} command. See the example below.{{Cmd|&amp;lt;nowiki&amp;gt;# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;&#039;idVendor=051d&#039;&#039;&#039; and &#039;&#039;&#039;idProduct=0002&#039;&#039;&#039;. These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
These parameters can also simply be retrieved from {{ic|lsusb}}. See the example below.{{Cmd|&amp;lt;nowiki&amp;gt;# lsusb&lt;br /&gt;
 Bus 001 Device 001: ID 1d6b:0002 Linux 6.12.67-0-rpi dwc_otg_hcd DWC OTG Controller&lt;br /&gt;
 Bus 001 Device 003: ID 0424:2514&lt;br /&gt;
 Bus 001 Device 002: ID 0424:2514&lt;br /&gt;
 Bus 001 Device 004: ID 0463:ffff EATON Ellipse ECO&lt;br /&gt;
 Bus 001 Device 005: ID 0424:7800&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a EATON Ellipse ECO UPS has been detected. We can also see the two important parameters from the ID field, with &#039;&#039;&#039;0463&#039;&#039;&#039; being the &#039;&#039;&#039;idVendor&#039;&#039;&#039; and &#039;&#039;&#039;ffff&#039;&#039;&#039; being the &#039;&#039;&#039;idProduct&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
Install the {{pkg|nut}} package:{{Cmd|# apk add nut}}&lt;br /&gt;
&lt;br /&gt;
== Configuration == &lt;br /&gt;
&lt;br /&gt;
All of the configuration files delivered with the package will be in the {{Path|/etc/nut}} subdirectory. &lt;br /&gt;
&lt;br /&gt;
The following commands rename three original configuration files. {{Cmd|&amp;lt;nowiki&amp;gt;# mv /etc/nut/nut.conf /etc/nut/nut.bak&lt;br /&gt;
# mv /etc/nut/ups.conf /etc/nut/ups.bak&lt;br /&gt;
# mv /etc/nut/upsd.conf /etc/nut/upsd.bak&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Proceed to create the three files with only the configuration parameters needed for our example USB-attached APC Smart-UPS. &lt;br /&gt;
&lt;br /&gt;
To instruct NUT to make the UPS status available on the network, create the {{Path|/etc/nut/nut.conf}} file with content as follows: {{Cat|/etc/nut/nut.conf|&amp;lt;nowiki&amp;gt;MODE=netserver&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
 &lt;br /&gt;
The content of {{Path|/etc/nut/ups.conf}} defines the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB-attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided that it is a USB-attached UPS. Create the file {{Path|/etc/nut/ups.conf}} with content as follows: {{Cat|/etc/nut/ups.conf|&amp;lt;nowiki&amp;gt;[SmartUPS_1000]&lt;br /&gt;
    driver = usbhid-ups&lt;br /&gt;
    port = auto&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
 &lt;br /&gt;
To tell NUT to make the UPS info available on all network interfaces instead of the default i.e localhost only, which is not very useful, create the {{Path|/etc/nut/upsd.conf}} file with content as follows: {{Cat|/etc/nut/upsd.conf|&amp;lt;nowiki&amp;gt;LISTEN 0.0.0.0 3493&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Tip| Replace 0.0.0.0 with the network address of a specific interface if none of the interfaces are appropriate for your situation.}}&lt;br /&gt;
&lt;br /&gt;
=== Configure udev rules ===&lt;br /&gt;
&lt;br /&gt;
To avoid [[#Insufficient permissions on everything|permission errors]], configure &#039;&#039;&#039;udev&#039;&#039;&#039; for giving NUT access to the USB-attached Smart-UPS 1000. Create the file {{Path|/etc/udev/rules.d/62-nut-usbups.rules}} as follows:{{Cat|/etc/udev/rules.d/62-nut-usbups.rules|&amp;lt;nowiki&amp;gt;SUBSYSTEM==&amp;quot;usb&amp;quot;, ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
The &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; in the first part – i.e &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039; – are unique to your UPS. They were found earlier in the [[#Determine UPS USB parameters| Determining UPS USB parameters]] section. The rest of the line tells &#039;&#039;&#039;udev&#039;&#039;&#039; what permissions and group ownership to use, and these should be the same regardless of the UPS make and model.&lt;br /&gt;
&lt;br /&gt;
Use the {{ic|udevadm}} command to tell &#039;&#039;&#039;udev&#039;&#039;&#039; to read in and apply the changes:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# udevadm control --reload &lt;br /&gt;
# udevadm trigger&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Note|There is also a file {{Path|/lib/udev/rules.d/62-nut-usbups.rules}} that has information for all of the UPS models that NUT knows about. You may be able to simply copy this rather than constructing your own rules.}}&lt;br /&gt;
&lt;br /&gt;
== Service configuration ==&lt;br /&gt;
&lt;br /&gt;
The service is called {{ic|nut-upsd}} and can be managed using the standard start|stop|restart commands using standard [[OpenRC]] commands.&lt;br /&gt;
&lt;br /&gt;
{{Tip|Remember to [[#Configure udev rules|configure &#039;&#039;&#039;udev&#039;&#039;&#039; rules]] and to [[#Testing the configuration|test the configuration]] before proceeding further.}} &lt;br /&gt;
&lt;br /&gt;
Proceed to start the service as follows: {{Cmd|# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...}}&lt;br /&gt;
&lt;br /&gt;
Notice that the directory {{Path|/run/nut}} is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
[[#Verifying running state|Verify the running state]] before proceeding to configure the automatic startup of the {{ic|nut-upsd}}. If everything looks good, go ahead and set the service to auto-start when the system is booted:{{Cmd|# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default}}&lt;br /&gt;
&lt;br /&gt;
== Using NUT ==&lt;br /&gt;
&lt;br /&gt;
Now, the {{ic|upsc}} command can be run against the name added in {{Path|/etc/nut/ups.conf}} to gather all status information about your UPS. Based on the example used on this wiki page:{{Cmd|$ upsc SmartUPS_1000}}&lt;br /&gt;
One can also gather specific status information by passing them as an argument: {{Cmd|$ upsc SmartUPS_1000 battery.charge}} This is useful to monitor specific values and/or to initiate actions (e.g. from a script) when specific thresholds are reached.&lt;br /&gt;
&lt;br /&gt;
The [[#See also|See also]] section has documentation links about how to configure NUT to do useful things, such as sending an email, initiating a graceful shutdown when the main power is lost, and how to use Home Assistant to keep tabs on your UPS. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting == &lt;br /&gt;
&lt;br /&gt;
=== Testing the configuration ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure that it was detected and that the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the {{Path|/dev/bus/usb}} subdirectories. One of these represents your UPS. If the &#039;&#039;&#039;udev&#039;&#039;&#039; rules work correctly, the file should be the one with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.{{Cmd|# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003}}&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from {{ic|dmesg}} should tip you off as to which directory and file it is. Look at the line below from {{ic|dmesg}} and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of the {{Path|/dev/bus/usb/001/003}}file. {{Cat|/dev/bus/usb/001/003|usb 1-3: Manufacturer: American Power Conversion}}&lt;br /&gt;
&lt;br /&gt;
=== Verifying running state ===&lt;br /&gt;
&lt;br /&gt;
A couple of quick commands will ensure that the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Insufficient permissions on everything ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error message above is due to the USB device having the wrong ownership and permissions. [[#Configure udev rules|Configure &#039;&#039;&#039;udev&#039;&#039;&#039; rules]] and restart the [[#Service configuration|service]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://networkupstools.org/ NUT home page] &lt;br /&gt;
* [https://networkupstools.org/stable-hcl.html list of NUT compatible models]&lt;br /&gt;
* [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant]&lt;br /&gt;
* [[Apcupsd]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;br /&gt;
[[Category:System Administration]]&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>Antiz</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=32100</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=32100"/>
		<updated>2026-03-01T22:08:59Z</updated>

		<summary type="html">&lt;p&gt;Antiz: Update udevadm commands to actually apply the rule&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page shows how to install and configure the Network UPS Tools (NUT) package to monitor and report the statistics for a USB-attached Uninterruptible Power Supply (UPS) and make the UPS status available over the network, so that it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
== Determine UPS USB parameters ==&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine Linux host to see how it appears to the system. Information about the UPS can be seen with the {{ic|dmesg}} command. See the example below.{{Cmd|&amp;lt;nowiki&amp;gt;# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;&#039;idVendor=051d&#039;&#039;&#039; and &#039;&#039;&#039;idProduct=0002&#039;&#039;&#039;. These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
These parameters can also simply be retrieved from {{ic|lsusb}}. See the example below.{{Cmd|&amp;lt;nowiki&amp;gt;# lsusb&lt;br /&gt;
 Bus 001 Device 001: ID 1d6b:0002 Linux 6.12.67-0-rpi dwc_otg_hcd DWC OTG Controller&lt;br /&gt;
 Bus 001 Device 003: ID 0424:2514&lt;br /&gt;
 Bus 001 Device 002: ID 0424:2514&lt;br /&gt;
 Bus 001 Device 004: ID 0463:ffff EATON Ellipse ECO&lt;br /&gt;
 Bus 001 Device 005: ID 0424:7800&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a EATON Ellipse ECO UPS has been detected. We can also see the two important parameters from the ID field, with &#039;&#039;&#039;0463&#039;&#039;&#039; being the &#039;&#039;&#039;idVendor&#039;&#039;&#039; and &#039;&#039;&#039;ffff&#039;&#039;&#039; being the &#039;&#039;&#039;idProduct&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
Install the {{pkg|nut}} package:{{Cmd|# apk add nut}}&lt;br /&gt;
&lt;br /&gt;
== Configuration == &lt;br /&gt;
&lt;br /&gt;
All of the configuration files delivered with the package will be in the {{Path|/etc/nut}} subdirectory. &lt;br /&gt;
&lt;br /&gt;
The following commands rename three original configuration files. {{Cmd|&amp;lt;nowiki&amp;gt;# mv /etc/nut/nut.conf /etc/nut/nut.bak&lt;br /&gt;
# mv /etc/nut/ups.conf /etc/nut/ups.bak&lt;br /&gt;
# mv /etc/nut/upsd.conf /etc/nut/upsd.bak&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Proceed to create the three files with only the configuration parameters needed for our example USB-attached APC Smart-UPS. &lt;br /&gt;
&lt;br /&gt;
To instruct NUT to make the UPS status available on the network, create the {{Path|/etc/nut/nut.conf}} file with content as follows: {{Cat|/etc/nut/nut.conf|&amp;lt;nowiki&amp;gt;MODE=netserver&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
 &lt;br /&gt;
The content of {{Path|/etc/nut/ups.conf}} defines the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB-attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided that it is a USB-attached UPS. Create the file {{Path|/etc/nut/ups.conf}} with content as follows: {{Cat|/etc/nut/ups.conf|&amp;lt;nowiki&amp;gt;[SmartUPS_1000]&lt;br /&gt;
    driver = usbhid-ups&lt;br /&gt;
    port = auto&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
 &lt;br /&gt;
To tell NUT to make the UPS info available on all network interfaces instead of the default i.e localhost only, which is not very useful, create the {{Path|/etc/nut/upsd.conf}} file with content as follows: {{Cat|/etc/nut/upsd.conf|&amp;lt;nowiki&amp;gt;LISTEN 0.0.0.0 3493&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Tip| Replace 0.0.0.0 with the network address of a specific interface if none of the interfaces are appropriate for your situation.}}&lt;br /&gt;
&lt;br /&gt;
=== Configure udev rules ===&lt;br /&gt;
&lt;br /&gt;
To avoid [[#Insufficient permissions on everything|permission errors]], configure &#039;&#039;&#039;udev&#039;&#039;&#039; for giving NUT access to the USB-attached Smart-UPS 1000. Create the file {{Path|/etc/udev/rules.d/62-nut-usbups.rules}} as follows:{{Cat|/etc/udev/rules.d/62-nut-usbups.rules|&amp;lt;nowiki&amp;gt;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
The &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; in the first part – i.e &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039; – are unique to your UPS. They were found earlier in the [[#Determine UPS USB parameters| Determining UPS USB parameters]] section. The rest of the line tells &#039;&#039;&#039;udev&#039;&#039;&#039; what permissions and group ownership to use, and these should be the same regardless of the UPS make and model.&lt;br /&gt;
&lt;br /&gt;
Use the {{ic|udevadm}} command to tell &#039;&#039;&#039;udev&#039;&#039;&#039; to read in and apply the changes:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# udevadm control --reload &lt;br /&gt;
# udevadm trigger&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Note|There is also a file {{Path|/lib/udev/rules.d/62-nut-usbups.rules}} that has information for all of the UPS models that NUT knows about. You may be able to simply copy this rather than constructing your own rules.}}&lt;br /&gt;
&lt;br /&gt;
== Service configuration ==&lt;br /&gt;
&lt;br /&gt;
The service is called {{ic|nut-upsd}} and can be managed using the standard start|stop|restart commands using standard [[OpenRC]] commands.&lt;br /&gt;
&lt;br /&gt;
{{Tip|Remember to [[#Configure udev rules|configure &#039;&#039;&#039;udev&#039;&#039;&#039; rules]] and to [[#Testing the configuration|test the configuration]] before proceeding further.}} &lt;br /&gt;
&lt;br /&gt;
Proceed to start the service as follows: {{Cmd|# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...}}&lt;br /&gt;
&lt;br /&gt;
Notice that the directory {{Path|/run/nut}} is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
[[#Verifying running state|Verify the running state]] before proceeding to configure the automatic startup of the {{ic|nut-upsd}}. If everything looks good, go ahead and set the service to auto-start when the system is booted:{{Cmd|# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default}}&lt;br /&gt;
&lt;br /&gt;
== Using NUT ==&lt;br /&gt;
&lt;br /&gt;
Now, the {{ic|upsc}} command can be run against the name added in {{Path|/etc/nut/ups.conf}} to gather all status information about your UPS. Based on the example used on this wiki page:{{Cmd|$ upsc SmartUPS_1000}}&lt;br /&gt;
One can also gather specific status information by passing them as an argument: {{Cmd|$ upsc SmartUPS_1000 battery.charge}} This is useful to monitor specific values and/or to initiate actions (e.g. from a script) when specific thresholds are reached.&lt;br /&gt;
&lt;br /&gt;
The [[#See also|See also]] section has documentation links about how to configure NUT to do useful things, such as sending an email, initiating a graceful shutdown when the main power is lost, and how to use Home Assistant to keep tabs on your UPS. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting == &lt;br /&gt;
&lt;br /&gt;
=== Testing the configuration ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure that it was detected and that the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the {{Path|/dev/bus/usb}} subdirectories. One of these represents your UPS. If the &#039;&#039;&#039;udev&#039;&#039;&#039; rules work correctly, the file should be the one with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.{{Cmd|# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003}}&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from {{ic|dmesg}} should tip you off as to which directory and file it is. Look at the line below from {{ic|dmesg}} and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of the {{Path|/dev/bus/usb/001/003}}file. {{Cat|/dev/bus/usb/001/003|usb 1-3: Manufacturer: American Power Conversion}}&lt;br /&gt;
&lt;br /&gt;
=== Verifying running state ===&lt;br /&gt;
&lt;br /&gt;
A couple of quick commands will ensure that the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Insufficient permissions on everything ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error message above is due to the USB device having the wrong ownership and permissions. [[#Configure udev rules|Configure &#039;&#039;&#039;udev&#039;&#039;&#039; rules]] and restart the [[#Service configuration|service]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://networkupstools.org/ NUT home page] &lt;br /&gt;
* [https://networkupstools.org/stable-hcl.html list of NUT compatible models]&lt;br /&gt;
* [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant]&lt;br /&gt;
* [[Apcupsd]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;br /&gt;
[[Category:System Administration]]&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>Antiz</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=32099</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=32099"/>
		<updated>2026-03-01T22:06:08Z</updated>

		<summary type="html">&lt;p&gt;Antiz: Add instructions to find the &amp;quot;idVendor&amp;quot; and &amp;quot;idProduct&amp;quot; parameters via &amp;#039;lsusb&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page shows how to install and configure the Network UPS Tools (NUT) package to monitor and report the statistics for a USB-attached Uninterruptible Power Supply (UPS) and make the UPS status available over the network, so that it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
== Determine UPS USB parameters ==&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine Linux host to see how it appears to the system. Information about the UPS can be seen with the {{ic|dmesg}} command. See the example below.{{Cmd|&amp;lt;nowiki&amp;gt;# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;&#039;idVendor=051d&#039;&#039;&#039; and &#039;&#039;&#039;idProduct=0002&#039;&#039;&#039;. These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
These parameters can also simply be retrieved from {{ic|lsusb}}. See the example below.{{Cmd|&amp;lt;nowiki&amp;gt;# lsusb&lt;br /&gt;
 Bus 001 Device 001: ID 1d6b:0002 Linux 6.12.67-0-rpi dwc_otg_hcd DWC OTG Controller&lt;br /&gt;
 Bus 001 Device 003: ID 0424:2514&lt;br /&gt;
 Bus 001 Device 002: ID 0424:2514&lt;br /&gt;
 Bus 001 Device 004: ID 0463:ffff EATON Ellipse ECO&lt;br /&gt;
 Bus 001 Device 005: ID 0424:7800&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a EATON Ellipse ECO UPS has been detected. We can also see the two important parameters from the ID field, with &#039;&#039;&#039;0463&#039;&#039;&#039; being the &#039;&#039;&#039;idVendor&#039;&#039;&#039; and &#039;&#039;&#039;ffff&#039;&#039;&#039; being the &#039;&#039;&#039;idProduct&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
Install the {{pkg|nut}} package:{{Cmd|# apk add nut}}&lt;br /&gt;
&lt;br /&gt;
== Configuration == &lt;br /&gt;
&lt;br /&gt;
All of the configuration files delivered with the package will be in the {{Path|/etc/nut}} subdirectory. &lt;br /&gt;
&lt;br /&gt;
The following commands rename three original configuration files. {{Cmd|&amp;lt;nowiki&amp;gt;# mv /etc/nut/nut.conf /etc/nut/nut.bak&lt;br /&gt;
# mv /etc/nut/ups.conf /etc/nut/ups.bak&lt;br /&gt;
# mv /etc/nut/upsd.conf /etc/nut/upsd.bak&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Proceed to create the three files with only the configuration parameters needed for our example USB-attached APC Smart-UPS. &lt;br /&gt;
&lt;br /&gt;
To instruct NUT to make the UPS status available on the network, create the {{Path|/etc/nut/nut.conf}} file with content as follows: {{Cat|/etc/nut/nut.conf|&amp;lt;nowiki&amp;gt;MODE=netserver&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
 &lt;br /&gt;
The content of {{Path|/etc/nut/ups.conf}} defines the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB-attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided that it is a USB-attached UPS. Create the file {{Path|/etc/nut/ups.conf}} with content as follows: {{Cat|/etc/nut/ups.conf|&amp;lt;nowiki&amp;gt;[SmartUPS_1000]&lt;br /&gt;
    driver = usbhid-ups&lt;br /&gt;
    port = auto&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
 &lt;br /&gt;
To tell NUT to make the UPS info available on all network interfaces instead of the default i.e localhost only, which is not very useful, create the {{Path|/etc/nut/upsd.conf}} file with content as follows: {{Cat|/etc/nut/upsd.conf|&amp;lt;nowiki&amp;gt;LISTEN 0.0.0.0 3493&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Tip| Replace 0.0.0.0 with the network address of a specific interface if none of the interfaces are appropriate for your situation.}}&lt;br /&gt;
&lt;br /&gt;
=== Configure udev rules ===&lt;br /&gt;
&lt;br /&gt;
To avoid [[#Insufficient permissions on everything|permission errors]], configure &#039;&#039;&#039;udev&#039;&#039;&#039; for giving NUT access to the USB-attached Smart-UPS 1000. Create the file {{Path|/etc/udev/rules.d/62-nut-usbups.rules}} as follows:{{Cat|/etc/udev/rules.d/62-nut-usbups.rules|&amp;lt;nowiki&amp;gt;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
The &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; in the first part – i.e &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039; – are unique to your UPS. They were found earlier in the [[#Determine UPS USB parameters| Determining UPS USB parameters]] section. The rest of the line tells &#039;&#039;&#039;udev&#039;&#039;&#039; what permissions and group ownership to use, and these should be the same regardless of the UPS make and model.&lt;br /&gt;
&lt;br /&gt;
Use the {{ic|udevadm}} command to tell &#039;&#039;&#039;udev&#039;&#039;&#039; to read in the changes:{{Cmd|# udevadm control --reload-rules}}&lt;br /&gt;
&lt;br /&gt;
{{Note|There is also a file {{Path|/lib/udev/rules.d/62-nut-usbups.rules}} that has information for all of the UPS models that NUT knows about. You may be able to simply copy this rather than constructing your own rules.}}&lt;br /&gt;
&lt;br /&gt;
== Service configuration ==&lt;br /&gt;
&lt;br /&gt;
The service is called {{ic|nut-upsd}} and can be managed using the standard start|stop|restart commands using standard [[OpenRC]] commands.&lt;br /&gt;
&lt;br /&gt;
{{Tip|Remember to [[#Configure udev rules|configure &#039;&#039;&#039;udev&#039;&#039;&#039; rules]] and to [[#Testing the configuration|test the configuration]] before proceeding further.}} &lt;br /&gt;
&lt;br /&gt;
Proceed to start the service as follows: {{Cmd|# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...}}&lt;br /&gt;
&lt;br /&gt;
Notice that the directory {{Path|/run/nut}} is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
[[#Verifying running state|Verify the running state]] before proceeding to configure the automatic startup of the {{ic|nut-upsd}}. If everything looks good, go ahead and set the service to auto-start when the system is booted:{{Cmd|# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default}}&lt;br /&gt;
&lt;br /&gt;
== Using NUT ==&lt;br /&gt;
&lt;br /&gt;
Now, the {{ic|upsc}} command can be run against the name added in {{Path|/etc/nut/ups.conf}} to gather all status information about your UPS. Based on the example used on this wiki page:{{Cmd|$ upsc SmartUPS_1000}}&lt;br /&gt;
One can also gather specific status information by passing them as an argument: {{Cmd|$ upsc SmartUPS_1000 battery.charge}} This is useful to monitor specific values and/or to initiate actions (e.g. from a script) when specific thresholds are reached.&lt;br /&gt;
&lt;br /&gt;
The [[#See also|See also]] section has documentation links about how to configure NUT to do useful things, such as sending an email, initiating a graceful shutdown when the main power is lost, and how to use Home Assistant to keep tabs on your UPS. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting == &lt;br /&gt;
&lt;br /&gt;
=== Testing the configuration ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure that it was detected and that the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the {{Path|/dev/bus/usb}} subdirectories. One of these represents your UPS. If the &#039;&#039;&#039;udev&#039;&#039;&#039; rules work correctly, the file should be the one with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.{{Cmd|# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003}}&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from {{ic|dmesg}} should tip you off as to which directory and file it is. Look at the line below from {{ic|dmesg}} and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of the {{Path|/dev/bus/usb/001/003}}file. {{Cat|/dev/bus/usb/001/003|usb 1-3: Manufacturer: American Power Conversion}}&lt;br /&gt;
&lt;br /&gt;
=== Verifying running state ===&lt;br /&gt;
&lt;br /&gt;
A couple of quick commands will ensure that the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Insufficient permissions on everything ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The error message above is due to the USB device having the wrong ownership and permissions. [[#Configure udev rules|Configure &#039;&#039;&#039;udev&#039;&#039;&#039; rules]] and restart the [[#Service configuration|service]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://networkupstools.org/ NUT home page] &lt;br /&gt;
* [https://networkupstools.org/stable-hcl.html list of NUT compatible models]&lt;br /&gt;
* [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant]&lt;br /&gt;
* [[Apcupsd]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Monitoring]]&lt;br /&gt;
[[Category:System Administration]]&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>Antiz</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=31083</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=31083"/>
		<updated>2025-09-28T19:00:41Z</updated>

		<summary type="html">&lt;p&gt;Antiz: Add an accuracy/out-of-date note about the &amp;quot;Todo&amp;quot; section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Accuracy|The below &amp;quot;Todo&amp;quot; tag &#039;&#039;may&#039;&#039; be inaccurate/out-of-date. I&#039;ve set up the udev rule as described in the article and no permissions (or any other) issue so far, despite a fair amount of system upgrade and reboot (on the latest stable branch).}}&lt;br /&gt;
&lt;br /&gt;
{{Todo|The udev configuration presented here does not work consistently. A recent update and/or reboot has caused the libusb &#039;&#039;insufficient permissions on everything&#039;&#039; message to reappear. Even explicitly setting group ownership and permissions does not fix the problem.}}&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/upsd.conf /etc/nut/upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will rename the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
* The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
* The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
* Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
You should now be able run the &amp;lt;code&amp;gt;upsc&amp;lt;/code&amp;gt; command against the name added in &amp;lt;code&amp;gt;/etc/nut/ups.conf&amp;lt;/code&amp;gt; to gather all status information about your UPS (e.g. with the example from this wiki page: &amp;lt;code&amp;gt;upsc SmartUPS_1000&amp;lt;/code&amp;gt;). One can also gather specific status information by passing them as an argument (e.g. &amp;lt;code&amp;gt;upsc SmartUPS_1000 battery.charge&amp;lt;/code&amp;gt;). This is useful to monitor specific values and/or initiate actions (e.g. from a script) when specific thresholds are reached.&lt;br /&gt;
&lt;br /&gt;
NUT itself can also be configured to do useful things like send an email or initiate a graceful shutdown when the main power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Antiz</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=31082</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=31082"/>
		<updated>2025-09-28T18:11:27Z</updated>

		<summary type="html">&lt;p&gt;Antiz: Mention the `upsc` command and give some usage examples&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Todo|The udev configuration presented here does not work consistently. A recent update and/or reboot has caused the libusb &#039;&#039;insufficient permissions on everything&#039;&#039; message to reappear. Even explicitly setting group ownership and permissions does not fix the problem.}}&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/upsd.conf /etc/nut/upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will rename the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
* The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
* The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
* Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
You should now be able run the &amp;lt;code&amp;gt;upsc&amp;lt;/code&amp;gt; command against the name added in &amp;lt;code&amp;gt;/etc/nut/ups.conf&amp;lt;/code&amp;gt; to gather all status information about your UPS (e.g. with the example from this wiki page: &amp;lt;code&amp;gt;upsc SmartUPS_1000&amp;lt;/code&amp;gt;). One can also gather specific status information by passing them as an argument (e.g. &amp;lt;code&amp;gt;upsc SmartUPS_1000 battery.charge&amp;lt;/code&amp;gt;). This is useful to monitor specific values and/or initiate actions (e.g. from a script) when specific thresholds are reached.&lt;br /&gt;
&lt;br /&gt;
NUT itself can also be configured to do useful things like send an email or initiate a graceful shutdown when the main power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Antiz</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=31081</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=31081"/>
		<updated>2025-09-28T18:10:58Z</updated>

		<summary type="html">&lt;p&gt;Antiz: Undo revision 31080 by Antiz (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Todo|The udev configuration presented here does not work consistently. A recent update and/or reboot has caused the libusb &#039;&#039;insufficient permissions on everything&#039;&#039; message to reappear. Even explicitly setting group ownership and permissions does not fix the problem.}}&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/upsd.conf /etc/nut/upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will rename the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
* The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
* The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
* Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do useful things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Antiz</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=31080</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=31080"/>
		<updated>2025-09-28T18:10:02Z</updated>

		<summary type="html">&lt;p&gt;Antiz: Mention the `upsc` command and give some usage examples&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
You should now be able run the &amp;lt;code&amp;gt;upsc&amp;lt;/code&amp;gt; command against the name added in &amp;lt;code&amp;gt;/etc/nut/ups.conf&amp;lt;/code&amp;gt; to gather all status information about your UPS (e.g. with the example from this wiki page: &amp;lt;code&amp;gt;upsc SmartUPS_1000&amp;lt;/code&amp;gt;). One can also gather specific status information by passing them as an argument (e.g. &amp;lt;code&amp;gt;upsc SmartUPS_1000 battery.charge&amp;lt;/code&amp;gt;). This is useful to monitor specific values and/or initiate actions (e.g. from a script) when specific thresholds are reached.&lt;br /&gt;
&lt;br /&gt;
NUT itself can also be configured to do useful things like send an email or initiate a graceful shutdown when the main power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Antiz</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=31066</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=31066"/>
		<updated>2025-09-27T19:30:52Z</updated>

		<summary type="html">&lt;p&gt;Antiz: Fixing path in command examples&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Todo|The udev configuration presented here does not work consistently. A recent update and/or reboot has caused the libusb &#039;&#039;insufficient permissions on everything&#039;&#039; message to reappear. Even explicitly setting group ownership and permissions does not fix the problem.}}&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/upsd.conf /etc/nut/upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will rename the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
* The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
* The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
* Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do useful things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Antiz</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=31065</id>
		<title>Nut-ups</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nut-ups&amp;diff=31065"/>
		<updated>2025-09-27T19:16:24Z</updated>

		<summary type="html">&lt;p&gt;Antiz: Fixing path in command examples&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Todo|The udev configuration presented here does not work consistently. A recent update and/or reboot has caused the libusb &#039;&#039;insufficient permissions on everything&#039;&#039; message to reappear. Even explicitly setting group ownership and permissions does not fix the problem.}}&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring Network UPS Tools (NUT) ==&lt;br /&gt;
&lt;br /&gt;
This wiki page shows how to install and configure the NUT package to monitor and report the statistics for a USB attached Uninterruptible Power Supply (UPS). The UPS model used in the examples is an APC SmartUPS 1000, but any UPS on the [https://networkupstools.org/stable-hcl.html list of compatible models] should work.&lt;br /&gt;
&lt;br /&gt;
The end goal is to make the UPS status available over the network so it can be monitored and used to trigger actions in a home automation system like [https://www.home-assistant.io/ Home Assistant].&lt;br /&gt;
&lt;br /&gt;
=== Determining Your UPS USB Parameters ===&lt;br /&gt;
&lt;br /&gt;
The first step is to plug in the USB cable between your UPS and your Alpine host to see how it appears to the system. Information about the UPS can be seen with the &#039;&#039;&#039;dmesg&#039;&#039;&#039; command. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# dmesg&lt;br /&gt;
 [400269.428612] usb 1-3: new low-speed USB device number 3 using xhci_hcd&lt;br /&gt;
 [400269.580728] usb 1-3: New USB device found, idVendor=051d, idProduct=0002, bcdDevice= 0.06&lt;br /&gt;
 [400269.580751] usb 1-3: New USB device strings: Mfr=3, Product=1, SerialNumber=2&lt;br /&gt;
 [400269.580759] usb 1-3: Product: Smart-UPS 1000 FW:600.3.D USB FW:1.4&lt;br /&gt;
 [400269.580765] usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
 [400269.580771] usb 1-3: SerialNumber: AS0123456789&lt;br /&gt;
 [400269.687883] usbcore: registered new interface driver usbhid&lt;br /&gt;
 [400269.687894] usbhid: USB HID core driver&lt;br /&gt;
 [400269.698356] hid-generic 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Smart-UPS 1000 FW:600.3.D USB FW:1.4] on usb-0000:00:15.0-3/input0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this output, we can see a Smart-UPS 1000 has been detected. We can also see two important parameters: &#039;&#039;idVendor=051d&#039;&#039; and &#039;&#039;idProduct=0002&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These will be used later in the udev rules, so keep them handy.&lt;br /&gt;
&lt;br /&gt;
=== Installing and Configuring NUT ===&lt;br /&gt;
&lt;br /&gt;
The first step is to add the alpine package. After that, we&#039;ll rename three default configuration files and replace them with the parameters needed for our example USB attached APC Smart-UPS.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# apk update &amp;amp;&amp;amp; apk add nut&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/nut.conf /etc/nut/nut.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/nut.conf&lt;br /&gt;
 MODE=netserver&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/ups.conf /etc/nut/ups.conf~&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;/etc/nut/ups.conf&lt;br /&gt;
 [SmartUPS_1000]&lt;br /&gt;
     driver = usbhid-ups&lt;br /&gt;
     port = auto&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# mv /etc/nut/upsd.conf /etc/nut/upsd.conf~&lt;br /&gt;
 alpine:/# cat &amp;lt;&amp;lt;EOF &amp;gt;upsd.conf&lt;br /&gt;
 LISTEN 0.0.0.0 3493&lt;br /&gt;
 EOF&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first command should be familiar. It updates the Alpine package manager database and installs the nut package. All of the configuration files delivered with the package will be in the &#039;&#039;&#039;/etc/nut&#039;&#039;&#039; subdirectory.&lt;br /&gt;
&lt;br /&gt;
The next several commands will rename the original configuration file and then write a new file with only the configuration parameters needed.&lt;br /&gt;
&lt;br /&gt;
* The line written to &#039;&#039;&#039;nut.conf&#039;&#039;&#039; instructs NUT to make the UPS status available on the network.&lt;br /&gt;
&lt;br /&gt;
* The lines in &#039;&#039;&#039;ups.conf&#039;&#039;&#039; define the name (in square brackets), the driver used to communicate with the UPS, and the port. For USB attached UPSs, it&#039;s almost always going to be a driver of &#039;&#039;usbhid-ups&#039;&#039; and a port of &#039;&#039;auto&#039;&#039;. Make and model should not make any difference here provided it is a USB attached UPS.&lt;br /&gt;
&lt;br /&gt;
* Finally, the line in &#039;&#039;&#039;upsd.conf&#039;&#039;&#039; is there to tell NUT it should make the UPS info available on all network interfaces. The default is localhost only, which is not very useful. You can replace 0.0.0.0 with the network address of a specific interface if all interfaces is not appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
=== Configuring udev Rules ===&lt;br /&gt;
&lt;br /&gt;
If you tried starting the &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; service at this point, it would complain loudly about permissions. See the example below.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 libusb1: Could not open any HID devices: insufficient permissions on everything&lt;br /&gt;
 No matching HID UPS found&lt;br /&gt;
 upsnotify: failed to notify about state 4: no notification tech defined, will not spam more about it&lt;br /&gt;
 Driver failed to start (exit status=1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is due to the USB device having the wrong ownership and permissions.&lt;br /&gt;
&lt;br /&gt;
Below is an example of how to configure udev for giving NUT access to the USB attached Smart-UPS 1000.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
 alpine:/# cd /etc/udev/rules.d&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt;62-nut-usbups.rules&lt;br /&gt;
 ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;, MODE=&amp;quot;664&amp;quot;, GROUP=&amp;quot;nut&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 alpine:/# udevadm control --reload-rules&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Take a look at the line that starts with &#039;&#039;ATTR{idVendor}==&amp;quot;051d&amp;quot;, ATTR{idProduct}==&amp;quot;0002&amp;quot;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
These are the vendor and product IDs found in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output above. The rest of the line tells udev what permissions and group ownership to use. It should be the same regardless of the UPS make and model, but the &#039;&#039;idVendor&#039;&#039; and &#039;&#039;idProduct&#039;&#039; will be unique to your UPS.&lt;br /&gt;
&lt;br /&gt;
{{ note|There is also a file &#039;&#039;&#039;/lib/udev/rules.d/62-nut-usbups.rules&#039;&#039;&#039; that has information for all of the UPS models NUT knows about. You may be able to simply copy this rather than constructing your own rules from the information in the &#039;&#039;&#039;dmesg&#039;&#039;&#039; output. }}&lt;br /&gt;
&lt;br /&gt;
Finally, the &#039;&#039;&#039;udevadm control&#039;&#039;&#039; command tells udev to read in the changes.&lt;br /&gt;
&lt;br /&gt;
=== Testing the Configuration Thus Far ===&lt;br /&gt;
&lt;br /&gt;
Unplug the UPS USB cable from the host, wait a moment, and then reinsert it. Check &#039;&#039;&#039;dmesg&#039;&#039;&#039; again to make sure it was detected and the idVendor and idProduct are correct.&lt;br /&gt;
&lt;br /&gt;
Check the permissions on the files in the &#039;&#039;&#039;/dev/bus/usb&#039;&#039;&#039; subdirectories. One of these represents your UPS. If the udev rules work correctly, it should be the file with a group owner of &#039;&#039;nut&#039;&#039; and permissions of 0664. An example is shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# ls -l /dev/bus/usb/001/003&lt;br /&gt;
 crw-rw-r-- 1 root nut 189, 2 Oct 10 00:53 /dev/bus/usb/001/003&lt;br /&gt;
&lt;br /&gt;
Your directory and file names may be different, but at least one of the files should have the group ownership and permissions as shown in the example.&lt;br /&gt;
&lt;br /&gt;
The output from &#039;&#039;&#039;dmesg&#039;&#039;&#039; should tip you off as to which directory and file it is. Look at the line below from &#039;&#039;&#039;dmesg&#039;&#039;&#039; and compare the &#039;&#039;usb 1-3&#039;&#039; to the directory entry of &#039;&#039;/dev/bus/usb/001/003&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 usb 1-3: Manufacturer: American Power Conversion&lt;br /&gt;
&lt;br /&gt;
=== Starting NUT ===&lt;br /&gt;
&lt;br /&gt;
The service is called &#039;&#039;&#039;nut-upsd&#039;&#039;&#039; and can be started as shown below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd start&lt;br /&gt;
  * /run/nut: creating directory&lt;br /&gt;
  * /run/nut: correcting owner&lt;br /&gt;
 Using subdriver: APC HID 0.100&lt;br /&gt;
  * Starting UPS Server ...&lt;br /&gt;
&lt;br /&gt;
Notice that the directory &#039;&#039;&#039;/run/nut&#039;&#039;&#039; is created automatically the first time.&lt;br /&gt;
&lt;br /&gt;
=== Verifying Running State ===&lt;br /&gt;
&lt;br /&gt;
A couple quick commands will ensure the NUT service is actually running as expected. These are shown in the example below.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-service nut-upsd status&lt;br /&gt;
 * status: started&lt;br /&gt;
 alpine:/# netstat -tln | grep 3493&lt;br /&gt;
 tcp        0      0 0.0.0.0:3493            0.0.0.0:*               LISTEN&lt;br /&gt;
&lt;br /&gt;
This shows the service running and making the UPS status available on all network interfaces (0.0.0.0) over the default TCP port for NUT (3493).&lt;br /&gt;
&lt;br /&gt;
=== Configuring Automatic Startup ===&lt;br /&gt;
&lt;br /&gt;
If everything looks good, go ahead and set the service to auto-start when the system is booted.&lt;br /&gt;
&lt;br /&gt;
 alpine:/# rc-update add nut-upsd&lt;br /&gt;
  * service nut-upsd added to runlevel default&lt;br /&gt;
&lt;br /&gt;
=== Next Steps ===&lt;br /&gt;
&lt;br /&gt;
NUT can be configured to do useful things like send an email or initiate a graceful shutdown when the mains power is lost. The [https://networkupstools.org/ NUT home page] is your source for documentation on how to do this.&lt;br /&gt;
&lt;br /&gt;
There is also a [https://www.home-assistant.io/integrations/nut/ NUT integration for Home Assistant] that can be installed to keep tabs on your UPS.&lt;/div&gt;</summary>
		<author><name>Antiz</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Include:Setup_your_system_and_account_for_building_packages&amp;diff=27558</id>
		<title>Include:Setup your system and account for building packages</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Include:Setup_your_system_and_account_for_building_packages&amp;diff=27558"/>
		<updated>2024-10-14T15:07:00Z</updated>

		<summary type="html">&lt;p&gt;Antiz: Remove outdated instructions for security keys generation: Manually copying keys to /etc/apk/keys is not necessary anymore as it&amp;#039;s now done by the `abuild-keygen -a -i` already&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The {{Pkg|alpine-sdk}} is a metapackage that pulls in the most essential packages used to build new packages. Also install and configure a way to elevate privileges, such as sudo or doas, and an editor, such as vi, nano, micro.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add alpine-sdk}}&lt;br /&gt;
&lt;br /&gt;
This would be a good time to [[Setting_up_a_new_user|create a normal user account for you to work in]]. To make life easier later, it&#039;s a good idea to add this user to the wheel group; operations that require superuser privileges can now be done with sudo or doas.&lt;br /&gt;
&lt;br /&gt;
The [[Aports_tree|aports tree]] is in git so before we clone it, let&#039;s configure git.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ git config --global user.name &amp;quot;Your Full Name&amp;quot;&lt;br /&gt;
$ git config --global user.email &amp;quot;your@email.address&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
Read carefully [[Development using git]] to grasp basic Git operations and how to configure for sending email patches.&lt;br /&gt;
&lt;br /&gt;
Now we can clone the [[Aports_tree|aports tree]]. &lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ git clone https://gitlab.alpinelinux.org/alpine/aports}}&lt;br /&gt;
&lt;br /&gt;
Before we start creating or modifying [[APKBUILD_Reference|APKBUILD]] files, we need to setup abuild for our system and user. Edit the file {{Path|/etc/abuild.conf}} to your requirements.&lt;br /&gt;
&lt;br /&gt;
Most of the defaults can be left alone, unless you are developing for a custom platform, in which case the comments in the file should guide you. The one field to edit is PACKAGER, so that you can get credit (or blame) for packages you create.&lt;br /&gt;
&lt;br /&gt;
To use &#039;abuild -r&#039; command to install dependency packages automatically (and other &#039;abuild&#039; commands that require it).&lt;br /&gt;
{{Cmd|# addgroup &amp;lt;yourusername&amp;gt; abuild}}&lt;br /&gt;
&lt;br /&gt;
{{Note|Remember to logout and login again for the group change to have effect.}}&lt;br /&gt;
&lt;br /&gt;
The last step is to configure the security keys with the [[Abuild-keygen|abuild-keygen]] script for [[Abuild and Helpers|abuild]] with the command:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# abuild-keygen -a -i}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Antiz</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Include:Setup_your_system_and_account_for_building_packages&amp;diff=27546</id>
		<title>Include:Setup your system and account for building packages</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Include:Setup_your_system_and_account_for_building_packages&amp;diff=27546"/>
		<updated>2024-10-14T06:58:11Z</updated>

		<summary type="html">&lt;p&gt;Antiz: Remove outdated / debatable instructions to setup the cache dir: /var/cache/distfiles is created by the &amp;quot;abuild&amp;quot; package and it already belongs to root:abuild with a 775 mode. Ensuring it exists with `mkdir -p` is not so useful and setting `chmod a+w` permissions to it (basically turning it into 777) is, at the very least, highly debatable security wise. The second approach implies changing the group to &amp;quot;abuild&amp;quot; and giving it write permissions, which is useless as it&amp;#039;s already the default.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The {{Pkg|alpine-sdk}} is a metapackage that pulls in the most essential packages used to build new packages. Also install and configure a way to elevate privileges, such as sudo or doas, and an editor, such as vi, nano, micro.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add alpine-sdk}}&lt;br /&gt;
&lt;br /&gt;
This would be a good time to [[Setting_up_a_new_user|create a normal user account for you to work in]]. To make life easier later, it&#039;s a good idea to add this user to the wheel group; operations that require superuser privileges can now be done with sudo or doas.&lt;br /&gt;
&lt;br /&gt;
The [[Aports_tree|aports tree]] is in git so before we clone it, let&#039;s configure git.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ git config --global user.name &amp;quot;Your Full Name&amp;quot;&lt;br /&gt;
$ git config --global user.email &amp;quot;your@email.address&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
Read carefully [[Development using git]] to grasp basic Git operations and how to configure for sending email patches.&lt;br /&gt;
&lt;br /&gt;
Now we can clone the [[Aports_tree|aports tree]]. &lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ git clone https://gitlab.alpinelinux.org/alpine/aports}}&lt;br /&gt;
&lt;br /&gt;
Before we start creating or modifying [[APKBUILD_Reference|APKBUILD]] files, we need to setup abuild for our system and user. Edit the file {{Path|/etc/abuild.conf}} to your requirements.&lt;br /&gt;
&lt;br /&gt;
Most of the defaults can be left alone, unless you are developing for a custom platform, in which case the comments in the file should guide you. The one field to edit is PACKAGER, so that you can get credit (or blame) for packages you create.&lt;br /&gt;
&lt;br /&gt;
To use &#039;abuild -r&#039; command to install dependency packages automatically (and other &#039;abuild&#039; commands that require it).&lt;br /&gt;
{{Cmd|# addgroup &amp;lt;yourusername&amp;gt; abuild}}&lt;br /&gt;
&lt;br /&gt;
{{Note|Remember to logout and login again for the group change to have effect.}}&lt;br /&gt;
&lt;br /&gt;
The last step is to configure the security keys with the [[Abuild-keygen|abuild-keygen]] script for [[Abuild and Helpers|abuild]] with the command:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# abuild-keygen -a -i}}&lt;br /&gt;
&lt;br /&gt;
If you want to share the generated keys between multiple computers ({{Path|~/.abuild}}), you will have to manually copy the generated public key into {{Path|/etc/apk/keys}} for the signing process of generated packages to work, example:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# cp /home/user/.abuild/user@domain.tld-12345abc.rsa.pub /etc/apk/keys}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Antiz</name></author>
	</entry>
</feed>