Import data from Glow MQTT IHD

Continued from Glow IHD with Local MQTT

I’m eventually getting round to doing this, and have noticed a few oddities with the data;

In trying to decode the MQTT data in Node-RED, I discovered several things with the gas data;

  1. The timestamp only changes every 3 messages (aprox just over 30s) (sometimes 4 messages)
  2. The difference between the 2 timestamps is not consistent (between 28 and 32 seconds)
22/08/2022, 21:58:30node: eab876118987fe3a glow/441793526184/SENSOR/gasmeter : msg.payload.gasmeter.timestamp : string[20] "2022-08-22T20:58:07Z" 
22/08/2022, 21:58:40node: eab876118987fe3a glow/441793526184/SENSOR/gasmeter : msg.payload.gasmeter.timestamp : string[20] "2022-08-22T20:58:07Z" 
22/08/2022, 21:58:50node: eab876118987fe3a glow/441793526184/SENSOR/gasmeter : msg.payload.gasmeter.timestamp : string[20] "2022-08-22T20:58:39Z" 
22/08/2022, 21:59:00node: eab876118987fe3a glow/441793526184/SENSOR/gasmeter : msg.payload.gasmeter.timestamp : string[20] "2022-08-22T20:58:39Z" 
22/08/2022, 21:59:10node: eab876118987fe3a glow/441793526184/SENSOR/gasmeter : msg.payload.gasmeter.timestamp : string[20] "2022-08-22T20:58:39Z" 
22/08/2022, 21:59:20node: eab876118987fe3a glow/441793526184/SENSOR/gasmeter : msg.payload.gasmeter.timestamp : string[20] "2022-08-22T20:59:12Z" 
22/08/2022, 21:59:30node: eab876118987fe3a glow/441793526184/SENSOR/gasmeter : msg.payload.gasmeter.timestamp : string[20] "2022-08-22T20:59:12Z" 
22/08/2022, 21:59:40node: eab876118987fe3a glow/441793526184/SENSOR/gasmeter : msg.payload.gasmeter.timestamp : string[20] "2022-08-22T20:59:12Z"

I also noticed taking over 30s to change timestamp.

If anyone want to import this data I suggest the following Node-RED function [edited 13/12/2022]

var newmsg = {};
newmsg.payload = {};

// const time = msg.payload.gasmeter.timestamp.replace("Z", "+00:00"); // alternative time format
const time = Date.parse(msg.payload.gasmeter.timestamp)/1000;
const gasm3 = msg.payload.gasmeter.energy.import.cumulativevol;

newmsg.payload = JSON.stringify({time, gasm3});
newmsg.topic = "emon/octopusmeter"

return newmsg;

Process the input every minute to avoid gaps.

The GSME only reports every 30 minutes so you could even make it more than a minute.

The IHD also gives a kWh figure (which you can add) but I’d be a little wary of the conversion factor for calorific value it uses.

Also note some of the data is listed as vol, but is in fact kWh.

[edit]

For completeness, electric

var newmsg = {};
newmsg.payload = {};

const time = Date.parse(msg.payload.electricitymeter.timestamp)/1000;
const electric = msg.payload.electricitymeter.energy.import.cumulative * 1000;

newmsg.payload = JSON.stringify({time, electric});
return newmsg;

@borpin thank you for this function, and I note the previous Glow IHD with Local MQTT thread.

As a happy hardware engineer (not so much happy software writer), I have not had immediate success in using node-red to connect my emonpi and local MQTT from a Glow IHD. MQTT explorer shows the MQTT feed, as does node-red

But if I try to use your sample function to modify the timestamp, I get a Type Error

I kind of feel that the gasmeter and electricitymeter objects are of a different kind to the upper levels (glow//SENSOR), but I don’t know how to drive this.

A noob error? I’d be very happy to learn what I’m doing wrong.

Any clues, or even a fully worked sample interfacer from Glow to emonpi would be very gratefully received.

You didn’t do anything wrong - I got it wrong. Must have pasted the wrong code.

I’ve updated the above and I’ll add electric as well.

Thanks @borpin , that prompted enough to get me out of the weeds.

I did do something wrong - on the mqtt in node I had accepted the Output selection as auto-detect (string or buffer), but it needed to be a parsed JSON object, hence the TypeError.

I am now successfully importing my Octopus SMETS2 meter data into emonCMS :white_check_mark:

1 Like