Windows 10 Laptop Battery Sesnor

I want to collect the battery level of my laptop at regular intervals (5 mins) and when it is 100% i want to ,make an automation to switch off my Sonoff S20 which is charging it - and vice versa when it is 10%.

How can i create a sensor to do this? My is on a Rasp Pi3


you can write a powershell script to do this that run on the laptop.
I might do the same, can share when finnished if you don’t write/find anything until then.

ok. i have googled that and it seems ok so far but how do you extract that from the laptop to hass?

I think like this:

Also, this is how you get battery status in %:
(Get-WmiObject win32_battery).EstimatedChargeRemaining

I googled it but its beyond me. Please share if you create it.


I will updates you as fast as it is done :slight_smile: Just have to understand this new Home-Assistant API authentication first.
My plan are to make a powershell script to send all kinds of info from the PC to Home-Assistant, like cpu load, ram usage, drivespace and so on.

1 Like

did you ever do this mate?

No, It had not gotten any priority yet …
I made this:

But as for your issue I just find this project that I think can help:

1 Like

thank you!

Sadly, this just doesn’t seem to want to report the battery status for me.

It’s worth another look. I managed to get it working by stopping the windows service after I updated the config file and then starting the service again.

Refreshed mosquito broker too and all the entities showed up.
The battery status did initally not report correctly. I just refreshed home assistant and then all the info came up.

IOT Link can send laptop batter status with the addon & MQTT.

It seems that project is somewhat abandoned and its README now recommends using Hass.Agent instead.