Introduction
Futurehome has added the functionality to open opp local API access over MQTT.
NB! Only for Smarthubs with version >= 1.9.xx
When the access is enabled - the port 1884 on the Smarthub will be opened. This port exposes the MQTT broker inside the smarthub, and allows other MQTT clients to connect to it. The connection is secured with a username and password that can be set in the Futurehome app.
NB! The only way to deactivate the local MQTT access is to send a request to Futurehome support.
The communication is done using FIMP - Futurehome IoT Messaging Protocol, and is documented on Github: https://github.com/futurehomeno/fimp-api
Enable access
- Login to the Futurehome app.
- Go to the advanced option under site settings.
- Enter a username and password (minimum characters).
- Press Activate
- Use a tool like Fing to find your Smarthub IP-address (cube.local) on the local network.
- Connect to MQTT on your Smarthub over port 1884 with the username and password. You can use any MQTT client to connect. In the example below we will use Node-Red
Usage
All communication is done using FIMP over MQTT - you can find the documentation on Github: https://github.com/futurehomeno/fimp-api
In this example we will use Node-Red
Configure MQTT node
- Select the mqtt node under input
- Add new mqtt-broker under Server
- Configure the node with the IP found in Fing (or local host name) and username and password entered in the app.
- Add the configuration
- Subscribe to topic: pt:j1/#
This will let you see all messages from devices and apps in the smarthub - You can read more about the topic structure in Github
Get a list of devices on the Smarthub
For this we will need two mqtt nodes, one input and one output. We will send a message to the output node requesting a list of devices. And we will receive the response on the input node. We will also use the inject node to send the message, and the debug node to view the response.
Output - mqtt node
- Select the Server you added in the previous step
- Add topic: pt:j1/mt:cmd/rt:app/rn:vinculum/ad:1
Input - inject node
- Select JSON as the payload
- Add the following FIMP message:
{
"ctime": "2019-09-04 17:36:31 +0200",
"props": {},
"resp_to": "pt:j1/mt:rsp/rt:app/rn:node-red/ad:flow1",
"serv": "vinculum",
"src": "node-red",
"tags": [],
"type": "cmd.pd7.request",
"uid": "09936904-8ec8-4280-9285-945d77bd0a74",
"val": {
"cmd": "get",
"component": null,
"id": null,
"param": {
"components": [
"device"
]
},
"requestId": 7294000000007
},
"val_t": "object",
"ver": "1"
}
- Topic can be left empty since we added it to the mqtt output node, or you can add: pt:j1/mt:cmd/rt:app/rn:vinculum/ad:1
Input - mqtt node
- Select the Server you added in the first step
- Add the topic we used in "resp_to" in the inject node: pt:j1/mt:rsp/rt:app/rn:node-red/ad:flow1
- Set the Output as a parsed JSON object
Output - debug node
- Add the debug node, no settings needed
Test it!
- Connect the nodes like this:
- You should see that the nodes connect after pressing the deploy button.
- Press the inject node to send the message.
- You should see the received message under the debug view
- Copy the message and use your favorite JSON parser to view it, or just it in Node-red
- This flow attached at the end of the article
Control out_bin_switch on a device
This flow attached at the end of the article
Comments
0 comments
Please sign in to leave a comment.