Skip to main content

An interface to the Homematic JSON-API

Project description

PJHomematic

PJHomematic is an abstarction of the Homematic JSON-API.

The package interfaces on different depths to the homematic API

  • High level API
    • Homematic - The API classes and methods are created dynamically to be called directly
  • Low level API
    • hmrpc - An interface to the Homematic JSON-API with session handling
    • jsonrpc - An implementation of the JSON-RPC protocol

The package is tested against the recent RaspberryMatic version only (currently 3.71). If you find out it is working great with some other platforms please drop me a message or create an issue if you experience problems.

Installation

The installation requires a python installation (>= 3.9).

# python3 -m pip install PJHomematic

If you want to be able to export the device list as Excel file via homematic.list_devices (see below) install the extra dependencies (openpyxl)

# python3 -m pip install PJHomematic[extra]

Usage

To retreive a list of all devices (columns: Name, Type, Address, Subsection, Room, Level) you should run

# python3 -m homematic.list_devices IP-ADDRESS USERNAME PASSWORD

If openpyxl is available the list is written to an excel file. Otherwise it is printed tab separated to the console.

API usage

The following chapters describing the usage of the different API level for the same job.

The JSON-API documentation can be retrieved via

from pprint import pp
from homematic import Homematic

hm = Homematic('http://10.1.1.1', username='user', password='pwd')
pp(hm.api_doc)
hm.logout()

High level API - Homematic class

Example of access via the high level API

from homematic import Homematic

hm = Homematic('http://10.1.1.1', username='user', password='pwd')
print(hm.system.listMethods())
hm.logout()

Low level API - hmrpc module

Example of access via the low level API

from homematic import hmrpc

hmrc = hmrpc.HMRPCClient('http://10.1.1.1', username='user', password='pwd')
print(hmrc.call('system.listMethods'))
hmrc.logout()

Low level API - jsonrpc module

Example of access via the low level API with manual session management

from homematic import jsonrpc

jrc = jsonrpc.JSONRPCClient('http://10.1.1.1/api/homematic.cgi')
session = jrc.call('Session.login', username='user', password='pwd')
print(jrc.call('system.listMethods'))
jrc.call('Session.logout', _session_id_=session)

Problems with https

If you expierence problems with https consider to use a proper CA signed certifcate instead of the default selfsigned cert.

If you are using windows you probably have to install python-certifi-win32 to use your local certificate store

If you need support do not hesitate to ask.

Source Code

The source code is available at GitHub

Copyright

PJHomematic © 2023 by Andreas Schawo is licensed under CC BY-SA 4.0

Homematic and Homematic IP are trademarks of eQ-3 AG

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

PJHomematic-0.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

PJHomematic-0.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file PJHomematic-0.1.tar.gz.

File metadata

  • Download URL: PJHomematic-0.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for PJHomematic-0.1.tar.gz
Algorithm Hash digest
SHA256 d6cf21b775d5957dc5f37c57a4c4b7c14ec40c3e714339639f02744e5b38de52
MD5 bd98f8b4177af4a16c3ea8bb2da916e1
BLAKE2b-256 2420128d0320e1a79a49fac5765ff44d1f733521208291a59fc4243aa306df17

See more details on using hashes here.

File details

Details for the file PJHomematic-0.1-py3-none-any.whl.

File metadata

  • Download URL: PJHomematic-0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for PJHomematic-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53fc709a05f99b9ab922b4f4cf1542546ffa96baf251da5de7edb46ab5b63b40
MD5 d8b045608da8aca7a35c78a9f57a8f47
BLAKE2b-256 15355fe6c85ffa76d11015599af231b189603f3392d8e780fe9edff240303224

See more details on using hashes here.

Supported by

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