Remote RPI system monitor

No, show the following.


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'apt'

After some searching I think it’s because your python3.8 is not the standard python interpreter of your system(the python3.5 is) So I think there are 2 options:

  1. Set python3.8 as the standard interpreter
  2. you could try following steps(not guaranteed to be working):
git clone https://salsa.debian.org/apt-team/python-apt && cd python-apt
git checkout 1.8.4.1 # check versions via git tag
python3.8 setup.py build
python3.8 setup.py install

Thanks for following up, unfortunately, the build throws an error as well.

pi@raspberry:~/python-apt $ python3.8 setup.py build
W: [python3.8] DistUtilsExtra import error.
W: [python3.8] Sphinx import error.
running build
running build_py
creating build/lib.linux-armv7l-3.8
creating build/lib.linux-armv7l-3.8/apt
copying apt/__init__.py -> build/lib.linux-armv7l-3.8/apt
copying apt/debfile.py -> build/lib.linux-armv7l-3.8/apt
copying apt/auth.py -> build/lib.linux-armv7l-3.8/apt
copying apt/cache.py -> build/lib.linux-armv7l-3.8/apt
copying apt/cdrom.py -> build/lib.linux-armv7l-3.8/apt
copying apt/utils.py -> build/lib.linux-armv7l-3.8/apt
copying apt/package.py -> build/lib.linux-armv7l-3.8/apt
creating build/lib.linux-armv7l-3.8/apt/progress
copying apt/progress/base.py -> build/lib.linux-armv7l-3.8/apt/progress
copying apt/progress/__init__.py -> build/lib.linux-armv7l-3.8/apt/progress
copying apt/progress/text.py -> build/lib.linux-armv7l-3.8/apt/progress
creating build/lib.linux-armv7l-3.8/aptsources
copying aptsources/__init__.py -> build/lib.linux-armv7l-3.8/aptsources
copying aptsources/distinfo.py -> build/lib.linux-armv7l-3.8/aptsources
copying aptsources/sourceslist.py -> build/lib.linux-armv7l-3.8/aptsources
copying aptsources/distro.py -> build/lib.linux-armv7l-3.8/aptsources
running build_ext
building 'apt_pkg' extension
creating build/temp.linux-armv7l-3.8
creating build/temp.linux-armv7l-3.8/python
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.8 -c python/acquire.cc -o build/temp.linux-armv7l-3.8/python/acquire.o -std=c++11 -Wno-write-strings -DAPT_8_CLEANER_HEADERS -DAPT_9_CLEANER_HEADERS -DAPT_10_CLEANER_HEADERS
In file included from python/acquire.cc:26:0:
python/apt_pkgmodule.h:14:28: fatal error: apt-pkg/hashes.h: No such file or directory
 #include <apt-pkg/hashes.h>
                            ^
compilation terminated.
error: command 'gcc' failed with exit status 1

I think it is now, I re-installed Python yesterday.

pi@raspberry:~ $ /usr/bin/python3 --version
Python 3.8.5

pi@raspberry:~ $ python -V
Python 3.8.5

pi@raspberry:~ $ python3 -V
Python 3.8.5

pi@raspberry:~ $ python
Python 3.8.5 (default, Nov  4 2020, 11:18:06)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.

But the following confuses me

pi@raspberry:~ $ which python3
/usr/local/bin/python3

And does it work now?

No, still have an issue with python-apt.

> python3-apt is already the newest version (1.1.0~beta5).

> /var/lib/dpkg/info/python-apt.postinst: 6: /var/lib/dpkg/info/python-apt.postinst: pycompile: not found

> Errors were encountered while processing:
> python-apt

Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-apt is already the newest version (1.1.0~beta5).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up python-apt (1.1.0~beta5) ...
/var/lib/dpkg/info/python-apt.postinst: 6: /var/lib/dpkg/info/python-apt.postinst: pycompile: not found
dpkg: error processing package python-apt (--configure):
 subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
 python-apt
