# udev and/or sys-power/nut issue with /dev/usb/hiddev0

## dstutz97

I have nut installed and working ok.  The problem is every time I reboot my server udev doesn't apply the nut rules (/etc/udev/rules.d/70-nut-usbups.rules) properly and the ups driver can't start.  I get the following error:

```
# /etc/init.d/upsdrv start

 * Starting UPS drivers ...

Network UPS Tools - UPS driver controller 2.0.5

Network UPS Tools: HID UPS driver 0.13 (2.0.5)

Warning: This is an experimental driver.

Some features may not function correctly.

hiddev path open /dev/usb/hiddev0: Permission denied

Driver failed to start (exit status=1)

 * Failed to start UPS drivers!             
```

I do the following to fix it and then the driver starts up ok:

```
# chgrp nut /dev/usb/hiddev0

# /etc/init.d/upsdrv start

 * Starting UPS drivers ...

Network UPS Tools - UPS driver controller 2.0.5

Network UPS Tools: HID UPS driver 0.13 (2.0.5)

Warning: This is an experimental driver.

Some features may not function correctly.

Detected American Power Conversion Back-UPS RS 1500 FW:8.g9 .D USB FW:g9

on port /dev/usb/hiddev0
```

I've read through Daniel Drake's udev rules guide and tried some of the things he's said in there and I get strange output:

```
# udevinfo -a -p /dev/usb/hiddev0

no valid sysfs device found

# udevtest /dev/usb/hiddev0

This program is for debugging only, it does not run any program,

specified by a RUN key. It may show incorrect results, because

some values may be different, or not available at a simulation run.

parse_file: reading '/etc/udev/rules.d/05-udev-early.rules' as rules file

parse_file: reading '/dev/.udev/rules.d/10-root-link.rules' as rules file

parse_file: reading '/etc/udev/rules.d/30-kernel-compat.rules' as rules file

parse_file: reading '/etc/udev/rules.d/50-udev.rules' as rules file

parse_file: reading '/etc/udev/rules.d/60-persistent-input.rules' as rules file

parse_file: reading '/etc/udev/rules.d/60-persistent-storage.rules' as rules file

parse_file: reading '/etc/udev/rules.d/61-persistent-storage-edd.rules' as rules file

parse_file: reading '/etc/udev/rules.d/64-device-mapper.rules' as rules file

parse_file: reading '/etc/udev/rules.d/70-nut-usbups.rules' as rules file

parse_file: reading '/etc/udev/rules.d/70-persistent-cd.rules' as rules file

parse_file: reading '/etc/udev/rules.d/70-persistent-net.rules' as rules file

parse_file: reading '/etc/udev/rules.d/75-cd-aliases-generator.rules' as rules file

parse_file: reading '/etc/udev/rules.d/75-persistent-net-generator.rules' as rules file

parse_file: reading '/etc/udev/rules.d/80-drivers.rules' as rules file

parse_file: reading '/etc/udev/rules.d/90-network.rules' as rules file

parse_file: reading '/etc/udev/rules.d/95-udev-late.rules' as rules file

unable to open device '/dev/usb/hiddev0'
```

lsusb shows:

```
Bus 001 Device 001: ID 0000:0000

Bus 002 Device 002: ID 051d:0002 American Power Conversion Back-UPS Pro 500/1000/1500

Bus 002 Device 001: ID 0000:0000
```

This appears to be the folder in sysfs:

```
# cat /sys/bus/usb/devices/usb2/2-4/product

Back-UPS RS 1500 FW:8.g9 .D USB FW:g9
```

Sooooo....any ideas?  I know of some hacks to get around the problem, but I'm curious why the udev rules that get installed with the package are being ignored.

----------

## kimmie

Here's my 70-nut-usb-rules:

```
# udev rules for the NUT USB drivers

# -- Gid was here ---

# Why is this in SUBSYSTEM=usb whereas all the others are in "usb_device"? Dunno.

# Could be a bug in the rest of the rules

# Liebert Powersure PSI 1440 - hidusb

SUBSYSTEM=="usb", ACTION=="add", SYSFS{idVendor}=="10af", SYSFS{idProduct}=="0004", MODE="660", GROUP="nut"

# -------------------

SUBSYSTEM!="usb_device", GOTO="nut-usbups_rules_end"

ACTION!="add", GOTO="nut-usbups_rules_end"

# MGE UPS SYSTEMS - usbhid-ups

SYSFS{idVendor}=="0463", SYSFS{idProduct}=="ffff", MODE="664", GROUP="nut"

SYSFS{idVendor}=="0463", SYSFS{idProduct}=="0001", MODE="664", GROUP="nut"

# APC - usbhid-ups

SYSFS{idVendor}=="051d", SYSFS{idProduct}=="0002", MODE="664", GROUP="nut"

# CyberPower - usbhid-ups

SYSFS{idVendor}=="0764", SYSFS{idProduct}=="0005", MODE="664", GROUP="nut"

SYSFS{idVendor}=="0764", SYSFS{idProduct}=="0501", MODE="664", GROUP="nut"

# Powercom - usbhid-ups

SYSFS{idVendor}=="0d9f", SYSFS{idProduct}=="0001", MODE="664", GROUP="nut"

# Powerware - bcmxcp_usb

SYSFS{idVendor}=="0592", SYSFS{idProduct}=="0002", MODE="664", GROUP="nut"

# Tripp Lite - tripplite_usb

SYSFS{idVendor}=="09ae", SYSFS{idProduct}=="0001", MODE="664", GROUP="nut"

# Tripp Lite - usbhid-ups

SYSFS{idVendor}=="09ae", SYSFS{idProduct}=="2005", MODE="664", GROUP="nut"

SYSFS{idVendor}=="09ae", SYSFS{idProduct}=="1003", MODE="664", GROUP="nut"

# Belkin - usbhid-ups

SYSFS{idVendor}=="050d", SYSFS{idProduct}=="0980", MODE="664", GROUP="nut"

SYSFS{idVendor}=="050d", SYSFS{idProduct}=="0900", MODE="664", GROUP="nut"

SYSFS{idVendor}=="050d", SYSFS{idProduct}=="0912", MODE="664", GROUP="nut"

SYSFS{idVendor}=="050d", SYSFS{idProduct}=="0551", MODE="664", GROUP="nut"

SYSFS{idVendor}=="050d", SYSFS{idProduct}=="0751", MODE="664", GROUP="nut"

# Kebo - unsupported

SYSFS{idVendor}=="0925", SYSFS{idProduct}=="1234", MODE="664", GROUP="nut"

LABEL="nut-usbups_rules_end"
```

The changes at the top are what works for me. I think it's worth filing a bug if this solution works for you too. And I'm not sure why the comments in the file refer to usbhid-ups... there's no such driver.

----------

## dstutz97

Well, that appeared to fix it.  I made the change and rebooted and now it starts right up.  I added the following line to the top of the nut udev rules file:

```
SUBSYSTEM=="usb", ACTION=="add", SYSFS{idVendor}=="051d", SYSFS{idProduct}=="0002", MODE="664", GROUP="nut"
```

I wonder if changes in the kernel moved where the device shows up in sysfs but the rules haven't been updated to follow.

EDIT: Bug filed

----------

