It’s a possibility, but needs careful thought.
Openhab does support MQTT. It doesn’t come with an MQTT broker, but most folks add Mosquitto. Crucially (for the solution I propose at the end) Openhab allows the use of multiple MQTT brokers.
For external access (i.e. from cloud services such as Sleep as Android) there’s a (free) cloud bridge for Openhab, called Myopenhab. This means that an Openhab user doesn’t need to poke holes in their own firewall for external cloud services to be able to interact. Instead, their local Openhab instance makes an outbound connection to Myopenhab and receives events that have been exposed. If you were building an Openhab-specific API, you’d be communicating with Myopenhab. Myopenhab doesn’t include an MQTT bridge.
An ideal MQTT solution for Sleep as Android and Openhab would (I suggest) have the following attributes:
- Doesn’t require the user to install an on-premise MQTT broker (they may not be using MQTT for anything else)
- Doesn’t require the user to use an MQTT cloud bridge for any on-premise MQTT broker (which would be a lot of extra config)
- Doesn’t require the user to open any ports on their firewall to access an MQTT broker (which would reduce security)
This could all be accomplished if you provided the MQTT broker service for Sleep as Android. You’d need to provide a public key to certify the identity of the broker service, and require username and password from the user.