Monitoring a PVE Machine’s Battery Status

I’ve used PVE (Proxmox Virtual Environment) for a while now for Node-RED, MQTT Broker, Emoncms etc and it really is bullet proof. My preferred setup is on an old laptop so this setup has a built-in UPS (its battery). I’ve thought for a while that I really should cycle the battery to enhance how long it runs and preserve the lifespan.

Needing to get a new laptop so I can upgrade the old system to V8, I decided to work out the best way to monitor the battery. I have installed Netdata and then accessed the Battery chart via the API previously and while I do Install Netdata, this means of battery monitoring was not great. ACPI provides more data including a status value.

First step, install acpi and a parser called jc that I have used in the past to take the acpi data and transform it into a JSON output. Both installed via apt. Test it.

Now for the easy part and although I knew how, I used Co-Pilot to generate the script and the systemd unit to run it.

Shell script

systemd Unit

Reload the daemon, enable the unit (so it auto starts at boot) and start it.

Adding this information into a Sensor in HomeAssistant, plugging in a Smart Switch and creating the automation to cycle the battery will be just as easy.

Job done.

[edit]

If only. The HA part turned out to be a bit of a PITA. The MQTT sensor refused to process the key named state. Modified the script above to change that key to mode.

 

Facebooktwitterby feather
This entry was posted in Technical - General. Bookmark the permalink.

Leave a Reply