Remote RPI system monitor

Nothing, I experience the same. Have raised an issue here: https://github.com/Sennevds/system_sensors/issues/38

Thanks, at least I now know that I am not alone ;). I just came back to HA after a long hiatus and I am still a newbie!

For the record, I have the same problem with my Ecobee Thermostats

I’ve updated the code could you try again and see if it’s fixed now

Just updated the issue with my findings. Unfortunately not fixed yet.

Thanks for creating this @Sennevds. I cloned the repo so that I could modify the state topic prefixes to fit in with my local scheme (might it be worth considering having this as a config item rather than hard-coded?)

I’ve got it working, to the extent that the entities are registered on HA and appear in the UI, and HA is receiving the state updates. However, the entity states are not being updated.

The fact that HA is receiving the state updates indicates that “state_topic” was correct in the config message, and that the device is sending on the correct state_topic, so that seems to cover the only changes I made to the code.

Any ideas? Here’s some log info

2020-06-26 10:24:29 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/dellups/dellupsTemp/config (retained): b'{"device_class":"temperature","name":"dellupsTemperature","state_topic":"tel/19c/dellups/state","unit_of_measurement":"\xc2\xb0C","value_template":"{{ value_json.temperature}}","unique_id":"dellups_sensor_temperature","device":{"identifiers":["dellups_sensor"],"name":"dellupsSensors","model":"RPI dellups","manufacturer":"RPI"}, "icon":"mdi:thermometer"}'
2020-06-26 10:24:29 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/dellups/dellupsDiskUse/config (retained): b'{"name":"dellupsDiskUse","state_topic":"tel/19c/dellups/state","unit_of_measurement":"%","value_template":"{{ value_json.disk_use}}","unique_id":"dellups_sensor_disk_use","device":{"identifiers":["dellups_sensor"],"name":"dellupsSensors","model":"RPI dellups","manufacturer":"RPI"}, "icon":"mdi:microsd"}'
2020-06-26 10:24:29 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/dellups/dellupsMemoryUse/config (retained): b'{"name":"dellupsMemoryUse","state_topic":"tel/19c/dellups/state","unit_of_measurement":"%","value_template":"{{ value_json.memory_use}}","unique_id":"dellups_sensor_memory_use","device":{"identifiers":["dellups_sensor"],"name":"dellupsSensors","model":"RPI dellups","manufacturer":"RPI"}, "icon":"mdi:memory"}'
2020-06-26 10:24:29 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/dellups/dellupsCpuUsage/config (retained): b'{"name":"dellupsCpuUsage","state_topic":"tel/19c/dellups/state","unit_of_measurement":"%","value_template":"{{ value_json.cpu_usage}}","unique_id":"dellups_sensor_cpu_usage","device":{"identifiers":["dellups_sensor"],"name":"dellupsSensors","model":"RPI dellups","manufacturer":"RPI"}, "icon":"mdi:memory"}'
2020-06-26 10:24:29 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/dellups/dellupsSwapUsage/config (retained): b'{"name":"dellupsSwapUsage","state_topic":"tel/19c/dellups/state","unit_of_measurement":"%","value_template":"{{ value_json.swap_usage}}","unique_id":"dellups_sensor_swap_usage","device":{"identifiers":["dellups_sensor"],"name":"dellupsSensors","model":"RPI dellups","manufacturer":"RPI"}, "icon":"mdi:harddisk"}'
2020-06-26 10:24:29 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/dellups/dellupsPowerStatus/config (retained): b'{"name":"dellupsPowerStatus","state_topic":"tel/19c/dellups/state","value_template":"{{ value_json.power_status}}","unique_id":"dellups_sensor_power_status","device":{"identifiers":["dellups_sensor"],"name":"dellupsSensors","model":"RPI dellups","manufacturer":"RPI"}, "icon":"mdi:power-plug"}'
2020-06-26 10:24:29 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/dellups/dellupsLastBoot/config (retained): b'{"device_class":"timestamp","name":"dellupsLastBoot","state_topic":"tel/19c/dellups/state","value_template":"{{ value_json.last_boot}}","unique_id":"dellups_sensor_last_boot","device":{"identifiers":["dellups_sensor"],"name":"dellupsSensors","model":"RPI dellups","manufacturer":"RPI"}, "icon":"mdi:clock"}'
2020-06-26 10:24:29 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/dellups/dellupsLastMessage/config (retained): b'{"name":"dellupsLastMessage","state_topic":"tel/19c/dellups/state","value_template":"{{ value_json.updates}}","unique_id":"dellups_sensor_last_message","device":{"identifiers":["dellups_sensor"],"name":"dellupsSensors","model":"RPI dellups","manufacturer":"RPI"}, "icon":"mdi:clock-check"}'
2020-06-26 10:24:29 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/dellups/dellupsUpdates/config (retained): b'{"name":"dellupsUpdates","state_topic":"tel/19c/dellups/state","value_template":"{{ value_json.updates}}","unique_id":"dellups_sensor_updates","device":{"identifiers":["dellups_sensor"],"name":"dellupsSensors","model":"RPI dellups","manufacturer":"RPI"}, "icon":"mdi:cellphone-arrow-down"}'
2020-06-26 10:24:29 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/dellups/dellupsWifiStrength/config (retained): b'{"device_class":"signal_strength","name":"dellupsWifiStrength","state_topic":"tel/19c/dellups/state","unit_of_measurement":"dBm","value_template":"{{ value_json.wifi_strength}}","unique_id":"dellups_sensor_wifi_strength","device":{"identifiers":["dellups_sensor"],"name":"dellupsSensors","model":"RPI dellups","manufacturer":"RPI"}}'
2020-06-26 10:24:29 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/dellups/dellupsDiskUseDrive1/config (retained): b'{"name":"dellupsDiskUseDrive1","state_topic":"tel/19c/dellups/state","unit_of_measurement":"%","value_template":"{{ value_json.disk_use_drive1}}","unique_id":"dellups_sensor_disk_use_drive1","device":{"identifiers":["dellups_sensor"],"name":"dellupsSensors","model":"RPI dellups","manufacturer":"RPI"}, "icon":"mdi:harddisk"}'
2020-06-26 10:25:15 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tel/19c/dellups/state
2020-06-26 10:25:15 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tel/19c/dellups/state
2020-06-26 10:25:15 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tel/19c/dellups/state
2020-06-26 10:25:15 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tel/19c/dellups/state
2020-06-26 10:25:15 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tel/19c/dellups/state
2020-06-26 10:25:15 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tel/19c/dellups/state
2020-06-26 10:25:15 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tel/19c/dellups/state
2020-06-26 10:25:16 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tel/19c/dellups/state
2020-06-26 10:25:16 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tel/19c/dellups/state
2020-06-26 10:25:16 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tel/19c/dellups/state
2020-06-26 10:25:16 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to tel/19c/dellups/state
...
2020-06-26 10:26:10 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on tel/19c/dellups/state: b'{"temperature": 41.2, "disk_use": 19.8, "memory_use": 21.6, "cpu_usage": 2.3, "swap_usage": 20.0, "power_status": "Everything is working as intended", "last_boot": "2020-05-18T11:54:52+01:00", "last_message": "Fri Jun 26 10:26:06 2020", "updates": 11, "wifi_strength": , "disk_use_drive1": 52.9}'

