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

RaspberryPi 5 - notes #113

Open
bsimmo opened this issue Oct 14, 2023 · 8 comments
Open

RaspberryPi 5 - notes #113

bsimmo opened this issue Oct 14, 2023 · 8 comments
Assignees
Labels
bug Something isn't working Looking Into This question Further information is requested

Comments

@bsimmo
Copy link

bsimmo commented Oct 14, 2023

Ok less a bug release, just a place I'm going to put any note when I test it on the Pi5 in a little bit
I do know we can add more detail, voltages, fan speed etc.

Bookworm may cause a problem due to the way we need to set it up ( venv and python.) but that's Pi independent.

@bsimmo bsimmo added the bug Something isn't working label Oct 14, 2023
@bsimmo
Copy link
Author

bsimmo commented Oct 28, 2023

I forgot to add some, install isn't much different a few tweaks (simpler) iirc.
Sems to show everything we need.

We can now also show if a 5V 5A PSU is being used (or 3A is being overridden)
We can show the 5V voltage. (and many others).

@ironsheep
Copy link
Owner

Yep, I'm learning venv setup and will adjust my instructions when I figure out a good approach.

Which would you see using more? a per-user setup for venv or a per project setup?

@ironsheep ironsheep added the question Further information is requested label Dec 2, 2023
@ironsheep ironsheep self-assigned this Dec 2, 2023
@sholdee
Copy link

sholdee commented Dec 21, 2023

I created a venv under /opt/RPi-Reporter-MQTT2HA-Daemon, activated the venv, installed requirements, and set isp-rpi-reporter.service as such:

WorkingDirectory=/opt/RPi-Reporter-MQTT2HA-Daemon/
ExecStart=/opt/RPi-Reporter-MQTT2HA-Daemon/venv/bin/python3 -u /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py

Has been working great. I prefer having it in a virtual environment.

@ironsheep
Copy link
Owner

ironsheep commented Dec 21, 2023

@sholdee I can easily make that change and update the docs. Thank you for finding, testing, and reporting this working pattern!

@3VAbdAVE
Copy link

3VAbdAVE commented Jan 7, 2024

Gonna expand on @sholdee 's comment.

This has become more important with Bookworm, since Python 3.11 defaults to failing pip installs without a "--break-system-packages" argument, and that's kinda (intentionally) scary for someone running the install. I've just got this working in a venv, here's my instruction updates:

First, I'd probably remove the duplicate packages entirely and use entirely env local packages. I had a couple conflicts between my own apps and this daemon due to system packages. So put all the requirements into the Python venv, and reduce the OS system instruction to
sudo apt update && sudo apt install -y git python3 python3-pip python3-venv python3-apt

Add the others to requirements.txt. Pip install should take care of dependencies.

This is actually pretty easy, since the virtual environment gets baked in when launched from the venv symlinks.

Create the venv as root:
sudo python -m venv /opt/RPi-Reporter-MQTT2HA-Daemon

I like to put the actual python application into a subfolder to keep the venv clean, "app" in this case:
sudo git clone https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon.git /opt/RPi-Reporter-MQTT2HA-Daemon/app

This is just what I'm using, you might prefer a different pattern.

Install the requirements:
sudo /opt/RPi-Reporter-MQTT2HA-Daemon/bin/pip install -r /opt/RPi-Reporter-MQTT2HA-Daemon/app/requirements.txt

(This worked fine on my systems as-is, it's possible there's some additional system packages needed for pip to do it's thing. Sometimes it can't auto-resolve dependencies, or the wheels need to compile, etc.)

Modify the .service file to execute under the virtualenv. (Ideally this gets updated if you decide to use venvs for future versions.)
sudo sed -i '/^ExecStart=/ s/usr\/bin/opt\/RPi-Reporter-MQTT2HA-Daemon\/bin/; s/ISP-RPi-mqtt-daemon.py/app\/ISP-RPi-mqtt-daemon.py/; /^WorkingDirectory/ s/$/app\//' /opt/RPi-Reporter-MQTT2HA-Daemon/app/isp-rpi-reporter.service

Edit the config.ini as appropriate and set permissions, since it contains the mqtt password. (The default service file runs this as the daemon user.)

sudo chown root:daemon /opt/RPi-Reporter-MQTT2HA-Daemon/app/config.ini
sudo chmod 640 /opt/RPi-Reporter-MQTT2HA-Daemon/app/config.ini

Install the service file and kick it off:

sudo mkdir -p /usr/local/lib/systemd/system/
sudo ln -s /opt/RPi-Reporter-MQTT2HA-Daemon/app/isp-rpi-reporter.service /usr/local/lib/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now isp-rpi-reporter.service

Since the service runs as daemon, I had errors with files in /dev on one or two systems. In my case, I added daemon to the video group, but you can also just set the service file to run as root. w/e works in your env.

@pskowronek
Copy link

pskowronek commented Jan 28, 2024

[ Awaiting the update regarding venv :) ]

btw, on Bookworm (RPi 4) this package is not installed by default: libraspberrypi-bin

@koira
Copy link

koira commented Aug 25, 2024

Gonna expand on @sholdee 's comment.

This has become more important with Bookworm, [...]

thanks for the instructions - worked perfect for me 🙏

@sudo-su-root
Copy link

