Skip to content

Getting the UPS3 software running #7

Description

@cjnaz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions