Agent.py: version = “0.1.5”
Firmware Ver: v0.2.3
Raspberry Pi 3 Model B Plus Rev 1.3
Linux xxxx 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux
Raspbian stretch
I had a similar initial experience here’s my discovery:
pms agent & api use many ‘f-string’ variables which is only supported in python 3.6.x and higher. Stretch has python 3.5.x by default, so download 3.6 or higher and ‘make’ into your existing image. A quicker solution so that you can validate the power portal would be to download Buster lite and have a clean install with python3.7.x already included.
register the device in the power portal and copy the curl string generated into your pi’s terminal. I always precede curl & wget with sudo but that’s just me.
this should successfully register the device and start publishing data (this is an MQTT pub/sub connection).
Once confirmed go to the configuration “tab” in the power portal and scroll to the bottom and update both the firmware & the software (pms agent). I would execute FW first, wait for completion then move on to software. You should end up with FW 0.2.7 & SW 0.1.5
the api (sixfab-power-python-api) is installed as part of the pms agent install when registering the device.
However it was (and may still be) installing 0.0.1.
use pip3 list to see which version of the package is installed.
IF the ‘.1’ then type ‘sudo pip3 install sixfab-power-python-api -U’, run pip3 list again and you should see the 0.0.2 version.
@mark.donofrio thank you for this information. This software package needs to check for Python 3.6 and issue a warning message if not available. I was unaware of this new string format option in Python. I can’t easily upgrade this particular system to the latest Raspbian. Just doing an apt-get upgrade does not bring in Python 3.6 and compiling Python from scratch violates my “only use packages” system maintenance.
So Sixfab should state up front that Buster with Python 3.6 is required.
you can try “converting down” with something like f2format (pip install f2format). I can’t vouch for this and I can’t speak to your “only use packages” agreement, just a suggestion. It seems you’re in a bit of a bind if you can’t install python 3.6/7/8.x and you can’t swap SD card images for ups testing.
@mark.donofrio thanks for the suggestion to try another SD card. I can do that for testing pretty easily.
Meanwhile, I modified the toolkit to remove the troublesome f" strings. They’re only found in a couple of files and the Python %s syntax works well to provide alternate code. Perhaps Sixfab should make these changes to allow earlier versions of Python to be useable. Unless I made a mistake somewhere the code changes did not help and I still have no dashboard data (see below).
agent/core/modules/set_configurations.py
# set scheduled events
for ignored_field in data["ignored_fields"]: # clear ignored events
for event in data["scheduled"]:
event_id_test = "event_" + event['_id']
if event_id_test == ignored_field:
data["scheduled"].remove(event)
for _id in ids_to_add:
if "event_" + _id in data["ignored_fields"]:
continue
With these changes the system is running without error and I’m getting a new “Received PUBLISH (d0, q0, r0, m0), '/device/Path-” message, but still no data on the Dashboard.
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:[FEEDER] Starting, locking
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getBatteryLevel] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getBatteryHealth] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getFanSpeed] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getFanHealth] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getWorkingMode] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[askWatchdogAlarm] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getInputTemp] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getInputVoltage] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getInputCurrent] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getInputPower] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getSystemTemp] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getSystemVoltage] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getSystemCurrent] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getSystemPower] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getBatteryTemp] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getBatteryVoltage] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getBatteryCurrent] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getBatteryPower] #033[0m done
May 20 09:46:22 picayune-2 python3[22839]: DEBUG:root:#033[94m[getFirmwareVer] #033[0m done
May 20 09:46:23 picayune-2 python3[22839]: Received PUBLISH (d0, q0, r0, m0), ‘/device/Path- xxx -Curvy/directives’, … (58 bytes)
May 20 09:46:23 picayune-2 python3[22839]: DEBUG:root:Setting RTC time to default
May 20 09:46:23 picayune-2 python3[22839]: DEBUG:root:#033[94m[setRtcTime] #033[0m Function executed success
After installing a new SD card and reinstalling the software, I’m now getting statistics on the Dashboard, finally. Everything looks normal except fan rotation states 6600 rpm which seems really high and unusual. I loaded 2020-02-13-raspbian-buster-full.img with all the latest updates.
I had a similar problem with raspbx on a pi4. With “sudo systemctl status pms_agent” and “sudo journalctl” I could see that the pms_agent service could not be started.
The Sixfab Power HAT installer expects that a user pi exists, which is a member of the groups sudo, i2c and video and is allowed execute sudo without password.
If you are using an image other than raspbian or you want the pms_agent service to run as a different user (e.g. power), you could do the following:
# create user power, add power to the groups: sudo, i2c, video
sudo adduser power
sudo adduser power sudo
sudo adduser power i2c
sudo adduser power video
# edit /etc/sudoers and at the end of the file insert a line with the following content: "power ALL=(ALL) NOPASSWD:ALL".
echo "power ALL=(ALL) NOPASSWD:ALL"|sudo EDITOR='tee -a' visudo
# stop pms_agent, edit user in /etc/systemd/system/pms_agent.service and start pms_agent
sudo systemctl stop pms_agent
sudo sed -i 's/^\(User=\).*/\1power/' /etc/systemd/system/pms_agent.service
sudo systemctl start pms_agent
I have found in my case that pms/api/run_server/py isn’t running automatically on system startup, I’m not sure if this is down to me using the ‘power’ user as suggested above or if this is something that happens to 1 in x users - hopefully Kev’s set up should be able to clarify this for us.
In order to ‘fix’ this issue I have added: @python3 /opt/sixfab/pms/api/run_server.py & disown
To /etc/xdg/lxsession/LXDE-pi/autostart
Hopefully this will provide a solution to those who are experiencing this issue.
Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
Debug mode: off
Traceback (most recent call last):
File “/opt/sixfab/pms/api/run_server.py”, line 6, in
app.run(host=“0.0.0.0”, port=6060, threaded=False, processes=1, debug=bool(is_debug_enabled))
File “/usr/local/lib/python3.7/dist-packages/flask/app.py”, line 990, in run
run_simple(host, port, self, **options)
File “/usr/local/lib/python3.7/dist-packages/werkzeug/serving.py”, line 1052, in run_simple
inner()
File “/usr/local/lib/python3.7/dist-packages/werkzeug/serving.py”, line 1005, in inner
fd=fd,
File “/usr/local/lib/python3.7/dist-packages/werkzeug/serving.py”, line 863, in make_server
host, port, app, request_handler, passthrough_errors, ssl_context, fd=fd
File “/usr/local/lib/python3.7/dist-packages/werkzeug/serving.py”, line 740, in init
HTTPServer.init(self, server_address, handler)
File “/usr/lib/python3.7/socketserver.py”, line 452, in init
self.server_bind()
File “/usr/lib/python3.7/http/server.py”, line 137, in server_bind
socketserver.TCPServer.server_bind(self)
File “/usr/lib/python3.7/socketserver.py”, line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use
I did try to add the power user as described above, but I had problems editing the sudoers file so I’m going to start over again this evening with a fresh install.