Closed HDmaniac closed 3 years ago
Same error is occuring on my fresh installation on a RPI3
Did you execute following command: sudo apt-get install python3-apt?
yes i did - version 1.4.3 is already installed on my system
Could you try to disable the updates in the settings.yaml just to check if it then works
I've just tried it without updates option.
Here is my settings.yaml: mqtt: hostname: 10.1.100.93 port: 1883 #defaults to 1883 user: homeassistant password: removed for data protection deviceName: deconz client_id: deconz timezone: Europe/Brussels update_interval: 60 #Defaults to 60 check_wifi_strength: true check_available_updates: false external_drives: Drive1: /boot/
Having rebooted after changing settings.yaml, the error still remains the same:
`pi@phoscon:~ $ sudo systemctl status system_sensors.service ● system_sensors.service - System Sensor service Loaded: loaded (/etc/systemd/system/system_sensors.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Tue 2021-03-23 21:11:35 UTC; 18s ago Process: 761 ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sensors.py /home/$ (code=exited, status=1/FAILURE) Main PID: 761 (code=exited, status=1/FAILURE)
Mär 23 21:11:33 phoscon systemd[1]: Started System Sensor service. Mär 23 21:11:35 phoscon python3[761]: File "/home/pi/system_sensors/src/system_sensors.py", line 96 Mär 23 21:11:35 phoscon python3[761]: print (f"Message received: {message.payload.decode()}" ) Mär 23 21:11:35 phoscon python3[761]: ^ Mär 23 21:11:35 phoscon python3[761]: SyntaxError: invalid syntax Mär 23 21:11:35 phoscon systemd[1]: system_sensors.service: Main process exited, code=exited, status=1/FAILURE Mär 23 21:11:35 phoscon systemd[1]: system_sensors.service: Unit entered failed state. Mär 23 21:11:35 phoscon systemd[1]: system_sensors.service: Failed with result 'exit-code'.`
When running pi@phoscon:~/system_sensors $ python3 src/system_sensors.py src/settings.yaml everything is working properly
Hmm that's weird. Could you send the contents of the system_sensor.service file?
Sure :-)
[Unit] Description=System Sensor service After=multi-user.target
[Service] User=pi Type=idle ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sensors.py /home/pi/system_sensors/src/settings.yaml
[Install] WantedBy=multi-user.target
i have just double checked, if it's working now as I have detected an error in my service-file. I have corrected the error copied the service file to the correct directory, and re-enabled the service. error still remains the same:
pi@phoscon:~/system_sensors $ sudo systemctl status system_sensors.service ● system_sensors.service - System Sensor service Loaded: loaded (/etc/systemd/system/system_sensors.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Tue 2021-03-23 21:28:53 UTC; 4s ago Process: 2489 ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sensors.py /home/pi/system_sensors/src/settings.yaml (code=exited, status=1/FAILURE) Main PID: 2489 (code=exited, status=1/FAILURE)
Mär 23 21:28:53 phoscon systemd[1]: Started System Sensor service. Mär 23 21:28:53 phoscon python3[2489]: File "/home/pi/system_sensors/src/system_sensors.py", line 96 Mär 23 21:28:53 phoscon python3[2489]: print (f"Message received: {message.payload.decode()}" ) Mär 23 21:28:53 phoscon python3[2489]: ^ Mär 23 21:28:53 phoscon python3[2489]: SyntaxError: invalid syntax Mär 23 21:28:53 phoscon systemd[1]: system_sensors.service: Main process exited, code=exited, status=1/FAILURE Mär 23 21:28:53 phoscon systemd[1]: system_sensors.service: Unit entered failed state. Mär 23 21:28:53 phoscon systemd[1]: system_sensors.service: Failed with result 'exit-code'.
What version of python are you running?
Had the same issue on a RPi4 and took a while to troubleshoot things. Sorted with the below. Used systemd-analyze plot > output.svg on before/after, looks like waiting for docker is part of the problem, starting it earlier after network-online.target works. Only have a couple of containers, one of them uses mqtt for HA related things. Still works after the change.
An FYI to others who may be having the same issue.
[Unit] Description=System Sensor service
After=network-online.target Wants=network-online.target
[Service] User=pi Type=idle ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sensors.py /home/pi/system_sensors/src/settings.yaml
[Install] WantedBy=multi-user.target
What version of python are you running?
I am running 3.8.4
Had the same issue on a RPi4 and took a while to troubleshoot things. Sorted with the below. Used systemd-analyze plot > output.svg on before/after, looks like waiting for docker is part of the problem, starting it earlier after network-online.target works. Only have a couple of containers, one of them uses mqtt for HA related things. Still works after the change.
An FYI to others who may be having the same issue.
[Unit] Description=System Sensor service
After=multi-user.target
After=network-online.target Wants=network-online.target
[Service] User=pi Type=idle ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sensors.py /home/pi/system_sensors/src/settings.yaml
[Install] WantedBy=multi-user.target
Thanks for sharing your solution. Unfortunately, it seems to be not working for my setup on my RPI3. Still facing the same issuce.
sudo systemctl status system_sensors.service ● system_sensors.service - System Sensor service Loaded: loaded (/etc/systemd/system/system_sensors.service; enabled; vendor p Active: failed (Result: exit-code) since Mon 2021-03-29 05:52:53 UTC; 44s ago Process: 668 ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sen Main PID: 668 (code=exited, status=1/FAILURE)
Mär 29 05:52:51 phoscon systemd[1]: Started System Sensor service. Mär 29 05:52:53 phoscon python3[668]: File "/home/pi/system_sensors/src/system Mär 29 05:52:53 phoscon python3[668]: print (f"Message received: {message.pa Mär 29 05:52:53 phoscon python3[668]: Mär 29 05:52:53 phoscon python3[668]: SyntaxError: invalid syntax Mär 29 05:52:53 phoscon systemd[1]: system_sensors.service: Main process exited, Mär 29 05:52:53 phoscon systemd[1]: system_sensors.service: Unit entered failed Mär 29 05:52:53 phoscon systemd[1]: system_sensors.service: Failed with result ' lines 1-14/14 (END)...skipping... ● system_sensors.service - System Sensor service Loaded: loaded (/etc/systemd/system/system_sensors.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2021-03-29 05:52:53 UTC; 44s ago Process: 668 ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sensors.py /home/pi/system_sensors/src/settings.yaml (code=exited, status=1/FAILURE) Main PID: 668 (code=exited, status=1/FAILURE)
Mär 29 05:52:51 phoscon systemd[1]: Started System Sensor service. Mär 29 05:52:53 phoscon python3[668]: File "/home/pi/system_sensors/src/system_sensors.py", line 96 Mär 29 05:52:53 phoscon python3[668]: print (f"Message received: {message.payload.decode()}" ) Mär 29 05:52:53 phoscon python3[668]: ^ Mär 29 05:52:53 phoscon python3[668]: SyntaxError: invalid syntax Mär 29 05:52:53 phoscon systemd[1]: system_sensors.service: Main process exited, code=exited, status=1/FAILURE Mär 29 05:52:53 phoscon systemd[1]: system_sensors.service: Unit entered failed state. Mär 29 05:52:53 phoscon systemd[1]: system_sensors.service: Failed with result 'exit-code'.
I have the same issue on a 3B, manually I can start it, but it cannot auto start on reboot
Sadly, same error for my, raspberry pi 3b - manual start works fine, start on reboot doesn't work - error "Network is unreachable"?
`pi@raspberrypi:~ $ sudo systemctl status system_sensors.service ● system_sensors.service - System Sensor service Loaded: loaded (/etc/systemd/system/system_sensors.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Fri 2021-05-07 15:31:18 CEST; 2min 49s ago Process: 454 ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sensors.py /home/pi/system_sensors/src/settings.yaml (code=exited, status=1 Main PID: 454 (code=exited, status=1/FAILURE)
Mai 07 15:31:18 raspberrypi python3[454]: sock = self._create_socket_connection() Mai 07 15:31:18 raspberrypi python3[454]: File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 3522, in _create_socket_connect Mai 07 15:31:18 raspberrypi python3[454]: return socket.create_connection(addr, source_address=source, timeout=self._keepalive) Mai 07 15:31:18 raspberrypi python3[454]: File "/usr/lib/python3.7/socket.py", line 727, in create_connection Mai 07 15:31:18 raspberrypi python3[454]: raise err Mai 07 15:31:18 raspberrypi python3[454]: File "/usr/lib/python3.7/socket.py", line 716, in create_connection Mai 07 15:31:18 raspberrypi python3[454]: sock.connect(sa) Mai 07 15:31:18 raspberrypi python3[454]: OSError: [Errno 101] Network is unreachable Mai 07 15:31:18 raspberrypi systemd[1]: system_sensors.service: Main process exited, code=exited, status=1/FAILURE Mai 07 15:31:18 raspberrypi systemd[1]: system_sensors.service: Failed with result 'exit-code'. lines 1-16/16 (END)`
Sadly, same error for my, raspberry pi 3b - manual start works fine, start on reboot doesn't work - error "Network is unreachable"?
`pi@raspberrypi:~ $ sudo systemctl status system_sensors.service ● system_sensors.service - System Sensor service Loaded: loaded (/etc/systemd/system/system_sensors.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Fri 2021-05-07 15:31:18 CEST; 2min 49s ago Process: 454 ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sensors.py /home/pi/system_sensors/src/settings.yaml (code=exited, status=1 Main PID: 454 (code=exited, status=1/FAILURE)
Mai 07 15:31:18 raspberrypi python3[454]: sock = self._create_socket_connection() Mai 07 15:31:18 raspberrypi python3[454]: File "/home/pi/.local/lib/python3.7/site-packages/paho/mqtt/client.py", line 3522, in _create_socket_connect Mai 07 15:31:18 raspberrypi python3[454]: return socket.create_connection(addr, source_address=source, timeout=self._keepalive) Mai 07 15:31:18 raspberrypi python3[454]: File "/usr/lib/python3.7/socket.py", line 727, in create_connection Mai 07 15:31:18 raspberrypi python3[454]: raise err Mai 07 15:31:18 raspberrypi python3[454]: File "/usr/lib/python3.7/socket.py", line 716, in create_connection Mai 07 15:31:18 raspberrypi python3[454]: sock.connect(sa) Mai 07 15:31:18 raspberrypi python3[454]: OSError: [Errno 101] Network is unreachable Mai 07 15:31:18 raspberrypi systemd[1]: system_sensors.service: Main process exited, code=exited, status=1/FAILURE Mai 07 15:31:18 raspberrypi systemd[1]: system_sensors.service: Failed with result 'exit-code'. lines 1-16/16 (END)`
do you have following lines in your systemd file: After=network-online.target Wants=network-online.target I don't have any problems and use it on 5 different PI's some on wifi some on ethernet so for some reason your PI takes a long time to connect
Had the same issue on a RPi4 and took a while to troubleshoot things. Sorted with the below. Used systemd-analyze plot > output.svg on before/after, looks like waiting for docker is part of the problem, starting it earlier after network-online.target works. Only have a couple of containers, one of them uses mqtt for HA related things. Still works after the change. An FYI to others who may be having the same issue. [Unit] Description=System Sensor service
After=multi-user.target
After=network-online.target Wants=network-online.target [Service] User=pi Type=idle ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sensors.py /home/pi/system_sensors/src/settings.yaml [Install] WantedBy=multi-user.target
Thanks for sharing your solution. Unfortunately, it seems to be not working for my setup on my RPI3. Still facing the same issuce.
sudo systemctl status system_sensors.service ● system_sensors.service - System Sensor service Loaded: loaded (/etc/systemd/system/system_sensors.service; enabled; vendor p Active: failed (Result: exit-code) since Mon 2021-03-29 05:52:53 UTC; 44s ago Process: 668 ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sen Main PID: 668 (code=exited, status=1/FAILURE)
Mär 29 05:52:51 phoscon systemd[1]: Started System Sensor service. Mär 29 05:52:53 phoscon python3[668]: File "/home/pi/system_sensors/src/system Mär 29 05:52:53 phoscon python3[668]: print (f"Message received: {message.pa Mär 29 05:52:53 phoscon python3[668]: Mär 29 05:52:53 phoscon python3[668]: SyntaxError: invalid syntax Mär 29 05:52:53 phoscon systemd[1]: system_sensors.service: Main process exited, Mär 29 05:52:53 phoscon systemd[1]: system_sensors.service: Unit entered failed Mär 29 05:52:53 phoscon systemd[1]: system_sensors.service: Failed with result ' lines 1-14/14 (END)...skipping... ● system_sensors.service - System Sensor service Loaded: loaded (/etc/systemd/system/system_sensors.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2021-03-29 05:52:53 UTC; 44s ago Process: 668 ExecStart=/usr/bin/python3 /home/pi/system_sensors/src/system_sensors.py /home/pi/system_sensors/src/settings.yaml (code=exited, status=1/FAILURE) Main PID: 668 (code=exited, status=1/FAILURE)
Mär 29 05:52:51 phoscon systemd[1]: Started System Sensor service. Mär 29 05:52:53 phoscon python3[668]: File "/home/pi/system_sensors/src/system_sensors.py", line 96 Mär 29 05:52:53 phoscon python3[668]: print (f"Message received: {message.payload.decode()}" ) Mär 29 05:52:53 phoscon python3[668]: ^ Mär 29 05:52:53 phoscon python3[668]: SyntaxError: invalid syntax Mär 29 05:52:53 phoscon systemd[1]: system_sensors.service: Main process exited, code=exited, status=1/FAILURE Mär 29 05:52:53 phoscon systemd[1]: system_sensors.service: Unit entered failed state. Mär 29 05:52:53 phoscon systemd[1]: system_sensors.service: Failed with result 'exit-code'.
Sorry for the late reply which version of python are you using? This is a different error then the network error: SyntaxError: invalid syntax But this is good syntax so my guess is that u use an old version of python
I just added in ExecStartPre=/bin/sleep 60
and everything appears to be working now. It looks like it was trying to connect before my mqtt server was up
So I added a restart to the service file and set it to restart 5 times with a 60 second delay. This seems to have resolved my issue.
What seemed to be happening is the service would start on network but that was before mqtt since mqtt booted with docker/home assistant. Adding the condition on failure to my restart condition seems to have sorted this out. Currently I haven't seen it need more than one restart.
I can't get anything to work unless I manually start the script (python3 src/system_sensors.py src/settings.yaml)
I've tried reinstalling the requirements because it mentioned rpi_bad_power so I thought it may be a dependancy issue.
Here's what happens as well as my troubleshooting efforts:
Raspberry Pi 4 (4GB) Latest Raspbian