https://github.com/shonp40/ios-rest-battery
A REST API for reporting the battery percentage of jailbroken iOS devices
https://github.com/shonp40/ios-rest-battery
home-assistant jailbreak
Last synced: about 2 months ago
JSON representation
A REST API for reporting the battery percentage of jailbroken iOS devices
- Host: GitHub
- URL: https://github.com/shonp40/ios-rest-battery
- Owner: ShonP40
- License: cc0-1.0
- Created: 2023-03-27T14:54:54.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2026-02-16T18:01:37.000Z (4 months ago)
- Last Synced: 2026-02-17T00:52:49.244Z (4 months ago)
- Topics: home-assistant, jailbreak
- Language: Python
- Homepage: https://shon.codes
- Size: 65.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iOS REST Battery
A REST API for reporting the battery percentage of jailbroken iOS devices
## Installation
### Requirements
- Jailbroken iOS device
- Terminal/SSH access to your iOS device
- (Recommended) A tweak that keeps Wi-Fi on even when the device is locked (like `iNoSleep`)
- Git CLI (`apt-get install git`) on your iOS device
- Awk (`apt-get install gawk`) on your iOS device
- Screen (`apt-get install screen`) on your iOS device
- Python 2.5.1 (`apt-get install python`) (32-bit) / Python 3.9.9 (`apt-get install python3`) (64-bit) on your iOS device
## Setup (32-bit)
1. Meet the requirements
2. Follow the instructions [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) to generate an SSH key on your iOS device to be able to access GitHub
3. Run `cat /path/to/.pub` and copy its contents to this [GitHub](https://github.com/settings/ssh/new) page
4. Clone this repository to your iOS device (`git clone git@github.com:ShonP40/iOS-REST-Battery.git`)
5. Clone the `SimpleJSON` repository to your iOS device (`git clone git@github.com:simplejson/simplejson.git`)
6. cd into the `simplejson` directory
7. Install the `simplejson` package using `python setup.py install`
8. cd into the `iOS-REST-Battery` directory
9. Install `batterydata` using `dpkg -i batterydata-arm32.deb`
10. Start the script by running `python battery-arm32.py` to test it out
11. Press `Ctrl + C` to stop the script
## Setup (64-bit)
1. Meet the requirements
2. Clone this repository to your iOS device (`git clone https://github.com/ShonP40/iOS-REST-Battery`)
3. cd into the `iOS-REST-Battery` directory
4. Install `batterydata` using `dpkg -i batterydata-arm64-rootfull.deb` or `dpkg -i batterydata-arm64-rootless.deb` (depending on your setup)
5. Start the script by running `python3 battery-arm64-rootfull.py` or `python3 battery-arm64-rootless.py` (depending on your setup) to test it out
6. Press `Ctrl + C` to stop the script
## Running (You will need to do this every time you reboot your device)
1. cd into the `iOS-REST-Battery` directory
2. Create a new screen session by running `screen -S battery`
3. Start the script
4. Detach from the screen session by pressing `Ctrl + A + D`
## Updating
1. Reattach to the screen session by running `screen -r battery`
2. Press `Ctrl + C` to stop the script
3. Run `git pull`
4. Start the script again
5. Detach from the screen session by pressing `Ctrl + A + D`
## Usage
If you are using this script to display the battery status of your iOS device on Home Assistant, you can use the following configuration as an example:
```yaml
sensor:
- platform: rest
name: iPad battery status
unique_id: ipad_battery_status
resource: http://:8000/status
method: GET
value_template: "{{ value_json.Battery }}"
unit_of_measurement: "%"
device_class: battery
json_attributes:
- Battery
- Battery status
timeout: 60
```