GraphQL API Support [Alpha]

GraphQL for OpenHAB

This add-on aims to bring GraphQL support to OpenHAB.

After deployment, the system will respond with GraphQL playgrounds on /graphql, and accept queries and subscription requests at that URI.

Contributions welcome! I expect that I will try and eventually submit this as an addon to live in the openhab-addons project, but it needs some more work before then.

Please don’t rely on the shape of this API yet - there may be changes to come (esp. based on feedback)

There is a simple react project that you can use as a basis for your own experiments here:

Current Status

Querying

  • Querying mostly works for items and things. There are a few fields that are still nulled out (mostly around Commands and State) which will come soon.

Mutations

  • First mutation for sendCommand to an individual item.

Subscriptions

  • You can subscribe at an item, items (with a filter) or to everything within a group.
    NB: This is working, but there seems to be an issue with playgrounds not being able to subscribe correctly.

Changelog

Version 0.3.2

  • Some GQL fixes
  • Introduction of tags() query

Version 0.3.1

  • Fix for state fetch

Version 0.3

  • Turned down excessive logging
  • Added skip & limit to the query API. The return collection types now contain these fields and totals, so wrap the items in a child attribute.
  • Targetted 4.0.x as 4.1.x was causing some strange issues

Version 0.2

  • Lots of updates - filtering in items, optional querying through groups. First mutation (SendCommand). State now returned. Event subscriptions can also be to filters or to groups.

Version 0.0.1

  • initial work in progress

Current Binary: https://github.com/magnayn/openhab-graphql/releases/download/0.3.2/graphql.jar

Source: GitHub - magnayn/openhab-graphql: GraphQL Support for OpenHAB

1 Like

How can one disable the log spam caused by the binding? There don’t seem to be any configuration options inside the binding yet (OH 4)

Good point - yes, it spits out way too much.

I’ll spin a version over the weekend that makes that is a bit more sensible in that regard!

THis should now have toned down the logging, and has a few extra fixes.