Building Sensor Network: Neurio integration

· Read in about 2 min · (327 words) ·


Neurio Home Energy Monitor is one of my smart IoT sensors which offers nice cloud app. This one monitors the detailed house power consumption.

When I started to build my own sensor network independent of the cloud availability, I was pleased to find out that, not like Netatmo sensors, Neurio offers also local access to the actual measurements. Then the task was clear, I need to have power consumption information available through MQTT.

Neurio local access

The Neurio Sensor implements a JSON format sensor value output. By calling http://IP_address/current-sample the sensor returns latest measurement value.

So in my case returns now:


Time for JSON to MQTT translation gate

This time the short Google research didn’t return any existing app and to be honest, I was happy for that. It is refreshing to go on my own in the simplest possible way from time to time.

The idea was simple, to create JSON2MQTT translation gate which accepts as parameter URL of a JSON resource and some template specifying how to cope with JSON data.

Python is very powerful in the simplicity of JSON like data transformation and it was very logical to utilize the power of list/set comprehension for the transformation template or mapping file if you will.

The simple template can look like this:

[ (i['type'],i['p_W']) for i in dataSet['channels'] ]

where «dataSet» refers to the root in JSON dictionary tree. And the output is always in the format:

[attribute_name, attribute_value]

which can be easily published over MQTT using Eclipse Paho for Python library, resulting this time in something like:

neurio/CONSUMPTION 338

See the complete source code

The final step is as always, adding the new gate into pm2 processes

pm2 start /usr/bin/python3 --name "JSON2mqtt-neurio" -- /home/luba/Git/JSON2mqtt/ --JSON --map neurio.txt --mqtt-topic neurio
pm2 save

We can check what processes we already have there:

The PM2

And of course to subscribe to see the Neurio messages

mosquitto_sub -v -t 'neurio/#'

The Matrix