Nodered/mqtt interface to broadlink environment sensor A1


Like many, I have been tinkering with iot environmental monitoring using esp8266 with various sensors to monitor environment (temp, humidity, light, etc) for a while. The result has always been a less than professional outcome and the enclosures are not exactly what you call designer look.
The broadlink A1 enviro sensor (wifi) is a very a neat package at a very reasonable price (few cups of coffee) with a modern designer look, however their app for this is very rudimentary, lacking features and flexibility, and you will have to depend on their servers.

This project using nodered, grabs the raw data output from the A1 and transmit it via mqtt, so if you subscribe to the topic you can do what ever you want anywhere (ie display data, store in google sheets or database, or control other devices depending on the data values, eg turning light at dusk, or aircon when temp reached threshold).

Note: Still a noob with NR, so code or flow may not be most efficient.


  1. Have installed node-red-contrib-broadlink-control and familiar with the configaration of the node.
  2. Have a mqtt broker setup and configured.

The HW:
Broadlink A1
Nodered Server (in my case Pi3)

Main Nodes used: MQTT node; Broadlink (node-red-contrib-broadlink-control), function node; dashboard node

Broadcasting the raw data:
Flow 1: Broadcasting the raw data from the A1 to MQTT broker:

The A1 outputs two json objects; payload and raw:

e.g payload: {"temperature":20.7,"humidity":68.3,"light":"Normal","air_quality":"Perfect","noise":"Normal"}

e.g raw:

We want to extract the raw object as it contains numerical values so we can graph them.

The "extract raw" function node extracts the raw object and sent it to the mqtt node.

Function node code:
let raw= msg.raw;
msg.payload = raw;
return msg;

This will broadcast the raw data to the mqtt broker.

The receiving end (subscribing):

As stated I am still a noob with NR, I spend some time trying to parse and extract the data so I can split it and display it on the dashboard.
What I found (I think):
The data a json object when it was sent via mqtt, however mqtt seems to turn it into string at the receiving end. I then tried to extract the string using substring, slpit node, etc and got myself all confused and thing starts to get complicated very quickly...
After few frustrating days, I stumbled upon turning the string back into a json object.
Then it just a matter of extracting the parameter you want:
e.g to extract light:
function node code:
let lightstr= msg.payload.light;
msg.payload = lightstr;
return msg;

The output is then displayed on the dashboard:

By using "FRED" or Serveo or Ngrok a NR environmental display instance can be created anywhere.

I have a few of these sensors around the house, looks good and works!


Nice. Not seen the BroadLink A1 before. I've been building my own sensor platforms that do much the same stuff but don't currently include the air quality or gas leak detectors. Unfortunately, it is a little garish for use in our Victorian house. At around £30 from China, it is probably about the same price as doing it yourself if you have to get a power supply and case.

Of course, doing it yourself means that you get the pleasure of making it (if that's your thing) and you get to tweak it exactly how you want it. Mine report direct to MQTT so Node-RED integration is trivial and I can tweak the reporting period - I generally use about once per minute.

I also integrate data from other sensors. Our Drayton Wiser smart heating system has temperature sensors on each radiator and a standalone thermostat with temperature and humidity. Then there is the Oregon Scientific temperature/humidity sensor that is outside the house - that was the first sensor I ever brought to use with Node-RED some years ago now.

Node-RED is the hub and it allows me to standardise and enhance the sensor data making reporting and alerting much easier.


@kenkoknz Ken, do you have to have a broadlink controler to use this or does it just broadcast the info via MQTT aautomatically?


The A1 is stand alone and just broadcast the info. I do have a broadlink controller to control "in circuit" wall touch light switches and all ir devices (tv, home theater, air cond ect) and any rf devices, which is also connected to NR and Alexa as well as native app.