[Nut-upsdev] AEG - PROTECT HOME support using NUT with serial protocol
Arnaud Quette
aquette.dev at gmail.com
Sat Mar 31 17:52:10 UTC 2012
2012/3/31 Joachim Schiele <js at lastlog.de>
> On 03/30/2012 01:34 PM, Arnaud Quette wrote:
>
>
>
> 2012/3/29 Joachim Schiele <js at lastlog.de>
>
>> On 03/29/2012 04:24 PM, Arnaud Quette wrote:
>>
>>
>> 2012/3/29 Joachim Schiele <js at lastlog.de>
>>
>>> hi,
>>>
>>> i own a aeg protect home (think it is a 600 VA) which has a serial and
>>> an usb port.
>>>
>>> using this hack in ups.conf:
>>> [bestupsname]
>>> driver = bestups
>>> port = /dev/ttyUSB0
>>> ID = FOR,750,230,230,11.0,13.5
>>> desc = "home-server"
>>>
>>> i start the driver with:
>>> ./bestups -a bestupsname -D -q
>>>
>>
>> the bestups driver is indeed part of the large "Q1 protocol" family:
>>
>> https://alioth.debian.org/pm/task.php?func=detailtask&project_task_id=493&group_id=30602&group_project_id=318
>>
>>
>>> and after adding some debugging it seems to work (not yet in
>>> production). i first started by looking at the protocol and it is very very
>>> similar to www.networkupstols.org/ups-protocols/megatec.html at least
>>> protocol wise.
>>>
>>
>> so the way to go is blazer_ser or blazer_usb
>>
>>
>>> but i have a few problems
>>>
>>> ==== problem 1 ====
>>> using FOR is wrong as it then reports as a different device than it
>>> actually is. should i add a new device string, say APH?
>>>
>>> ==== problem 2 ====
>>> i would like to use the usb protocol but i don't know where to start.
>>>
>>> lsusb
>>> Bus 003 Device 003: ID 0665:5161 Cypress Semiconductor USB to Serial
>>>
>>
>> confirming blazer_usb support
>>
>>
>> both blazer_ser and blazer_usb seem to work although i had some problems
>> as i forgot to run, the command below, with the -u root parameter. and
>> because i forgot that i searched the wrong thing for quite a while (udev
>> rules):
>>
>> ./blazer_usb -a blazer_usb -DDD -q
>> 0.001342 Trying to match device
>> 0.001348 Device matches
>> 0.001356 failed to claim USB device: could not claim interface 0:
>> Operation not permitted
>> 0.001363 failed to detach kernel driver from USB device: could not
>> detach kernel driver from interface 0: Operation not permitted
>> 0.001370 failed to claim USB device: could not claim interface 0:
>> Operation not permitted
>> 0.001377 failed to detach kernel driver from USB device: could not
>> detach kernel driver from interface 0: Operation not permitted
>> 0.001383 failed to claim USB device: could not claim interface 0:
>> Operation not permitted
>> 0.001389 failed to detach kernel driver from USB device: could not
>> detach kernel driver from interface 0: Operation not permitted
>> 0.001396 failed to claim USB device: could not claim interface 0:
>> Operation not permitted
>> 0.001402 failed to detach kernel driver from USB device: could not
>> detach kernel driver from interface 0: Operation not permitted
>> 0.001408 Can't claim USB device [0665:5161]: could not detach
>> kernel driver from interface 0: Operation not permitted
>>
>> but then with -u root it worked:
>>
>> ./blazer_usb -a blazer_usb -u root -DDD -q
>> ...
>> 0.067478 Trying to match device
>> 0.067484 Device matches
>> 0.073450 Trying megatec protocol...
>> 0.077431 send: Q1
>> 0.432493 read: (237.2 237.2 233.6 004 49.9 13.5 25.0 00001001
>> 0.432574 Status read in 1 tries
>> 0.432581 Supported UPS detected with megatec protocol
>> 0.436440 send: F
>> 0.624780 read: #230.0 002 12.00 50.0
>> 0.624819 Ratings read in 1 tries
>> 0.628442 send: I
>>
>> thanks very much! i wonder if the UPS works with 'just' that!
>>
>
> to be complete enough, still in testing mode:
> - start both the driver and upsd with "-u root"
>
> here i have some output:
> https://nixos.org/wiki/How_to_setup_UPS/NUT
>
a note for this: you should omit the LISTEN line in upsd.conf.
the default is to listen to both IPv4 and v6 local adresses (ie 127.0.0.1
and ::1).
that makes it smoother for using localhost everywhere
for the root user, check existing packages.
you'll see that you just need to:
- compile with "--with-user=nut --with-group=nut"
- "chgrp nut" on /etc/nut and /var/lib/nut/
- modify your udev rule
ATTRS{idVendor}=="0665", ATTRS{idProduct}=="5161", MODE="664", GROUP="nut",
SYMLINK+="hidraw_protecthome"
> - send back a more complete driver output (Ie, the answer to "I" is
> missing above)
>
> 0.000000 debug level is '3'
> 0.000614 Checking device (1D6B/0002) (008/001)
> 0.000652 - VendorID: 1d6b
> 0.000661 - ProductID: 0002
> 0.000667 - Manufacturer: Linux 2.6.35.14 ehci_hcd
> 0.000674 - Product: EHCI Host Controller
> 0.000681 - Serial Number: 0000:00:1d.7
> 0.000688 - Bus: 008
> 0.000694 Trying to match device
> 0.000704 Device does not match - skipping
> 0.000714 Checking device (046D/C00C) (006/004)
> 0.022891 - VendorID: 046d
> 0.022923 - ProductID: c00c
> 0.022930 - Manufacturer: Logitech
> 0.022937 - Product: USB Mouse
> 0.022943 - Serial Number: unknown
> 0.022950 - Bus: 006
> 0.022956 Trying to match device
> 0.022965 Device does not match - skipping
> 0.022979 Checking device (04B3/3003) (006/003)
> 0.030881 - VendorID: 04b3
> 0.030894 - ProductID: 3003
> 0.030900 - Manufacturer: Silitek
> 0.030907 - Product: IBM USB HUB KEYBOARD
> 0.030913 - Serial Number: unknown
> 0.030920 - Bus: 006
> 0.030926 Trying to match device
> 0.030933 Device does not match - skipping
> 0.030943 Checking device (04B3/3004) (006/002)
> 0.038880 - VendorID: 04b3
> 0.038893 - ProductID: 3004
> 0.038900 - Manufacturer: Silitek
> 0.038906 - Product: IBM USB HUB KEYBOARD
> 0.038913 - Serial Number: unknown
> 0.038919 - Bus: 006
> 0.038926 Trying to match device
> 0.038933 Device does not match - skipping
> 0.038944 Checking device (1D6B/0001) (006/001)
> 0.038973 - VendorID: 1d6b
> 0.038981 - ProductID: 0001
> 0.038987 - Manufacturer: Linux 2.6.35.14 uhci_hcd
> 0.038994 - Product: UHCI Host Controller
> 0.039001 - Serial Number: 0000:00:1d.2
> 0.039007 - Bus: 006
> 0.039014 Trying to match device
> 0.039021 Device does not match - skipping
> 0.039030 Checking device (1D6B/0001) (005/001)
> 0.039054 - VendorID: 1d6b
> 0.039062 - ProductID: 0001
> 0.039068 - Manufacturer: Linux 2.6.35.14 uhci_hcd
> 0.039075 - Product: UHCI Host Controller
> 0.039081 - Serial Number: 0000:00:1d.1
> 0.039088 - Bus: 005
> 0.039094 Trying to match device
> 0.039101 Device does not match - skipping
> 0.039110 Checking device (1D6B/0001) (004/001)
> 0.039134 - VendorID: 1d6b
> 0.039141 - ProductID: 0001
> 0.039148 - Manufacturer: Linux 2.6.35.14 uhci_hcd
> 0.039154 - Product: UHCI Host Controller
> 0.039161 - Serial Number: 0000:00:1d.0
> 0.039167 - Bus: 004
> 0.039174 Trying to match device
> 0.039181 Device does not match - skipping
> 0.039190 Checking device (0665/5161) (003/002)
> 0.066589 - VendorID: 0665
> 0.066603 - ProductID: 5161
> 0.066609 - Manufacturer: Cypress Semiconductor
> 0.066616 - Product: USB to Serial
> 0.066623 - Serial Number: unknown
> 0.066629 - Bus: 003
> 0.066636 Trying to match device
> 0.066643 Device matches
> 0.072607 Trying megatec protocol...
> 0.076590 send: Q1
> 0.418407 read: (241.5 241.4 237.5 003 49.9 13.6 25.0 00001001
> 0.418495 Status read in 1 tries
> 0.418504 Supported UPS detected with megatec protocol
> 0.421595 send: F
> 0.610122 read: #230.0 002 12.00 50.0
> 0.610149 Ratings read in 1 tries
> 0.613598 send: I
> 1.615630 read: No error
> 1.615664 blazer_vendor: short reply
> 1.615672 Vendor information read 1 failed
> 1.619619 send: I
> 2.621647 read: No error
> 2.621682 blazer_vendor: short reply
> 2.621690 Vendor information read 2 failed
> 2.625638 send: I
> 3.627663 read: No error
> 3.627683 blazer_vendor: short reply
> 3.627690 Vendor information read 3 failed
> 3.627697 Vendor information unavailable
> 3.627705 Battery runtime will not be calculated (runtimecal not
> set)
>
FYI, this is fixed for 2.6.4, and provide a good battery.runtime value
> 3.631657 send: Q1
> 4.002439 read: (241.4 241.4 237.5 004 49.9 13.5 25.0 00001001
> 4.002555 dstate_init: sock /var/state/ups/blazer_usb-blazer_usb
> open on fd 5
> 4.005665 send: Q1
> 4.354017 read: (241.5 241.4 237.5 004 49.9 13.6 25.0 00001001
> 6.007705 send: Q1
> 6.370726 read: (241.5 241.4 237.5 003 49.9 13.6 25.0 00001001
> 8.009741 send: Q1
> 8.354691 read: (241.4 241.4 237.5 003 49.9 13.6 25.0 00001001
> 10.010782 send: Q1
> 10.370673 read: (241.5 241.4 237.5 004 49.9 13.6 25.0 00001001
> 12.012818 send: Q1
> 12.354572 read: (241.4 241.4 237.5 004 49.9 13.6 25.0 00001001
> 14.014859 send: Q1
> 14.370553 read: (241.4 241.4 237.5 003 49.9 13.6 25.0 00001001
> 14.974405 Signal 2: exiting
>
> - send back outputs from upsc / upsrw / upscmd
>
>
> # upsc ProtectHome at localhost
> battery.voltage: 13.60
> battery.voltage.nominal: 12.0
> beeper.status: enabled
> device.type: ups
> driver.name: blazer_usb
> driver.parameter.pollinterval: 2
> driver.parameter.port: /dev/hidraw_protecthome
> driver.version: 2.6.1
> driver.version.internal: 0.03
> input.current.nominal: 2.0
> input.frequency: 49.9
> input.frequency.nominal: 50
> input.voltage: 241.4
> input.voltage.fault: 241.4
> input.voltage.nominal: 230
> output.voltage: 237.5
> ups.delay.shutdown: 30
> ups.delay.start: 180
> ups.load: 4
> ups.productid: 5161
> ups.status: OL
> ups.temperature: 25.0
> ups.type: offline / line interactive
> ups.vendorid: 0665
>
> don't know what to test with upsrw or upscmd
>
> upsrw -u master -s beeper.status=on ProtectHome at localhost
> Unexpected response from upsd: ERR ACCESS-DENIED
>
just do:
$ upsrw ProtectHome
$ upscmd -l ProtectHome
to be able to use these command, as you did above, you'll have to create an
administrative user.
refer to upsd.users manpage for more info:
http://www.networkupstools.org/docs/man/upsd.users.html
> - test the shutdown using (requires upsmon to be started too, as root):
>
> http://www.networkupstools.org/docs/user-manual.chunked/ar01s06.html#UPS_shutdown
>
> as configured the system was shut down within 25seconds after UPS was
> disconnected from power, see also:
>
> https://nixos.org/wiki/How_to_setup_UPS/NUT#example_log.2C_when_unplugging_the_UPS_from_power
>
> the driver seems to work here as this is exactly what i wanted. when
> battery takes over, shutdown the system after 25seconds. this leaves enough
> time to replug the power wires if needed but ensured that the system goes
> down as soon as possible.
>
>
>
> I'm holding the commit of a new hardware compat list entry until you send
> these back
>
> yeah, thanks for that!
>
I've just commited it in trunk (r3516):
http://trac.networkupstools.org/projects/nut/changeset/3516
cheers,
Arnaud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/nut-upsdev/attachments/20120331/3cba8a8f/attachment-0001.html>
More information about the Nut-upsdev
mailing list