Coder Social home page Coder Social logo

ups3's People

Contributors

geekworm-com avatar onajafi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ups3's Issues

How should the four LED should light up (on)

Hi, excuse me. I'm finally trying out my UPS3 but seems to not turning on the 4 main lights (which is supposed to be for Battery percentage). Also, is there any way to display my battery percentage on my taskbar from Raspberry Pi OS?

Thanks. Otherwise, after installation, it says it is not charging (to charging it, do I must to connect my supply cable to the UPS module right?)

The smartups.py service floods the smartups.log file

It logs almost every second (pls. see below) and the log file grows unnecessarily by about 6 MB in 24 hours and thus unnecessarily increases the memory card wear in RPi.

I suggest logging only when changing any of the parameters and at least once every 1 hour, if at all.

Sample from /var/log/smartups.log file:

2020-12-31 08:00:58,243  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:00:59,460  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:00,677  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:01,899  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:03,122  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:04,345  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:05,562  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:06,783  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:07,996  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:09,219  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:10,436  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:11,653  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:12,877  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:14,094  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:15,310  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:16,523  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:17,746  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:18,968  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:20,192  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:21,415  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:22,627  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:23,848  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:25,058  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:26,275  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:27,498  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%
2020-12-31 08:01:28,714  smartups.py : INFO   Input:Connected , ChargeStatus: Charging done , SOC:91.171875%

Getting the UPS3 software running

This UPS3 github repo was updated in June of 2020 with the purpose of "making it compatible with python3". Then in May of 2021 they apparently blasted the older Python2 files back on top of the Python3 versions. You will need to add parentheses on all of the print statements in the three .py files.

I set this up on a Pi Zero W with Bullseye Lite. I needed to install both smbus and pip3 as a prerequisites before running install.sh, as neither are in the Lite Bullseye build apparently. The install failed without these prior installs:

sudo apt-get install python3-pip
sudo apt-get install python3-smbus

The smartups service was failing with the following, per systemctl status smartups

Dec 18 17:28:35 RPi3 systemd[1]: smartups.service: Scheduled restart job, restart counter is at 5.
Dec 18 17:28:35 RPi3 systemd[1]: Stopped ugeek smart ups v3.
Dec 18 17:28:35 RPi3 systemd[1]: smartups.service: Start request repeated too quickly.
Dec 18 17:28:35 RPi3 systemd[1]: smartups.service: Failed with result 'exit-code'.
Dec 18 17:28:35 RPi3 systemd[1]: Failed to start ugeek smart ups v3.

journalctl -e -u smartups showed:

…
Dec 18 18:05:33 RPi3 sudo[1785]: pam_unix(sudo:auth): conversation failed
Dec 18 18:05:33 RPi3 sudo[1785]: pam_unix(sudo:auth): auth could not identify password for [pi]
Dec 18 18:05:33 RPi3 systemd[1]: smartups.service: Main process exited, code=exited, status=1/FAILURE
Dec 18 18:05:33 RPi3 systemd[1]: smartups.service: Failed with result 'exit-code'.
Dec 18 18:05:33 RPi3 systemd[1]: smartups.service: Scheduled restart job, restart counter is at 4.
Dec 18 18:05:33 RPi3 systemd[1]: Stopped ugeek smart ups v3.
Dec 18 18:05:33 RPi3 systemd[1]: Started ugeek smart ups v3.
Dec 18 18:05:33 RPi3 IMS[1786]: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
Dec 18 18:05:33 RPi3 IMS[1786]: sudo: a password is required
Dec 18 18:05:33 RPi3 sudo[1786]: pam_unix(sudo:auth): conversation failed
Dec 18 18:05:33 RPi3 sudo[1786]: pam_unix(sudo:auth): auth could not identify password for [pi]
Dec 18 18:05:33 RPi3 systemd[1]: smartups.service: Main process exited, code=exited, status=1/FAILURE
Dec 18 18:05:33 RPi3 systemd[1]: smartups.service: Failed with result 'exit-code'.
Dec 18 18:05:33 RPi3 systemd[1]: smartups.service: Scheduled restart job, restart counter is at 5.
Dec 18 18:05:33 RPi3 systemd[1]: Stopped ugeek smart ups v3.
Dec 18 18:05:33 RPi3 systemd[1]: smartups.service: Start request repeated too quickly.
Dec 18 18:05:33 RPi3 systemd[1]: smartups.service: Failed with result 'exit-code'.
Dec 18 18:05:33 RPi3 systemd[1]: Failed to start ugeek smart ups v3.

The sudo password prompt was a clue. I had previously set sudo to require a password. After undoing the sudo password requirement setting the smartups service starts properly.

A few additional notes

  • The service runs as user pi, and thus requires use of sudo to issue a power down halt.
  • status.py stops the smartups service, does its thing, then restarts the service. Thus, running status.py must be done with sudo.
  • Python3 complains about status.py line 209 if service_status is 0: is should be ==.
  • smartups.py logs to /var/log/smartups every second. That's a lot of pounding on the SD card for a long term.

For my applications I'm thinking of implementing a service that can be provide status info to a calling app, rather than the provided scheme of killing the service, reading the registers directly, and restarting the service. Thus, a user app need not be run with sudo. More study and research TBD.

