I have a Shelly 1PM monitoring the amount of power flowing into a solar diverter, which sends its data to an OpenHAB instance. I want this OpenHAB instance to send the data onto EmonCMS via a 20 second timer rule (don’t believe the Shelly can call an API on an interval). PHPFina appears to be the man for the job, although I am concerned what happens when data doesn’t arrive for a few minutes/hours, or if there is deviation in the interval that it is submitted. The PHPFina doco here suggests blanks aren’t a big deal as the gap is just filled with NaN, but doesn’t say whether this is managed automatically by EmonCMS or I have to do it myself? Also, if my interval is 20 seconds but the actual gap varies between 20-25 seconds, is that an issue?
Would PHPFina be suitable for this task, or is this really a job for PHPTimeSeries which will log the timestamp along with the data point?
My understanding is:
Think of PHPFINA as a time slot. Data that arrives while that slot is open gets stored in it. If another data item arrives before the slot closes, it overwrites the one already there. If it misses the slot, the slot remains empty. All that’s inside emonCMS. If you send it value, it goes into the slot that’s open when it arrives. Going just a little deeper into the storage mechanism, time is computed from the start time of the database, the interval and the record number.
You have a few minutes or hours of empty records.
Say the recording interval is 20 s, and the arrival interval is 25 s, and the first data item arrives just after its slot is opened. It’s stored in the correct slot.
The second arrives 5 s and a bit into its slot. It’s stored in the correct slot.
The third arrives 10 s and a bit into its slot. It’s stored in the correct slot.
The fourth arrives 15 s and a bit into its slot. It’s stored in the correct slot.
The fifth arrives 20 s and a bit after its slot opened, and it missed it, and goes into the 6th slot. Slot 5 is empty.
So (a) you have a gap, and (b) all the values have a time that varies by up to 20 s from the time the data was received. Whether that matters, and so whether you need PHPTimeseries, is something for you to decide. Without knowing what the precise instant the data arrives means to you, and if the gaps of hours are the exception rather than normality, then PHPFINA is probably what you need.
Thanks for the reply Robert.
So my first question was does PHPFina automatically pad out missing slots - looked at the PHPFina.php source and it does appear to do so on lines 194 - 222.
Your answer to the second question makes sense - my use case here is I have recently put a Shelly 1PM in front of our solar diverter/immersion heater, so I can subtract this from the whole house demand to get actual demand. I was wondering how it would work if I logged
WholeHouse - Diverter to a feed, if the whole house CT clamp sent a value in at time
n, while the Shelly 1PM sent it in at
n + 7 seconds, for example. Having the timeslots for each feed aligned and just taking the last write to that slot makes sense.