The Monnit ALTA Plugin is a serverless function tailored to receive data push messages from Monnit’s Webhook API and upload it appropriately to Ubidots. All steps needed to set up the devices and variables at Ubidots will be carried out by the plugin’s logic, so you don’t have to worry about those rudimentary and manual things. You can even add new sensors to your network at any time after the plugin was created and the new devices will be properly set up at Ubidots automatically at the first message received.
If all of the above read sounds good to you, keep reading and follow the instructions you will find ahead to get your Monnit ALTA devices network working seamlessly with Ubidots.
Requirements
An active Ubidots account.
An active iMonnit account.
A working network of Monnit’s ALTA devices.
1. Set up the Monnit ALTA plugin
Log in to your Ubidots account, click on Devices tab, then Plugins, then click on the + icon to create a new data plugin and search for the Monnit ALTA Plugin.
Follow the plugin set up wizard and select your Ubidots token when asked for.
After finishing the wizard, you will see the new plugin listed on the Plugins List. Click on the newly created plugin and navigate to the Decoder section on the left menu and grab, from the HTTPs Endpoint URL field, the URL you will be using from the iMonnit Webhook.
2. Set up Monnit’s Webhook
Log in into your iMonnit account and navigate to the API page from the left panel, go to the create webhook tab from the navigation bar and select Webhook from the Select Push Type list.
Enter the plugin endpoint URL from previous section on the Base URL input, click on save button and you’re done, just wait for the first message to be processed by the plugin to see your devices at Ubidots.
3. Customizing
Edit device types
The Monnit ALTA Plugin will create a predefined device type for gateways and each of the Application IDs you have in your network. This allows you to customize at once all devices of a given type, i.e. you can change default variables, its units, colors and so on.
You can find those device types by logging in to your Ubidots account, click on Devices tab and then on Types, this will list all created device types. Those created by this plugin will be like: monnit-gateway, monnit-sensor-<application ID>.
It is recommended to read this article about devices types, it will give you some insights about what can be customized and how to do that.
Digging deeper
The plugin will create devices in your Ubidots account with labels following the following scheme:
Gateways:
gateway-<gatewayID>
Sensors:
sensor-<sensorID>
Given the example message
{
"gatewayMessage": {
"gatewayID": "10000",
"gatewayName": "ExampleGateway",
"accountID": "xxxx",
"networkID": "xxxx",
"messageType": "0",
"power": "0",
"batteryLevel": "101",
"date": "2016-06-18 7:39:01",
"count": "3",
"signalStrength": "29",
"pendingChange": "False"
},
"sensorMessages": [
{
"sensorID": "10001",
"sensorName": "Temp1",
"applicationID": "2",
"networkID": "xxxx",
"dataMessageGUID": "78642056-CBD8-43B0-9A4B-247E58D3B6CB",
"state": "0",
"messageDate": "2016-06-18 7:37:48",
"rawData": "23.7",
"dataType": "TemperatureData",
"dataValue": "23.7",
"plotValues": "74.66",
"plotLabels": "Fahrenheit",
"batteryLevel": "100",
"signalStrength": "100",
"pendingChange": "False",
"voltage": "3.24"
}
]
}
, by default, variables will be created for signalStrength and batteryLevel values as well as each plotLabel/plotValue pair received in the message. If for some reason you need any of the other values to be uploaded to Ubidots, like for example voltage, you can go to the plugin’s decode settings (see Section 1) and edit the Decoding Function code to add the respective value to the data that will be sent:
def process_gateway_msg(msg):
values = {
"values": [{
"signal": float(msg["signalStrength"]),
"battery": float(msg["batteryLevel"]), # Don't forget the comma
"voltage": float(msg["voltage"]) # Add voltage value
}]
}
return values
def process_sensor_msg(msg):
values = {
"values": [{
**{
item[0]: float(item[1]) for item in zip(
msg["plotLabels"].split("|"),
msg["plotValues"].split("|")
)
},
**{
"signal": float(msg["signalStrength"]),
"battery": float(msg["batteryLevel"]), # Don't forget the comma
"voltage": float(msg["voltage"]) # Add voltage value
}
}]
}
return values