I am currently developing a binding to host openHAB things as WebThings (https://iot.mozilla.org/wot/#web-thing-description) so that they are accessible by other applications - mostly the Mozilla Gateway (https://iot.mozilla.org/). Furthermore, you can connect openHAB things and (Mozilla) WebThings to control each other.
The binding uses the Java WebThing Framework (https://iot.mozilla.org/framework/) which currently offers no OSGi bundle. Therefore, i created the bundle myself based on the Jar on MVNRepository (https://mvnrepository.com/artifact/org.mozilla.iot/webthing/0.12.0).
From the ReadMe:
This binding can be used to host openHAB things as (Mozilla) WebThings or connect them to control each other.
Example interaction: Link
!!! Work in progress !!!
Copy the files from the
dependencies folder and the binding into your addons folder
WebThings Server: Host your openHAB things as WebThings.
WebThings Connector: Connect openHAB things and WebThings.
Currently no auto discovery implemented.
- Server URL of WebThing Server: Currently only Mozilla Gateways supported. This is used for by the WebThings Connector.
Bearer token: Token for the Connector Things authorization. Can be generated in the Mozilla Gateway:
Settings --> Developer --> Create local authorization
- OpenHAB IP and Port: OpenHAB instance to get necessary information from. Used for REST API calls.
- Match capabilities: If true the WebThing Server will try to add a @type to each WebThing to match Mozilla capabilities based on default tags - this may not always work flawlessly for all things. If set to false, all WebThings will appear as custom things.
- Port of WebThing Server: Port to host your Webserver on. Multiple servers possible.
- Linked items: Choose whether to create a property for every channel of the openHAB thing or for every item linked to it. For linked items naming convention of simple linking is currently advised
- Host all things: Host all things (except things created by this binding) or only selected ones.
- Selected openHAB things: Choose openHAB things to host as WebThings (only if 3. = false).
- ID of WebThing
- UID of openHAB thing
|WebThing Server||Port||Number||Port of WebThing Server|
|WebThing Server||Hosted WebThings||Text||List of openHAB things hosted as WebThings|
|WebThing Connector||Update||Switch||Can be used to restart the websocket (re-connect)|
|WebThing Connector||ID||String||ID of WebThing|
|WebThing Connector||UID||String||UID of openHAB thing|
Example Usage cases
- Single platform for multiple smart homes or smart home systems from one or multiple networks
- Remote access
- Sync openHAB instances
- Authorization concept (expose different WebThing Servers with selected things via reverse proxy)
- Support for more items types / properties
- Third thing which lets you choose one capability and automatically creates WebThing with needed properties, actions and events
- Implement a way to control WebThings with “dummy” (offline) openHAB things. Currently only works one way (openHAB --> Gateway) due to offline openHAB things not being able to update their item states.
Currently only selected cases are supported and some major issues still exist. These issues include:
|Dependency incompatibility when REST API docs are installed||Binding may not start||Active||Remove docs --> install binding --> install docs|
|ConfigOptionProvider for WebThing Server may request the openHAB thing list before the API is ready||Server may not be creatable||Active||Try to manually restart bundle, Re-compile without
|First command for switch item / OnOff property gets send but not detected by gateway||Command not properly received||Active||Send another command after initially connecting|
|Add webthing as internal dependency||Dependencies need to be deployed manually||Active||Add lib directory (currently not compiling)|
|ItemStateChangeEvents for items with delimiters are not processed correctly||Some items are not controllable||Active||Switch case for special items|
|WebThings can only be accessed via their index in list (e.g. localhost:8888/0)||Removal of things from a WebThing Server will change the indices of the other things||Active||Create multiple servers so that changes to one do not affect all things|
Work in progress code can be found here: https://github.com/svensven94/openhab-addons/tree/2.5.x/bundles/org.openhab.binding.webthings
Lastly, the relevant GitHub issue can be found here: https://github.com/openhab/openhab-addons/issues/7009