Install with errors, service fails to load

I determined a couple of problems. It was tested with Raspbian Buster (27th May 2020) on RPi 4B:

When executing the install script, it reports:
dpkg-query: no packages found matching scons

After going through the menu items of the install script and enabling the service, it fails to start.
This is, what systemctl reports (sorry for the truncated lines):
pi@raspberrypi:~/ups3 $ sudo systemctl status smartups.service
● smartups.service - ugeek smart ups v3
Loaded: loaded (/etc/systemd/system/smartups.service; enabled; vendor
Active: failed (Result: exit-code) since Thu 2020-07-02 22:28:04 CEST
Process: 375 ExecStart=/usr/bin/sudo /usr/bin/python3 /usr/local/bin/s
Main PID: 375 (code=exited, status=1/FAILURE)

Jul 02 22:28:04 raspberrypi systemd[1]: smartups.service: Service Restar
Jul 02 22:28:04 raspberrypi systemd[1]: smartups.service: Scheduled rest
Jul 02 22:28:04 raspberrypi systemd[1]: Stopped ugeek smart ups v3.
Jul 02 22:28:04 raspberrypi systemd[1]: smartups.service: Start request
Jul 02 22:28:04 raspberrypi systemd[1]: smartups.service: Failed with re
Jul 02 22:28:04 raspberrypi systemd[1]: Failed to start ugeek smart ups

When starting the smartups.py manually, this happens:
pi@raspberrypi:~/ups3 $ /usr/bin/sudo /usr/bin/python3 /usr/local/bin/smartups.py
Traceback (most recent call last):
File "/usr/local/bin/smartups.py", line 12, in
from neopixel import *
File "/usr/local/bin/neopixel.py", line 5, in
import _rpi_ws281x as ws
ModuleNotFoundError: No module named '_rpi_ws281x'

Hoping you can fix it soon.

The install.sh script does not install the rpi-ws281x Python library due to a server outage

The following code is used in the install.sh script:
SOFT = $ (pip search rpi-ws281x | grep "INSTALLED")
which, however, is currently failing due to a failure on the part of PyPI's search backends, pls. see the error listing below.

I suggest using this code instead.
SOFT = $ (pip list | grep "rpi-ws281x")
Or better yet, replace pip call with pip3 everywhere, which solves incorrect include when running other scripts using python3, especially in smartups.service.

	SOFT = $ (pip3 list | grep "rpi-ws281x")
	if [ -z "$SOFT" ]; then
		pip3 install rpi-ws281x

Contents of the message when trying to install:

Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 143, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/search.py", line 48, in run
    pypi_hits = self.search(query, options)
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/search.py", line 65, in search
    hits = pypi.search({'name': query, 'summary': query}, 'or')
  File "/usr/lib/python3.7/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.7/xmlrpc/client.py", line 1452, in __request
    verbose=self.__verbose
  File "/usr/lib/python3/dist-packages/pip/_internal/download.py", line 791, in request
    return self.parse_response(response.raw)
  File "/usr/lib/python3.7/xmlrpc/client.py", line 1342, in parse_response
    return u.close()
  File "/usr/lib/python3.7/xmlrpc/client.py", line 656, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault -32500: "RuntimeError: PyPI's XMLRPC API has been temporarily disabled due to unmanageable load and will be deprecated in the near future. See https://status.python.org/ for more information.">

Installation failed

sudo ./install.sh

Install Smart UPS Service.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: rpi-ws281x in /usr/local/lib/python3.9/dist-packages (4.3.4)
Created symlink /etc/systemd/system/sysinit.target.wants/smartups.service -> /etc/systemd/system/smartups.service.
Start service now.
Service install failed, clean now.
Remove Smart UPS Service.
Removed /etc/systemd/system/sysinit.target.wants/smartups.service.
Service remove complete.
Failed to get unit file state for smartups.service: No such file or directory

sudo systemctl status smartups.service

Warning: The unit file, source configuration file or drop-ins of smartups.service changed on disk. Run 'systemctl daemon-reload' to reload units.

  • smartups.service - ugeek smart ups v3
    Loaded: loaded (/etc/systemd/system/smartups.service; bad; vendor preset: enabled)
    Active: failed (Result: exit-code) since Sun 2022-10-23 22:18:12 EEST; 3min 21s ago
    Process: 3076 ExecStart=/usr/bin/sudo /usr/bin/python3 /usr/local/bin/smartups.py (code=exited, status=216/GROUP)
    Main PID: 3076 (code=exited, status=216/GROUP)
    CPU: 7ms

loka 23 22:18:12 raspberrypi systemd[1]: smartups.service: Scheduled restart job, restart counter is at 6.
loka 23 22:18:12 raspberrypi systemd[1]: Stopped ugeek smart ups v3.
loka 23 22:18:12 raspberrypi systemd[1]: smartups.service: Start request repeated too quickly.
loka 23 22:18:12 raspberrypi systemd[1]: smartups.service: Failed with result 'exit-code'.
loka 23 22:18:12 raspberrypi systemd[1]: Failed to start ugeek smart ups v3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.