Skip to content

A GraphQL wrapper to monitor/control Homematic IP components via REST API.

License

Notifications You must be signed in to change notification settings

martin-riedl/homematic-gqls

Repository files navigation

HomeMatic GQLS (Graph Query Language Service)

This Flask-based wrapper of the great homematicip-rest-api can be used to integrate with various other gateways that allow for a GraphQL access.

image

Note

This is a very first version. As of now, the model only supports TemperatureHumiditySensorDisplay and ShutterContact, as these are those sensors that I have in use right now. However this could be easily extended.

Setup

  1. Clone this repo
    git clone https://github.com/martin-riedl/homematic-gqls
  2. Obtain authtoken from Homematic IP Cloud
    1. Follow the instructions from homematicip-rest-api to obtain an authtoken for your homematicIP cloud account (hereby a file config.ini is created).
    2. Copy the resulting file config.ini into the main directory of this repository.
  3. Install the requirements
    pip3 install -r requirements --user
  4. Start the server
    python3 server.py

Serving via HTTP

GraphQL can serve over http via GET and POST requests.

A POST request using curl

curl -X POST localhost:8191/graphql -H "Content-Type: application/json" --data '{"query":"{shuttercontacts{windowState}}"}'

or using a filter on the label

curl -X POST localhost:8191/graphql -H "Content-Type: application/json" --data '{"query":"{shuttercontacts_filtered (label_filter : "mylabelorempty") {label windowState}}"}'

A GET request using curl

curl -X GET localhost:8191/graphql?query=%7Bshuttercontacts%7BwindowState%7D%7D

Include in OpenHAB

For further information see OpenHAB HTTP Binding.

A request via HTTP GET which refreshes each 60k ms may look as follows:

String windowstatus "WindowStatus [%s]" { http="<[http://myhost:8191/graphql?query=%%7Bshuttercontacts%%7BwindowState%%7D%%7D:8191:JSONPATH($.data.shuttercontacts[0].windowState)]" }

Docker

Building the image:

docker build --tag hmgqls .

Running the container (bound to localhost on the host):

docker run -p 8191:8191 -d --restart unless-stopped --name hmgqls hmgqls

And check in the browser to see the Playground UI.

Or query a specific device, e.g. http://localhost:8191/graphql?query={shuttercontacts{windowState}}

About

A GraphQL wrapper to monitor/control Homematic IP components via REST API.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published