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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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