Skip to main content

A library to access Android devices which run JPI

Project description

pyJPI - An asynchronous Python module to interact with Android devices running JPI

Maintenance Latest release Latest commit PyPI version

Code coverage Max cyclomatic complexity

Overview

pyJPI is an asynchronous Python library designed to programmatically interact with Android devices running JPI.

This library is a key component for a core integration with Home Assistant.

More details on the integration can be found on the JPI page.

Features

  • Asynchronous operations are built with ``aiohttp` for non-blocking I/O, which is perfect for integrations and background tasks.
  • API: battInfo
  • API: get
  • API: getDeviceName

Installation

You can install pyJPI from PyPI using pip:

pip install pyjpi

Usage

Here is a more detailed example of how to use the library to connect, fetch status, and perform an action on an Android device running JPI.

import aiohttp
from pyjpi import jpiInit

async def main():
    """Main function to demonstrate library usage."""
    # Create an aiohttp session with SSL verification disabled.
    # Be cautious with this setting; it's useful for self-signed certificates
    # but not recommended for production environments without proper validation.
    session = aiohttp.ClientSession( connector=aiohttp.TCPConnector( verify_ssl=False ))

    # Get a handle on the pyJPI library.
    handle = await jpiInit( session )

    # Have an URL somewhere.
    url = "http://myhost.example.com:8080"

    # Then just has to call the library functions.
    try:
        res = await handle.get( url )
        # returns a dict { resp: ClientResponse, text: str } or False
        res = await handle.getDeviceName( url )
        # returns the device name as set by the manufacturer (a single string) or False
        res = await handle.battInfo( url )
        # returns a dict { level: integer, charging: bool, power: bool }


if __name__ == "__main__":
    main()

Available functions

  • async jpiInit( session: aiohttp.ClientSession ) -> JPILibrary:

Initializes the library.

Returns a handle on it.

Available classes

  • JPILibrary:

The class which manages the devices accesses.

Available JPILibrary methods

  • async get( url: str) -> dict:

Runs a HTTP GET method on the specified URL.

Returns a dict with:

    resp: the `aiohttp.ClientResponse`
    text: the resp.text() content
  • async getDeviceName( url: str) -> str:

Runs a HTTP GET method on f"{url}?action=getDeviceName" url.

Returns a string which contains the device name as set by the manufacturer.

  • async battInfo( url: str) -> dict:

Runs a HTTP GET method on on f"{url}?action=battInfo" url.

Returns a dict with:

    level: an integer with the current battery level in %
    charging: a boolean which says if the battery is currently charging
    power: a boolean which says if the power is on on the device.

Contributing

We welcome contributions as well as additional codeowners to pyjpi.

Issues & help

In case of support or error, please report your issue request to our Issues tracker.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyjpi-0.1.23.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyjpi-0.1.23-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file pyjpi-0.1.23.tar.gz.

File metadata

  • Download URL: pyjpi-0.1.23.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.19

File hashes

Hashes for pyjpi-0.1.23.tar.gz
Algorithm Hash digest
SHA256 225dd7c600fe91a1ffdd7ac9ee755f1b3eefaeeb3022a28fbf3cb46a624069ee
MD5 f2ccb1a2c967a9aefd128e139015a995
BLAKE2b-256 28be88e67dcf84044be79a35942352e5958fb8e647f09d17d5ab8c2086d56a78

See more details on using hashes here.

File details

Details for the file pyjpi-0.1.23-py3-none-any.whl.

File metadata

  • Download URL: pyjpi-0.1.23-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.19

File hashes

Hashes for pyjpi-0.1.23-py3-none-any.whl
Algorithm Hash digest
SHA256 44ac8b8d1258d472af6c0af34385a737e97f3f1d964d001c0f40efe66004469a
MD5 b765593404bf68a37f3eeef185cdd4f2
BLAKE2b-256 db3d14b414c83ca2a233f3ecca917290e2cf6984ef0eda609dbc53e6083089d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page