Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/martin-riedl/homematic-gqls
A GraphQL wrapper to monitor/control Homematic IP components via REST API.
https://github.com/martin-riedl/homematic-gqls
flask graphql homematic openhab react rest smarthome
Last synced: about 1 month ago
JSON representation
A GraphQL wrapper to monitor/control Homematic IP components via REST API.
- Host: GitHub
- URL: https://github.com/martin-riedl/homematic-gqls
- Owner: martin-riedl
- License: gpl-3.0
- Created: 2020-08-19T07:25:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-05T12:03:51.000Z (7 months ago)
- Last Synced: 2024-08-02T19:36:37.078Z (4 months ago)
- Topics: flask, graphql, homematic, openhab, react, rest, smarthome
- Language: Python
- Homepage:
- Size: 38.1 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-homematic - homematic-gqls - A GraphQL service to query Homematic IP components based on [homematicip-rest-api](https://github.com/coreGreenberet/homematicip-rest-api). (Software Modules)
README
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:: https://repository-images.githubusercontent.com/288663383/6ccbd800-f080-11ea-8c04-dd17821a7334
:height: 100px
:width: 200 px
:scale: 50 %.. 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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#. Clone this repo
.. code-block::git clone https://github.com/martin-riedl/homematic-gqls
#. Obtain authtoken from Homematic IP Cloud
#. Follow the instructions from `homematicip-rest-api `_ to obtain an `authtoken` for your homematicIP cloud account (hereby a file `config.ini` is created).
#. Copy the resulting file `config.ini` into the main directory of this repository.
#. Install the requirements
.. code-block::pip3 install -r requirements --user
#. Start the server
.. code-block::python3 server.py
Serving via HTTP
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^GraphQL can `serve over http `_ via `GET` and `POST` requests.
A POST request using `curl`
.. code-block::
curl -X POST localhost:8191/graphql -H "Content-Type: application/json" --data '{"query":"{shuttercontacts{windowState}}"}'
or using a filter on the label
.. code-block::
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`
.. code-block::
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:
.. code-block::
String windowstatus "WindowStatus [%s]" { http="<[http://myhost:8191/graphql?query=%%7Bshuttercontacts%%7BwindowState%%7D%%7D:8191:JSONPATH($.data.shuttercontacts[0].windowState)]" }Docker
^^^^^^^^^^^^Building the image:
.. code-block:: bash
docker build --tag hmgqls .
Running the container (bound to localhost on the host):
.. code-block:: bash
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}}`