I’m building lots of Smart Home devices based on microcontrollers myselfe, (e.g. to controll lights, relays, …). The hardware is often based on the Arduino platform and conected to my network using Wifi. I want them integrated in openHab. Therefor I’ll need to create a own binding. But instead of creating a new binding / extending it for each new device, I’ll do something more generic:
Each of my devices (or custom “hubs”) will host a http-service. This service should expose ThingTypes and Things connected to it. With this generic approach, I can define everything in my “microservices”, outside of openHab. These services will be responsible to maintain the state of Things connected to them. Another benefit of this is, that I can freely choose the language I’ll implement my logic, as long as I make some endpoints available.
I imagine it to work is as follows:
I’ll create a new binding with a “RemoteThingBridgeHandler”, a subtype of BridgeHandler.
This Bridge needs to be configured with a host, a port, and maybe somekind of authentication.
It will then query the host at an endpoint, which lists ThingTypes. For these types, a new ThingProvider is created.
Then, a second endpoint is called, which lists all connected Things and there ThingTypes. They now appear in the Inbox as they are discovered. Each Thing can then be reached using its own endpoint. All commands from openHab will be send to that endpoint, and openHab can poll the state of the Thing.
After reading a bit of documentation, came up with the following endpoints:
Lists all ThingTypesf
Lists all connected Things with an Uid and their ThingTypeUid
Gives information about that Thing, lists its ChannelUids
Gives the channel definition, also includes a field that indicades how often the value endpoint should be fetched
Gets the value of the item linked to the channel
Called when a command is issued to the channel
Before I start implementing this, I have some questions:
Is there already anything similar?
Is my understanding of the concepts wrong?
Any general suggestions?
I’m open for discussion and advice