Hi,

Sorry for the late answer. There’s still a little bug in my code. Could you try to disable the option for wifi strength? It has a empty value which gives an invalid json value:

{
    "temperature": 41.2,
    "disk_use": 19.8,
    "memory_use": 21.6,
    "cpu_usage": 2.3,
    "swap_usage": 20.0,
    "power_status": "Everything is working as intended",
    "last_boot": "2020-05-18T11:54:52+01:00",
    "last_message": "Fri Jun 26 10:26:06 2020",
    "updates": 11,
    "wifi_strength": ,
    "disk_use_drive1": 52.9
}

Cheers, @Sennevds. That’s cured it.

Thanks.

Just installed this tonight. Seems to be working great so far. I went from hovering around 5-6% CPU usage with glances running in docker to 2% with system_sensors. I’ll miss the ability to restart a compete stack on a fresh install of pi os, but whatever. I’d rather the 4% back.

OP, thank you so much for sharing this!

I am getting an error when trying to run it. I have no idea what that means. The only settings I have left out is the client_id. I do not know what to add to that line.

usage: system_sensors.py [-h] settings
system_sensors.py: error: the following arguments are required: settings

Update: My bad. I didn’t pay close attention to the run command. Forgot to add the path to settings.yaml. Working now.

python3 system_sensors.py /path/to/settings.yaml

One of my rpi3 is unable to install rpi_bad_power==0.0.3 in the requriement file. Error is

Collecting rpi_bad_power==0.0.3
  Could not find a version that satisfies the requirement rpi_bad_power==0.0.3 (from versions: )
No matching distribution found for rpi_bad_power==0.0.3

Update: Figured out the problem. Apparently, this rpi was running Python3.5.3. The script needs 3.6+. Upgraded to 3.7 manually and all is good now.

Every time my HassOS reboots or MQTT restarts, I stop receiving data from system_sensors. Is there a way to restart the script on the pi or configure something in HA to re-establish connection to the system_sensors service?

Same issue here.

Hi @apop and @moto2000 do you got the latest version? I’ve updated the repo but forgot to create a new release!

Hey, I’m stuck at step 6 6. python3 system_sensors.py /path/to/settings.yaml, what is this step?

python3: can't open file 'system_sensors.py': [Errno 2] No such file or directory

system_sensors.service: Failed with result 'exit-code'.

It’s just to execute the python script. Are you in the src folder?
You need to execute that command in the src folder and change the ‘/path/to/settings.yaml’ to the location where your settings.yaml is(normally in the same folder as system_sensors.py)

:+1: Amazing, works great.

Any chance of getting the GPIO state?, I’m using GPIO to control the fan based on temp, and would like to know when it’s active.

You can use this for gpio (and more) https://github.com/flyte/pi-mqtt-gpio

2 Likes

Any idea ho to rectify the following?

  Could not find a version that satisfies the requirement rpi_bad_power==0.0.3 (from -r requirements.txt (line 5)) (from versions: )
No matching distribution found for rpi_bad_power==0.0.3 (from -r requirements.txt (line 5))

● 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 2020-11-03 11:38:34 EST; 3min 13s ago
  Process: 24379 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: 24379 (code=exited, status=1/FAILURE)
      CPU: 178ms

Nov 03 11:38:34 pihole systemd[1]: Started System Sensor service.
Nov 03 11:38:34 pihole python3[24379]:   File "/home/pi/system_sensors/src/system_sensors.py", line 95
Nov 03 11:38:34 pihole python3[24379]:     print (f"Message received: {message.payload.decode()}"  )
Nov 03 11:38:34 pihole python3[24379]:                                                          ^
Nov 03 11:38:34 pihole python3[24379]: SyntaxError: invalid syntax
Nov 03 11:38:34 pihole systemd[1]: system_sensors.service: Main process exited, code=exited, status=1/FAILURE
Nov 03 11:38:34 pihole systemd[1]: system_sensors.service: Unit entered failed state.
Nov 03 11:38:34 pihole systemd[1]: system_sensors.service: Failed with result 'exit-code'.

Or you running this on a Pi or a different system?

Any idea ho to rectify the following?