Graph not rendering as I'd expect

Hi All,

Please forgive my hand drawn artwork :smiley:

I am pushing data from a Samsung smart plug into EmonCMS. The plug operates over Zigbee so its very frugal with its data use as many devices on the network are battery powered.

This means that it only sends power level updates when the level actually changes. I push this into a PHPTimeSeries feed.

Unfortunately the graphs are terrible though. EmonCMS is drawing a straight line from the last sample at 0 the day before to the next sample at 1100W when the pump turns back on.

Is there any way to have the graph render properly, with a horizontal line to the next sample is taken, like my hand drawn graph, which is what is actually going on?

The graph isnā€™t ā€˜terribleā€™ it is doing what you ask of it based on the data you are storing.

Timeseries feeds expect a value for every slot, if nothing is received, by default, it records NULL. This can be what is required.

You could play with the input processes available to record Zero if the input is NULL. It isnā€™t a built in process - @TrystanLea, perhaps it could be added?

Isnā€™t that what the emonCMS datatype PHPTIMESERIES is for?
e.g. record data thatā€™s coming in at variable intervals.

Ref: Data types - which one should I use? - #3 by pb66

Thankyou @borpin

The data is coming in only when the power level changes - this is how the data is collected - Push data from SmartThings via WebCoRE into EmonCMS

The way SmartThings reports power is exceptionally efficient - I would have to do something ugly like write the previous value to the emoncms database every 5 minutes to get a graph that renders accurately, and that seems like a waste.

@Bill.Thomson - exactly - Iā€™d broadly expect TIMESERIES to render per my hand-drawn graph given the descriptions you linked to.

Data1, Time1
Data2, Time2

if data1 is 0 at time1, and data2 is 100 at time2 then a graph will draw a straight line between data1 and data2.

It doesnā€™t know that the instant before Data2 it was still 0.

Sorry, I donā€™t know how to display what you want, I just know the graph is drawing what you are asking of it.

How would it be a waste? Youā€™d just get a graph with 5 minute resolution. If you can live with that, it should be OK. The problem comes when the data arrives at intervals greater than emonCMS expects.
If the interval is fixed at, or very close to, 5 minutes, you should be able to set the interval to 5 minutes and get the graph youā€™re looking for. (The PHPFINA drop-down-menu interval choices are 5, 10, 15, 20 and 30 minutes, as well as 1 hour, and 1 day) Otherwise, use PHPTIMESERIES.

I am using PHPTimeSeries and this is how it renders. I only get samples on the input when it changes power level.

resampling every 5 minutes wonā€™t be efficient because it would be storing a lot more data that doesnā€™t actually say store any meaningful information beyond the time series I have now. But it will render better, Iā€™d hope.

I understand Iā€™ve found a corner case in how OEM renders time series data. I think that until a developer sees and understands the issue Iā€™m outa luck.

Iā€™m not sure I understand that. As I see your problem, thereā€™s an assumption on the part of ā€œSmartThingsā€ (I think thatā€™s your data source) that the value will remain the same until it is changed.

I was taught - or somewhere along the way I picked up the assumption - that the values between known points on a graph vary smoothly between those points.

In respect of how the graph is drawn, PHPFINA and PHPTimeSeries work in exactly the same way - which is the same as every graph Iā€™ve ever come across, even hand drawn ones. It joins the known points. What Iā€™m trying to get across is you want it to include a point thatā€™s unknown as far as the data available to the graph is concerned, that you know about because you know the source of the data and that it has this specific property.

Thereā€™s no mechanism at present for you to tell it to do that.

If your data source is to work successfully with emonCMS as we have it, then I think there are three options:
1 - SmartThings or your handler needs to send both the ā€œfromā€ and the ā€œtoā€ values when thereā€™s a change, and then PHPTimeSeries will draw the graph according to your wishes, or
2 - you (or you ask someone to) write an interfacer for emonHub that remembers the last value, then emits it with the present time at the instant a new value is received, then emits the new value with a fractionally later time (so that PHPTimeSeries has two records for each change), or
3 - you need to add a custom graph module to your emonCMS that draws a horizontal line from the last to the next value, then a vertical step.

1 Like