Bug 197627

Summary: Powerdevil should support UPS as batteries on desktop PCs
Product: [Frameworks and Libraries] solid Reporter: Marco Poletti <poletti.marco>
Component: powermanagement-kcmAssignee: Dario Freddi <drf>
Status: RESOLVED FIXED    
Severity: wishlist CC: bcooksley, debfx-kde, Freiheits, funtoos, id87, legolegs, mmodem00, sebas, smirnoffjr, t.kijas, zarko.pintar
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Unspecified   
Latest Commit: Version Fixed In:

Description Marco Poletti 2009-06-23 18:26:28 UTC
Version:            (using KDE 4.2.4)
Installed from:    SuSE RPMs

Current UPS handling software is not user friendly (nut) or not usable (knutclient). I think Powerdevil is the ideal place to handle UPS' configuration/monitoring with a good UI. Most of the settings of a battery-powered laptop can be applied to a UPS-powered desktop (notifications, shutdown/suspend on critical charge, command execution, ecc.).
Comment 1 Marco Poletti 2009-06-23 18:28:13 UTC
I forgot: the most difficult change would be adding/configuring new UPSes (or maybe this can be done automatically).
Comment 2 Artyom Smirnov 2009-09-30 18:59:21 UTC
*** This bug has been confirmed by popular vote. ***
Comment 3 devsk 2010-02-18 06:26:28 UTC
Why is this bug not a higher priority? powerdevil definitely needs to find the UPS and manage it as a battery just like gnome-power-manager does. Right now, I don't have a way (mind you, kde way) to manage events for my UPS. Power goes, my desktop doesn't do anything.
Comment 4 Marco Poletti 2010-02-18 06:56:34 UTC
Well, if you aren't scared by editing text files as root, you can install NUT and configure it for your UPS (editing files in /etc/ups/). You need to specify the correct driver yourself, so you'll need some trial and error.
Once you have NUT up, you PC shuts down when power is down and battery goes <30% or so.
You can monitor the UPS with knutclient (an old KDE3 app, unable to configure the UPS).

It isn't impossible to do, but it should be way more easy (as GNOME does), it could be all automatic.
Comment 5 devsk 2010-02-18 07:17:23 UTC
But this is basic desktop functionality. Every good DE worth its salt should be doing this before the eye candy that we have gotten used and spent so much resources on in KDE4. I mean if power goes, a good desktop should notify its user, shutdown or hibernate the machine so that nothing gets lost. GNOME does it. Even Windows does it! How shameful is that?

I had nut configured and running knutclient when I was using KDE 3.5, and things worked very well. And then I moved to powerdevil with KDE4. And it worked for a while. It would find 2 batteries. One for my mouse, and second for my UPS. It would do everything that gnome-power-manager did. Somewhere along the line came 4.2, and this broke. I could get it to work sometimes by forcing redetection of the USB devices by removing ehci_hcd and uhci_hcd modules and modprobing them again. But that stopped working with 4.2.4 or may be 4.3, don't remember.

I think its a bug somewhere. Something changed in the code which broke it. Don't know which part changed. Only the dev who changed the code will know.

I can Autostart gnome-power-manager and it sits nicely in the system-tray and works well! But that's one gnome package pulling in tonnes of gnome packages just to get this basic functionality!
Comment 6 Dario Freddi 2010-02-18 14:45:25 UTC
I'll just go straight to the point: I don't have an UPS, and I don't know how to handle it. If I had one, I could implement this, but since I don't, I really don't want to introduce a feature (and consequent bugs) I can't test personally.

It's a forced decision on my side - just to clear the point, it's like me developing software for Mac OS without having a Mac to test it. I really can't rely on user feedback only, as it is really asking for trouble and broken software. So unless somebody with an UPS stands up and implement this, or somebody likes to donate me an UPS, this won't happen, at least from my side.

About your issue from 4.2 on, now powerdevil detects only primary batteries as valid ones. So probably implementing UPS, if things worked like you said, is probably a very easy task and could be a good JJ for a newcomer with an UPS on his side to test.

Although, the original bug which Marco filed is also about configuring and managing an UPS, for which the same thing I said above applies.

