Simple Python script for sending MacBook battery data to Domoticz

Python and python framework

Moderator: leecollings

Post Reply
jkaeber
Posts: 1
Joined: Friday 07 July 2017 10:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8063
Location: Berlin, DE
Contact:

Simple Python script for sending MacBook battery data to Domoticz

Post by jkaeber »

Hi,

i recently started exploring SmartHome stuff. After buying a Pi 3, an Aeon stick and a Fibaro wall plug and playing around with those, it is now time for some real project:

The idea is to control power usage of my MacBook using domoticz. MacOS provides a command line utility called "pmset" for reporting (and setting) some power management data. As a first step, i developed the attached script, which updates a text widget on the domoticz server using battery data from my Mac. The script is running on the Mac and receives PM data from the pmset command as follows:

Code: Select all

pmset -g pslog|ReportBattery.py
The pmset command is smart in that it only produces output when there is something new to report. So no more polling or interval guessing. On the domoticz side we only have to create a (virtual) text device for displaying the PM data. After editing the server name and the widget id in the script, we can start the above pipe on the Mac and watch its battery data being displayed by domoticz running on the Pi.

I do not yet fully understand the problem of creating and running python plugins on the Pi (bogus library configuration along the line Domoticz->Python3->Boost and maybe more). Until then, i will use domoticz in mixed-manual-automatic mode: monitoring the text device and from time to time (when nobody is expecting it ;)) clicking on the wall plug icon in domoticz. Learning one more programming language (i.e. LUA) for just this purpose is not an option. Python rules!

Have fun!
Achim K.
Attachments
ReportBattery.py.zip
(897 Bytes) Downloaded 66 times
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 1 guest