Node-RED help

I have been wanting to bring my oil tank quantity in to my emonCMS dashboard for ages, & have at last managed to “intercept” the 433 RF data that goes between my Watchman Sonic oil tank level sensor and the in-house display, and get the data in to Node-RED via MQTT. But I now want to bring the data in to my emonCMS dashboard.

Once every 15 minutes I get this info, with the date, time & depth_cm being what I want. The “topic” is home/rtl_433

{"time" : "2021-01-27 14:21:55", "model" : "Oil-SonicSmart", "id" : 136628653, "flags" : 128, "maybetemp" : 21, "temperature_C" : 13.333, "binding_countdown" : 0, "depth_cm" : 97}

How might I “parse” / process the info into a format that I can then use within emonCMS?

My emonPi is my MQTT broker, but the Node-RED is handled on a separate RPi.


Someone else probably has more information on this, but I just sent MQTT messages to the broker running on the emonPi with topics like:


and the payload containing the value.

This then automatically appeared as an Input in emonCMS from which you can create a feed.

As your MQTT client is on a separate host, you will need to authenticate, but standard credentials worked for me.

Your payload is a JSON object so you should be able to read values as


I suggest you construct a JSON string of the format


and publish it to


this will get picked up.

Check it is valid JSON. The time can be an integer in seconds but it must meet the ISO standard (the one in your example isn’t).

There is also the emoncms node for Node-red.


Thanks both - sorry for the delay in coming back, but I have a few comms issues I need to fix before doing this.

My MQTT server is my emonPi; does it keep / hold logs, and if so where / how would I find them? I’ve looked in emonHub & Admin, but can’t find anything.


or subscribe to $SYS/# topic from an MQTT client if they are published there.

For Mosquitto logs check out this guide Understanding and Configuring Logging - Mosquitto Broker Configuration

Thanks both - I now have my the url > Node-RED > emonCMS / Inputs > Feeds > MQTT > Home Assistant working well; but is there a way within emonCMS to round a Feed to x decimal places? Very much ideally within emonCMS as I am doing a conversion from degF to degC as part of a Feed creation.


I am reasonably sure the precision stored in the database is fixed.

You would usually fix it at the point of use. How are you using it that you need to round it?

I am bringing in MQTT data from a Davis Weather Station, and it reports in degF, so I apply a calculation to the Input within emonCMS, but that produces a degC with 2 decimal places - which I don’t need or want. I will play some more and see if I can do the calcs within the MQTT stream, so that only rounded numbers get to emonCMS.

On a related note, I have a RPi sending MQTT data to my emonPi / emonCMS MQTT broker, with the topic /home/rtl_433 . Would this be why I can’t “see” the data in my emonCMS Inputs page (like I can, for example, my PiZero_Serial_topbarn data). Perhaps I ought to change the topic to emon/rtl_433 instead?

NB: The data is sent via a script
rtl_433 -F json -M utc -R 43 | mosquitto_pub -t home/rtl_433 -l -h -p 1883 -u emonpi -P emonpimqtt2016

Davis is one of the major players in the personal weather station industry.
The quality of the instrument is such that the US National Weather Service prefers the Davis units to any other hardware for use in their Citizen Weather Observer Program. I find it odd that a temperature output in Celsius is not available from your unit. Which one do you have?

I have now been able to convert from degF to degC within NodeRED, and from there it goes via MQTT to emonCMS on my emonPi. So all is now good.

I have a Davis Vantage Vue; it does report in degF or degC within its’ own dashboard, but the API call only returns degF; but as I want to integrate the data within my emonCMS (& HomeAssistant) dashboards I needed to do my own post-process conversion.

It isn’t an API call as such. You are intercepting the 433 transmission from the external sensor so you are getting the raw data.

Yes you are right, sorry, it isn’t an API call; the info is the return from a url - .

	"data": {
		"did": "001D0A712D46",
		"ts": 1613636411,
		"conditions": [{
			"lsid": 352807,
			"data_structure_type": 1,
			"txid": 1,
			"temp": 49.1,
			"hum": 83.8,
			"dew_point": 44.4,
			"wet_bulb": 46.4,
			"heat_index": 49.1,
			"wind_chill": 43.0,
			"thw_index": 43.0,
			"thsw_index": null,
			"wind_speed_last": 17.81,
			"wind_dir_last": 134,
			"wind_speed_avg_last_1_min": 13.18,
			"wind_dir_scalar_avg_last_1_min": 133,
			"wind_speed_avg_last_2_min": 13.18,
			"wind_dir_scalar_avg_last_2_min": 133,
			"wind_speed_hi_last_2_min": 21.93,
			"wind_dir_at_hi_speed_last_2_min": 117,
			"wind_speed_avg_last_10_min": 12.56,
			"wind_dir_scalar_avg_last_10_min": 136,
			"wind_speed_hi_last_10_min": 21.93,
			"wind_dir_at_hi_speed_last_10_min": 117,
			"rain_size": 2,
			"rain_rate_last": 0,
			"rain_rate_hi": 0,
			"rainfall_last_15_min": 0,
			"rain_rate_hi_last_15_min": 0,
			"rainfall_last_60_min": 0,
			"rainfall_last_24_hr": 13,
			"rain_storm": 50,
			"rain_storm_start_at": 1613424181,
			"solar_rad": null,
			"uv_index": null,
			"rx_state": 0,
			"trans_battery_flag": 0,
			"rainfall_daily": 0,
			"rainfall_monthly": 211,
			"rainfall_year": 776,
			"rain_storm_last": 160,
			"rain_storm_last_start_at": 1612221900,
			"rain_storm_last_end_at": 1612771260
		}, {
			"lsid": 352806,
			"data_structure_type": 4,
			"temp_in": 52.3,
			"hum_in": 66.3,
			"dew_point_in": 41.4,
			"heat_index_in": 51.3
		}, {
			"lsid": 352805,
			"data_structure_type": 3,
			"bar_sea_level": 29.551,
			"bar_trend": -0.066,
			"bar_absolute": 29.265
	"error": null

[Mod - edited] - put the backticks on a line on their own - use to prettify the JSON

I have made some progress with extracting & converting the timestamp (“ts”:1613636411) in Node-Red; I get as far as producing "18 Feb 2021 08:22" but when that gets sent to emonCMS via MQTT the Input name becomes (eg) "18 Feb 2021 08" and the value is 22 :crazy_face:.

I can see why - presumably it thinks it is a value pair? (and this also leads to the creation of a new Input each update), so more experimenting required to get the MQTT message to be “time: 18 Feb 2021 08:24” instead…

PS I do love the interaction between several bits of hardware and various software platforms. Fascinating stuff.

Yes that is the API call :slight_smile:

In node red just use a change node and change the name from ts to time and leave as an integer. You may need to restructure the data possibly and split out the arrays.

It needs to be in ISO format for emoncms to understand the string.

1 Like