P.S.: By the way, UPSs are NOT a basic desktop functionality. And keep saying "shameful" "oh god kde is fail because it does not support ups", more than being ridicolous, does not help your cause.
Comment 7 devsk 2010-02-19 06:07:24 UTC
Dario, Are you the original author of powerdevil?
Comment 8 devsk 2010-02-19 06:19:39 UTC
(In reply to comment #7)
> Dario, Are you the original author of powerdevil?

ok, scratch that! Sorry!
Comment 9 Žarko 2010-03-18 08:06:35 UTC
(In reply to comment #6)
> I'll just go straight to the point: I don't have an UPS, and I don't know how
> to handle it. If I had one, I could implement this, but since I don't, I really
> don't want to introduce a feature (and consequent bugs) I can't test
> personally.

Hello Dario.

I ma the owner of one of these UPSes. So, maybe I can help you to test the code of Powerdevil.

As a start point I give it to you reports from solid-hardware command:

solid-hardware query 'IS Battery'
udi = '/org/freedesktop/Hal/devices/usb_device_51d_2_QB0429138064_if0_hiddev'

and details:

udi = '/org/freedesktop/Hal/devices/usb_device_51d_2_QB0429138064_if0_hiddev'
  parent = '/org/freedesktop/Hal/devices/usb_device_51d_2_QB0429138064_if0'  (string)
  vendor = ''  (string)
  product = 'American Power Conversion Back-UPS CS 650 FW:817.v2.I USB FW:v2'  (string)
  Battery.plugged = true  (bool)
  Battery.type = 'UpsBattery'  (0x2)  (enum)
  Battery.chargePercent = 100  (0x64)  (int)
  Battery.rechargeable = true  (bool)
  Battery.chargeState = 'NoCharge'  (0x0)  (enum)

It will be very nice if PowerDevil can handle UPS's battery states,put the PC to Powersaving profile and initiate Suspend/Hibernate or Shutdown procedures...

If GNOME has this, why KDE don't?
Comment 10 Žarko 2010-03-18 08:31:48 UTC
Huh,

It seems that I made mistake ;)

Powerdevil see my UPS battery (and report them as Number of Batteries 1), but Battery Monitor plasmoid do not!

so, I'll report bug to Battery Monitor plasmoid.

sorry....
Comment 11 Ben Cooksley 2010-03-18 08:58:26 UTC
SVN commit 1104658 by bcooksley:

Apply the same restrictions in the KCM as we do in the PowerDevil daemon, to ensure that devices we don't monitor aren't shown.
CCBUG: 197627

 M  +6 -1      CapabilitiesPage.cpp  
 M  +6 -1      GeneralPage.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1104658
Comment 12 Ben Cooksley 2010-03-18 08:59:15 UTC
@Dario Freddi: Should that patch be backported?
Comment 13 Žarko 2010-03-18 09:06:29 UTC
So, PowerDevil's daemon do not handle UPS battery?

In this case, my comment #6 stands still.
So, if Dario want to works on implementing UPS controlling to Powerdevil's daemon, I can help with testing with my UPS...
Comment 14 Ben Cooksley 2010-03-18 09:34:01 UTC
@Zarko: Correct, PowerDevil doesn't handle UPS batteries, it was a user interface bug....
Comment 15 id87 2010-03-28 15:17:48 UTC
Firstly: Sorry for my bad English.

Hello Dario.

I'm writing, because I'm another person, who would like to see UPS battery state in KDE SC (Battery Plasmoid).
Believe me - IF I would live in your city I would borrow You my UPS for month,two,three and give You six-pack of bear.
I don't push You, but please Have it in mind (in future).

Thank You.
Comment 16 Igor Strelnikoff 2010-08-09 17:32:56 UTC
Hello Dario

I would like to see UPS battery state in KDE SC (Battery Plasmoid) too.

My reports from solid-hardware command:

solid-hardware query 'IS Battery'
udi = '/org/freedesktop/Hal/devices/usb_device_51d_2_QB0429138064_if0_hiddev'

and details:

udi = '/org/freedesktop/Hal/devices/usb_device_51d_2_5B1015T32856_if0_hiddev'
  parent = '/org/freedesktop/Hal/devices/usb_device_51d_2_5B1015T32856_if0'  (string)
  vendor = ''  (string)
  product = 'American Power Conversion Back-UPS BR  800 FW:9.o5 .I USB FW:o5 '  (string)
  Battery.plugged = true  (bool)
  Battery.type = 'UpsBattery'  (0x2)  (enum)
  Battery.chargePercent = 96  (0x60)  (int)
  Battery.rechargeable = true  (bool)
  Battery.chargeState = 'Charging'  (0x1)  (enum)

How can I help?
Comment 17 Igor Strelnikoff 2010-08-09 17:34:19 UTC
Hello Dario

I would like to see UPS battery state in KDE SC (Battery Plasmoid) too.

My reports from solid-hardware command:

solid-hardware query 'IS Battery'
udi = '/org/freedesktop/Hal/devices/usb_device_51d_2_QB0429138064_if0_hiddev'

and details:

udi = '/org/freedesktop/Hal/devices/usb_device_51d_2_5B1015T32856_if0_hiddev'
  parent = '/org/freedesktop/Hal/devices/usb_device_51d_2_5B1015T32856_if0'  (string)
  vendor = ''  (string)
  product = 'American Power Conversion Back-UPS BR  800 FW:9.o5 .I USB FW:o5 '  (string)
  Battery.plugged = true  (bool)
  Battery.type = 'UpsBattery'  (0x2)  (enum)
  Battery.chargePercent = 96  (0x60)  (int)
  Battery.rechargeable = true  (bool)
  Battery.chargeState = 'Charging'  (0x1)  (enum)

How can I help?
Comment 18 devsk 2010-08-12 21:16:56 UTC
(In reply to comment #17)
> How can I help?

You can't. The owner of this software needs to have a UPS on his desktop for him to write the code. So, unless you can ship a UPS to him, there is no way you can help.  Or may be you are developer. Then, you can write the code yourself...;-)

If you do write the code, please post it here.
Comment 19 Dario Freddi 2010-11-09 21:28:31 UTC
*** Bug 249753 has been marked as a duplicate of this bug. ***
Comment 20 Dario Freddi 2010-11-10 02:30:41 UTC
SVN commit 1194864 by dafre:

BUG: 197627

Make PowerDevil treat an Ups battery as if it was a standard battery.

 M  +6 -1      powerdevilcore.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1194864
Comment 21 2011-01-16 07:25:03 UTC
Using trunk and the same issue here
Comment 22 2011-01-16 07:26:42 UTC
Im using an updated trunk from yesterday and AC continues not being detected,
neither the battery state in powerdevil.
Comment 23 2011-01-19 04:36:24 UTC
i was missing upower.

Stil user should be warned that powerdevil requires upower to run.

Maybe warn during build or in UI, and also explain it in documentation.
Comment 24 Sebastian Kügler 2011-01-19 11:45:24 UTC
Erm, it does ask for the feature and warn if it isn't there.
Comment 25 2011-01-19 12:17:57 UTC
When? Where?

I never saw anything about it....
Comment 26 Lamarque V. Souza 2011-02-05 08:25:54 UTC
Git commit 57c4c504504f3a194a12971080e52afa9218577d by Lamarque V. Souza.
Committed on 05/02/11 at 08:09.
Pushed by lvsouza into branch 'master'.

Treats UPS (uptype == 3) as batteries.
Powerdevil still does not treats my UPS as battery but
solid-hardware query 'IS Battery' works after this change.
It is a start.

CCBUG: 197627

M  +1    -1    solid/solid/backends/upower/upowerdevice.cpp     

http://commits.kde.org/kdelibs/57c4c504504f3a194a12971080e52afa9218577d
Comment 27 Lamarque V. Souza 2011-02-05 16:39:08 UTC
Git commit 7284d452badac7bc4276842cfbade6a51442c6a6 by Lamarque V. Souza.
Committed on 05/02/11 at 16:34.
Pushed by lvsouza into branch 'KDE/4.6'.

Backport 57c4c504504f3a194a12971080e52afa9218577d by lvsouza from master
to the 4.6 branch:

Treats UPS (uptype == 3) as batteries.
Powerdevil still does not treats my UPS as battery but
solid-hardware query 'IS Battery' works after this change.
It is a start.

CCBUG: 197627

M  +1    -1    solid/solid/backends/upower/upowerdevice.cpp     

http://commits.kde.org/kdelibs/7284d452badac7bc4276842cfbade6a51442c6a6
Comment 28 Lamarque V. Souza 2011-02-05 20:49:57 UTC
Git commit c5721519a0ccf8a528bdb31f051509db00e98e0c by Lamarque V. Souza.
Committed on 05/02/11 at 20:40.
Pushed by lvsouza into branch 'master'.

Add UpsBatteries to batterySources so that the Battery plasmoid can
monitors them when using UPower backend.

CCBUG: 197627

M  +4    -2    plasma/generic/dataengines/powermanagement/powermanagementengine.cpp     

http://commits.kde.org/kde-workspace/c5721519a0ccf8a528bdb31f051509db00e98e0c
Comment 29 Osipov Oleg 2011-03-02 01:14:29 UTC
"RESOLVED as FIXED"? I don't think so.
This is my new ippon smart power pro 2000 as it seen by Solid:

$ solid-hardware query 'IS Battery'
udi = '/org/freedesktop/Hal/devices/usb_device_665_5161_noserial'
$ solid-hardware details '/org/freedesktop/Hal/devices/usb_device_665_5161_noserial'
udi = '/org/freedesktop/Hal/devices/usb_device_665_5161_noserial'
  parent = '/org/freedesktop/Hal/devices/usb_device_1d6b_1_0000_00_1d_0'  (string)
  vendor = 'Cypress Semiconductor'  (string)
  product = 'USB to Serial'  (string)
  Battery.plugged = false  (bool)
  Battery.type = 'UpsBattery'  (0x2)  (enum)
  Battery.chargePercent = 0  (0x0)  (int)
  Battery.rechargeable = false  (bool)
  Battery.chargeState = 'NoCharge'  (0x0)  (enum)

Looks like Solid was deceived by ippon's way to provide USB support for their products. Actually, UPS was plugged in, was charged to 100%, is rechargeable and was in charging state. Strange thing: "type" was detected correctly, rest parameters were not.
Comment 30 Ben Cooksley 2011-03-02 05:27:01 UTC
Note that the fixes have only been applied to KDE 4.6, and your use of HAL indicates you probably don't use it.