Python code to get system monitor information from your other Pi's in Home Assistant

Monitoring Remote Raspberry PI

Using the Home Assistant REST API (https://developers.home-assistant.io/docs/en/external_api_rest.html) to provide a python script to install on your other Raspberry Pi’s that monitors and publishes data similar to the systemmonitor platform back to your HA instance.

I find this method much more robust and way less coding than MQTT or other methods posted. The HA Rest API makes it easy.

Sensors are automatically created once the api is invoked.

Check out the code https://github.com/petergridge/ha_monitor

9 Likes

Looks interesting. I have a pi zero that for what ever reason I’m not monitoring, so I might give this a go over the weekend.

I have updated the scripts with better exception handling and debug information. It is now more resilient to restarts of the Home Assistant server.

I’m unable to get this to work.

I had to install pip on my Pi Zero, but then had to manually install requests and psutil. Not sure why. But then when I run the script, it seems to just hang. I left it for a few minutes, and nothing. No error on screen, just nothing.

Set the debug attribute to 1 this will force messages to your console.

Also check in HA if there are any sensors created for your host.

I have this running on a PI3 no problems

one more thing, use CTRL-C to terminate the script

[quote=“petergridge, post:5, topic:169675, full:true”]
Set the debug attribute to 1 this will force messages to your console.

Set the debug attribute to 1 this will force messages to your console.

Also check in HA if there are any sensors created for your host.

I have this running on a PI3 no problems

All good terminating the script. That’s all I could do.

I ran in debug mode, and get the following

requests.exceptions.ConnectionError
requests.exceptions.ConnectionError
requests.exceptions.ConnectionError
requests.exceptions.ConnectionError
Resend All Sensors

Decided to look at my options again. I changed it from using the local IP address and port, to my domain name and it working now. Odd, it wouldn’t work with the local IP address, so not sure what is happening there.

Anyway, working now, and will update as long as my internet is working.

That’s odd, can you ping from the Pi2 to the HA box?

Yep. Kinda odd. I’ll have a look at it later. Maybe I miss-typed something.

Thanks @petergridge! I really liked your approach, very clean and effective!