The Ipad charger is connected to a zwave switch, controlled by a timer. This timer would switch on the charger every night. Since the Ipad is dedicated for domoticz, it doesn’t use much power, which made the charging every night pretty obsolete. And thus the wish for Ipad battery level depended switching was born.
I searched the internet several times for a way to export the Ipad battery level to the raspberry pi several times, but without any knowledge of iOS apps there only appeared to be a way trough jailbreaking the Ipad. Unfortunately I could not do this, because my version of iOS was not able to be jailbroken. So I decided to wait until my version (iOS 8.3) could be jailbroken.
Last week I checked again and installed a jailbreak for the Ipad.
Below are the steps I performed to achieve automatic charging:
- This is the jailbreak I used. http://www.taig.com/en/tutorial.html
- UNCHECK the “3K assistance” checkbox
- My Ipad restarted several times, without any progress showing. Please be patient.
- Once jailbroken, use the search option in Cydia to find and install:
- iOS terminal
- bash server
- APT 0.6 Transitional
- APT 0.7 Strict
iOS terminal ensures you can make a SSH connection between your Pi and Ipad. The standard username is root, password alpine.
- create a trusted SSH key, so the script below can use SSH without a password. I used these instructions: http://sshmenu.sourceforge.net/articles/key-setup.html
- create a .txt file on your pi. this will be used to temporarily store data from the Ipad.
- Make sure the file has the correct user access level (chmod 777)
- Note the path and name of this file.
- create a dummy switch in domoticz. Select “percentage” for type.
- Note the IDX
- create a script with the following code:
Code: Select all
#!/bin/bash
SERVER="IP:PORT" # Your Domoticz IP and Port
IPAD="IP" # Your Ipad IP
BATIDX="IDX" # Your IDX-number for the dummy switch you created
correction="0" # Correction value IF needed. negative value for substraction is allowed
TMPFILE="FILE" # Your Temp file location (e.g. /home/pi/filename.txt
ssh root@$IPAD "pmset -g ps" > $TMPFILE
batlevel=$(cat $TMPFILE |awk 'NR==2{print $2}' |tr -d '%' |tr -d ';')
echo "Retrieved Value = $batlevel %"
correctedlevel=$(awk "BEGIN {print $batlevel+$correction; exit}")
echo "Corrected Value = $correctedlevel %"
curl -s "http://$SERVER/json.htm?type=command¶m=udevice&idx=$BATIDX&nvalue=0&svalue=$correctedlevel"
- create a rule for execution of the script with the interval of your choice (crontab -e)
- Test the script (./scriptname from your script folder)
If everything is ok, the domoticz dummy switch is now updated. if the level is not the same is shown on your Ipad screen, you can enter a correction value for it in the script.
I chose not to use a script for linking the battery level to the charger switch. I used the domoticz event system for the time being.
Feel free to create a script for this or adjust mine to your needs.
Also, for Mac users:
The command used in the script to retrieve battery status (pmset -g ps) also works from the terminal window on your mac. I think you could use the same script to charge your mac.
If you run into trouble, leave a comment, me or somebody else might be able to help.
I know there are millions of ways of achieving the same result. this option works fine for me, so please don't comment on things I messed up, create your own solution

Thanks to JacquesMulders. Without him the script would have taken much longer to make.