E: Sub-process /usr/bin/dpkg returned an error code (1)

Hmm then I really don’t know how to fix this.
I think your best option right now is to disable the updates in the settings file.
I’m sorry I couldn’t help you any further.

Thanks for all your help, ended up torching it and starting over, all good now.

Unfortunatelly I get on Raspberry PI 4:
after 6. python3 src/system_sensors.py src/settings.yaml

Traceback (most recent call last):
  File "src/system_sensors.py", line 416, in <module>
    mqttClient.connect(settings["mqtt"]["hostname"], settings["mqtt"]["port"])
  File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 937, in connect
    return self.reconnect()
  File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1115, in reconnect
    return self._send_connect(self._keepalive)
  File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 2633, in _send_connect
    remaining_length += 2 + len(self._password)
TypeError: object of type 'int' has no len()

any idea how I fix that pls?

Did you set a username but not a password?

mqtt:
  hostname: 127.0.0.1
  port: 1883
  user: mqtt
  password: 1234
deviceName: test
client_id: test
timezone: Europe/Brussels
update_interval: 60 #Defaults to 60
check_wifi_strength: true
check_available_updates: true
external_drives:
  Drive1: /boot/

Does your password exists of only numeric values if so could you put single quotes around the password and try again?

Did some adjustment. HA did not discovered it yet but we are on good way. Thank you!!!

mqtt:
  hostname: '172.17.0.1'
  port: 1883
  user: 'mqtt'
  password: '`1234'
deviceName: test
client_id: test
timezone: Europe/Brussels
update_interval: 60
check_wifi_strength: true
check_available_updates: true
external_drives:
  Drive1: /boot/

Hi,

This is my first time trying to utilize mqtt for sensors. I know Mosquitto is running right as it’s configured and working with OpenZWave.

My RPI appears to be running correctly and the log in Mosquitto shows it connects but I never get any sensors. Any advice on where to look to resolve this.

1605812363: New connection from 192.168.1.XXX on port 1883.
[INFO] found XXXX-mqtt on local database
1605812363: New client connected from 192.168.1.XXX as rpi4-XXXX (p2, c1, k60, u'XXXX-mqtt').

Thanks in advance!

Digging in a little more, I went to Integrations > MQTT Broker and listened to a topic of # to see everything. My RPI was seen in there, but it’s not adding it to Home Assistant as a device.

Did you enable the following in Home Assistant: https://www.home-assistant.io/integrations/discovery/

Yup, it has no problem automatically adding any zwave devices as I add them to the network.

Here is the current state of the system-sensors

{"temperature": 39.0,"disk_use": 17.2,"memory_use": 9.5,"cpu_usage": 0.8,"swap_usage": 0.0,"power_status": "False","last_boot": "2020-11-03T16:31:38-05:00","last_message": "2020-11-20T07:59:54.991770-05:00", "updates": 0, "wifi_strength": -58}

Do you have any errors in your log?
Does the following topics exist in mqtt:

  • homeassistant/sensor/{name}/{name}Temp
  • homeassistant/sensor/{name}/{name}DiskUse
  • homeassistant/sensor/{name}/{name}MemoryUse
  • homeassistant/sensor/{name}/{name}CpuUsage
  • homeassistant/sensor/{name}/{name}SwapUsage
  • homeassistant/sensor/{name}/{name}PowerStatus
  • homeassistant/sensor/{name}/{name}LastBoot
  • homeassistant/sensor/{name}/{name}LastMessage
  • homeassistant/sensor/{name}/{name}Updates
  • homeassistant/sensor/{name}/{name}WifiStrength

All 10 topics exist:
Screenshot 2020-11-20 095440|690x474

I have this one error message:

Source: /usr/local/lib/python3.8/site-packages/aiohue/util.py:22
First occurred: 8:51:12 AM (9 occurrences)
Last logged: 8:51:12 AM

Received unexpected bridge id: 93eadbeef13

Don’t know if it’s a problem but could you try to change the name to one without a space?