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;
- The timestamp only changes every 3 messages (aprox just over 30s) (sometimes 4 messages)
- 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;