Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CyberPower UT series do not seem to pass correct 'OB' flag, try to accommodate this with new "onlinedischarge" config flag #811

Merged
merged 25 commits into from
Mar 29, 2022

Conversation

kgizdov
Copy link
Contributor

@kgizdov kgizdov commented Aug 11, 2020

As the title says. I have CPS UT1500E and unfortunately whatever I do, I cannot get it to show correct online status. I have been in contact with support and they say the UPS is operating as it should. Thus, I have arrived at this workaround.

The issue is as follows, when the UPS loses mains power, it goes from OL into OL DISCHRG mode. Yes, it does not change it's input mode. However, it correctly shows input voltage to be 0. The only way to circumvent this I have found to be encapsulated in this PR.

I am, however, open to suggestions on how to make it better as it clearly only applies to certain types of UPSes. I was thinking to filter on VRANGE, but that somehow seemed inappropriate to me.

Let me know if you require further info or testing and/or logs. Maybe we can find the actual underlying reason this happens and fix it at the core. Cheers.

@jimklimov
Copy link
Member

There is a bit of code-style issue in the initial commit (indentation should start with TABs until the level of if on the previous line).

Given that this misbehavior may be not present on all devices supported by the driver, I think it makes sense to define (and document!) a driver option for the "quirk" similar to what was done in https://github.com/networkupstools/nut/pull/788/files - then it is up to end-users suffering same as you to toggle this for their deployment or stay with current behavior.

It may make sense to log or even post ("wall?") the situation, like "We are in a strange OL DISCHRG situation at the moment, do you need the XXX quirk in your driver to handle this as an outage?"

Thinking out loud, an UPS calibration event might also seem like this validly - the device still has wall power, but is intentionally discharging the battery to see how long it lasts with your load.

@kgizdov
Copy link
Contributor Author

kgizdov commented Oct 9, 2020

I agree with everything said. I will fix the indentation and will try to refactor as requested. For your last comment, yes, we should detect the UPS calibration and if we cannot, we should issue a warning like "you are in this weird state, if you are not in a calibration mode, maybe you need this setting: bla". How's that sound?

@jimklimov
Copy link
Member

Sounds right. See also #817 merged recently that dealt with similar question (whether calibration is an outage).

@kgizdov
Copy link
Contributor Author

kgizdov commented Oct 9, 2020

obviously not ready, but is this something in the right direction?

Copy link
Member

@jimklimov jimklimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General direction looks good, some comments to code posted.
Also lacks a change to manpage, to document the new driver option for the quirk.

@kgizdov
Copy link
Contributor Author

kgizdov commented Oct 11, 2020

@jimklimov where would it be appropriate to explain in the manual structure. I can see the general config notes as well as the general hid-driver man. Not sure if either is a great place as this seems specific. Thoughts?

Copy link
Member

@jimklimov jimklimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of blocking build issues appeared in recent iterations, commented.

@jimklimov
Copy link
Member

jimklimov commented Nov 7, 2020

As for a good place to document the new driver option (added after I initially posted the reference to #788), I think a driver manpage could be good. In case of that PR, its origin could not be modified so a later commit was pushed to master adding the manpage changes for that: 799fd5a

For this PR, the suitable manpage at this time would probably be the USB family's common location: https://github.com/networkupstools/nut/blob/master/docs/man/usbhid-ups.txt

It may be worth adding a mention of the situation (with reference to manpage for specific details) in https://github.com/networkupstools/nut/blob/master/docs/config-notes.txt

@jimklimov jimklimov added the needs-work PR discussion concluded that some work is needed from the contributor label Sep 22, 2021
@jimklimov
Copy link
Member

@kgizdov : Just in case: is this PR's problem area related to #439 (as it evolved in the end) and #1245 as the generic solution to allow hotfixing known invalid mappings?

@kgizdov
Copy link
Contributor Author

kgizdov commented Jan 27, 2022

@jimklimov oh, sorry, this MR has completely gone out of my schedule somehow as I jumped into some other work. Allow me a couple of week to have a look. But I think if you've got a more general solution to this then by all means that's the end goal. Let me know if there's anything specific (code-wise) and should be aware of to incorporate or completely refactor the changes.

@jimklimov
Copy link
Member

Hi, thanks for the reply. I think, since #1245 was by now merged, it would help if you review its change so that we can decide if your original fix is needed or your goal is achieved by that one, and/or if your solution can be adapted to use that mechanism.

@jimklimov jimklimov marked this pull request as draft March 16, 2022 12:44
@jimklimov
Copy link
Member

Brushed up the PR, it seems to have merit regardless of "general hotfix for invalid mappings". At worst, we would have two solutions for one of the problems :)

@jimklimov jimklimov marked this pull request as ready for review March 28, 2022 13:57
@jimklimov jimklimov changed the title [WIP] CyberPower UT series do not seem to pass correct 'OB' flag, try to accommodate this CyberPower UT series do not seem to pass correct 'OB' flag, try to accommodate this Mar 28, 2022
@jimklimov jimklimov added enhancement ready / code review Author (and CI) consider the PR worthy of human rewievers' time ready / gonna merge The PR is in final cycles leading to merge unless someone logs an objection before we hit the button and removed needs-work PR discussion concluded that some work is needed from the contributor labels Mar 28, 2022
@jimklimov jimklimov changed the title CyberPower UT series do not seem to pass correct 'OB' flag, try to accommodate this CyberPower UT series do not seem to pass correct 'OB' flag, try to accommodate this with new "onlinedischarge" config flag Mar 29, 2022
@jimklimov jimklimov merged commit a8e3687 into networkupstools:master Mar 29, 2022
@jimklimov
Copy link
Member

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CyberPower (CPS) enhancement ready / code review Author (and CI) consider the PR worthy of human rewievers' time ready / gonna merge The PR is in final cycles leading to merge unless someone logs an objection before we hit the button
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants