Smartmeter: How to save the highest / last value of the day

Hey everyone,

node red and js noob here. I am using the smartmeter node to read the current power consumption as well as the total. I'm doing so every few seconds in order to display an up to date value of the current power consumption.
For the total however I'm basically only interesset in the value at 23:59:59 every day which I want to insert into an InfluxDB. I tried a calculate node but it's to much data since I poll every few seconds.

This reply timed out.

How about these (I'll let you code it as I have no Node-RED on this machine to test with - blush):

Create two flow variables - one for the date and one for the value

Set the date to the current date and the value to zero

  1. If the current date is not the same as the variable date - write the variable date and value to the database
  2. Set the current date to todays date
  3. Set the variable value to the new read value

OR

  1. Check if a record for todays date exists - if not create one with a value of zero
  2. Update todays date value with the current value (well it is a database after all)

Repeat from step one when the next read is done in both cases.

ALWAYS store the current date in a variable at the start of the flow when doing things like this - its a real pain to debug things (esp in others code) where the date changes partway through the process as they read the system date and it rolls over midnight...

One warning - think about your meter looping around - they have a horrible habit of doing this sometimes and even the 'professional billing' packages cannot cope some days (even with a fine from the ombudsman to help me get it sorted)! This leads to horrible daily used figure of -9999xx units day on day (and a rather large bill in my case).

Sorry for the late reply.

I ended up using a 'time range' node, that allows to split output into two time windows. So i created a time window from 23:59:50 to 23:59:59 and only connect this output to the influxdb node.

Not seen that node :grinning:

One concern that spring to mind is that if you do not get a reading durning that time (network error, hardware glitch etc) then you get nothing for the day at all. By tracking it throughout the day you will get a close measure towards the end of the day...

(Yes - OTT risk adverse but I come from a 24*7 business)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.