sudo-su-root commented Oct 18, 2024

Gonna expand on @sholdee 's comment.

This has become more important with Bookworm, since Python 3.11 defaults to failing pip installs without a "--break-system-packages" argument, and that's kinda (intentionally) scary for someone running the install. I've just got this working in a venv, here's my instruction updates:

First, I'd probably remove the duplicate packages entirely and use entirely env local packages. I had a couple conflicts between my own apps and this daemon due to system packages. So put all the requirements into the Python venv, and reduce the OS system instruction to sudo apt update && sudo apt install -y git python3 python3-pip python3-venv python3-apt

Add the others to requirements.txt. Pip install should take care of dependencies.

This is actually pretty easy, since the virtual environment gets baked in when launched from the venv symlinks.

Create the venv as root: sudo python -m venv /opt/RPi-Reporter-MQTT2HA-Daemon

I like to put the actual python application into a subfolder to keep the venv clean, "app" in this case: sudo git clone https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon.git /opt/RPi-Reporter-MQTT2HA-Daemon/app

This is just what I'm using, you might prefer a different pattern.

Install the requirements: sudo /opt/RPi-Reporter-MQTT2HA-Daemon/bin/pip install -r /opt/RPi-Reporter-MQTT2HA-Daemon/app/requirements.txt

(This worked fine on my systems as-is, it's possible there's some additional system packages needed for pip to do it's thing. Sometimes it can't auto-resolve dependencies, or the wheels need to compile, etc.)

Modify the .service file to execute under the virtualenv. (Ideally this gets updated if you decide to use venvs for future versions.) sudo sed -i '/^ExecStart=/ s/usr\/bin/opt\/RPi-Reporter-MQTT2HA-Daemon\/bin/; s/ISP-RPi-mqtt-daemon.py/app\/ISP-RPi-mqtt-daemon.py/; /^WorkingDirectory/ s/$/app\//' /opt/RPi-Reporter-MQTT2HA-Daemon/app/isp-rpi-reporter.service

Edit the config.ini as appropriate and set permissions, since it contains the mqtt password. (The default service file runs this as the daemon user.)

sudo chown root:daemon /opt/RPi-Reporter-MQTT2HA-Daemon/app/config.ini
sudo chmod 640 /opt/RPi-Reporter-MQTT2HA-Daemon/app/config.ini

Install the service file and kick it off:

sudo mkdir -p /usr/local/lib/systemd/system/
sudo ln -s /opt/RPi-Reporter-MQTT2HA-Daemon/app/isp-rpi-reporter.service /usr/local/lib/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now isp-rpi-reporter.service

Since the service runs as daemon, I had errors with files in /dev on one or two systems. In my case, I added daemon to the video group, but you can also just set the service file to run as root. w/e works in your env.

For anyone reading this, blank pi zero 2w -> Bookworm RPI OS Light 64bit - actual install commands that worked for me below. They might work in a single script if you remove sudo and run the script as sudo.
Things that caused me an issue:

  • python command, you either need an alias for python3 or just update the command as I did.
  • Comment above did not mention switching to v1.8.5, it would not start before I did this.

Might help someone update the actual install guide...

sudo apt-get update
sudo apt-get upgrade -y
sudo apt update && sudo apt install -y git python3 python3-pip python3-venv python3-apt
sudo python3 -m venv /opt/RPi-Reporter-MQTT2HA-Daemon
sudo git clone https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon.git /opt/RPi-Reporter-MQTT2HA-Daemon/app
cd /opt/RPi-Reporter-MQTT2HA-Daemon/app
sudo git checkout v1.8.5
sudo /opt/RPi-Reporter-MQTT2HA-Daemon/bin/pip install -r /opt/RPi-Reporter-MQTT2HA-Daemon/app/requirements.txt
sudo sed -i '/^ExecStart=/ s/usr/bin/opt/RPi-Reporter-MQTT2HA-Daemon/bin/; s/ISP-RPi-mqtt-daemon.py/app/ISP-RPi-mqtt-daemon.py/; /^WorkingDirectory/ s/$/app//' /opt/RPi-Reporter-MQTT2HA-Daemon/app/isp-rpi-reporter.service
sudo cp /opt/RPi-Reporter-MQTT2HA-Daemon/app/config.ini.dist /opt/RPi-Reporter-MQTT2HA-Daemon/app/config.ini
sudo chown root:daemon /opt/RPi-Reporter-MQTT2HA-Daemon/app/config.ini
sudo chmod 640 /opt/RPi-Reporter-MQTT2HA-Daemon/app/config.ini
sudo sed -i "/#username/c\username = hassagent" /opt/RPi-Reporter-MQTT2HA-Daemon/app/config.ini
sudo sed -i "/#password/c\password = hassagentpw" /opt/RPi-Reporter-MQTT2HA-Daemon/app/config.ini
sudo sed -i "/#hostname/c\hostname = jhvwejhbfewr.net" /opt/RPi-Reporter-MQTT2HA-Daemon/app/config.ini
sudo mkdir -p /usr/local/lib/systemd/system/
sudo ln -s /opt/RPi-Reporter-MQTT2HA-Daemon/app/isp-rpi-reporter.service /usr/local/lib/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now isp-rpi-reporter.service
sudo reboot now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Looking Into This question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants