Store different values of the same payload, and then release them in order of arrival in the graph?

How can I store different values ​​of the same payload, and then release them in order of arrival in the graph?

If there are multiple values in the same payload, won't they all have arrived at the same time?

No, I have a variable that changes the value over time, so I wanted to store these values ​​and then throw them into a char to see the difference in the peaks

Can you show us an example of this payload with different values in it?

Why not save each value along with the current time in an array of objects in the payload.

Could you just feed them into the chart as they arrive, rather than saving them and then building the chart?

It is a sensor that returns the value in a string, but I am still using an inject for the tests, And the graph only appears when I press the button
My flow:

[{"id":"80a580d7de110e16","type":"tab","label":"Flow 4","disabled":false,"info":"","env":[]},{"id":"9b57470c0e8b9afc","type":"inject","z":"80a580d7de110e16","name":"","props":[{"p":"payload.one","v":"565","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"2","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":140,"wires":[["df99a0281ba442b9"]]},{"id":"df99a0281ba442b9","type":"change","z":"80a580d7de110e16","name":"","rules":[{"t":"set","p":"one","pt":"global","to":"payload.one","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":140,"wires":[[]]},{"id":"2796898c17b42270","type":"ui_dropdown","z":"80a580d7de110e16","name":"","label":"Energia","tooltip":"","place":"Escolha","group":"5e5b90ffc9f1961a","order":2,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"Ar comprimido","value":"one","type":"str"},{"label":"Eletricidade","value":"two","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":720,"y":280,"wires":[["e11f77c661257953"]]},{"id":"e11f77c661257953","type":"change","z":"80a580d7de110e16","name":"","rules":[{"t":"set","p":"chartSelection","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":280,"wires":[[]]},{"id":"e03220e22f79dcf1","type":"ui_button","z":"80a580d7de110e16","name":"","group":"5e5b90ffc9f1961a","order":3,"width":0,"height":0,"passthru":false,"label":"Gerar gráfico","tooltip":"","color":"White","bgcolor":"Purple","className":"","icon":"","payload":"chartSelection","payloadType":"global","topic":"topic","topicType":"msg","x":530,"y":400,"wires":[["cae43270e7b65063"]]},{"id":"cae43270e7b65063","type":"function","z":"80a580d7de110e16","name":"function 3","func":"if(msg.payload==\"one\"){\n    msg.payload= global.get('one')\n}\n\nif(msg.payload==\"two\"){\n    msg.payload= global.get('two')\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":400,"wires":[["95756422e3978770","7a20928810935731"]]},{"id":"95756422e3978770","type":"debug","z":"80a580d7de110e16","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":920,"y":340,"wires":[]},{"id":"2f085db112552c25","type":"ui_ui_control","z":"80a580d7de110e16","name":"","events":"all","x":220,"y":400,"wires":[["ba93ac6de9587685"]]},{"id":"ba93ac6de9587685","type":"delay","z":"80a580d7de110e16","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":370,"y":400,"wires":[["e03220e22f79dcf1"]]},{"id":"2b06d6d38cdcf97e","type":"change","z":"80a580d7de110e16","name":"","rules":[{"t":"set","p":"two","pt":"global","to":"payload.two","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":200,"wires":[[]]},{"id":"7a20928810935731","type":"ui_chart","z":"80a580d7de110e16","name":"","group":"5e5b90ffc9f1961a","order":4,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":950,"y":420,"wires":[[]]},{"id":"f5642e2e8a6814f4","type":"inject","z":"80a580d7de110e16","name":"","props":[{"p":"payload.two","v":"515","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":220,"wires":[["2b06d6d38cdcf97e"]]},{"id":"b2b15be1bb0f4d05","type":"comment","z":"80a580d7de110e16","name":"This is an example of the data, but I will use a sensor later to receive the payload instead of this inject","info":"","x":360,"y":80,"wires":[]},{"id":"5e5b90ffc9f1961a","type":"ui_group","name":"Rampa_1","tab":"338878ddae580b7e","order":1,"disp":true,"width":20,"collapse":false,"className":""},{"id":"338878ddae580b7e","type":"ui_tab","name":"B","icon":"dashboard","disabled":false,"hidden":false}]

So your incoming data is a single value (565 or 515 in the example), not "different values ​​[in] the same payload".

In which case you can just pass msg.payload (not msg.payload.one) to the chart node as it arrives, as @Colin suggests.
The chart will draw a graph using each value and the timestamp of it's arrival.

But if I do it this way, the graph will be showing the data all the time, right? I need the graph to only appear when I press the button, Oh and these values ​​(515,565) are representing two sensors, the truth values ​​will not be fixed.

Yes.

Do you mean in a popup?
How do you propose to make it disappear again?

Do you want two different graphs or two lines on the same graph?

I need the same graph to show the two peak changes of the two sensors, When I want to change the value by the dropdown I need to reset the graph to show the value without the conflict of the previous value, I'm thinking of just playing [{"0"} ], and yes, it's basically a "popup"

This might achieve some of what you are after.
It draws a graph of either electricidade or ar comprindo (or neither).
Not very exciting graphs though, since the data never changes.

[{"id":"d6a0a91d477d81c8","type":"tab","label":"Flow 4","disabled":false,"info":"","env":[]},{"id":"db119705f2449c79","type":"inject","z":"d6a0a91d477d81c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"2","crontab":"","once":false,"onceDelay":0.1,"topic":"one","payload":"565","payloadType":"num","x":600,"y":160,"wires":[["5b7837e0a87e326c"]]},{"id":"fda65ce4465f99e5","type":"ui_dropdown","z":"d6a0a91d477d81c8","name":"","label":"Energia","tooltip":"","place":"Escolha","group":"5e5b90ffc9f1961a","order":2,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"Ar comprimido","value":"one","type":"str"},{"label":"Eletricidade","value":"two","type":"str"},{"label":"","value":"Neither","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":200,"y":300,"wires":[["0c9e06e4660f2c4b"]]},{"id":"0c9e06e4660f2c4b","type":"change","z":"d6a0a91d477d81c8","name":"","rules":[{"t":"set","p":"chartSelection","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":300,"wires":[["7143e0b6f0d4495e"]]},{"id":"57d550fc449b0edc","type":"inject","z":"d6a0a91d477d81c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"two","payload":"515","payloadType":"num","x":600,"y":200,"wires":[["5b7837e0a87e326c"]]},{"id":"516e34868b758de1","type":"ui_chart","z":"d6a0a91d477d81c8","name":"","group":"5e5b90ffc9f1961a","order":4,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":890,"y":180,"wires":[[]]},{"id":"5b7837e0a87e326c","type":"switch","z":"d6a0a91d477d81c8","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"chartSelection","vt":"global"}],"checkall":"true","repair":false,"outputs":1,"x":750,"y":180,"wires":[["516e34868b758de1"]]},{"id":"7143e0b6f0d4495e","type":"rbe","z":"d6a0a91d477d81c8","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":610,"y":300,"wires":[["6495b98bd6dc7955"]]},{"id":"6495b98bd6dc7955","type":"change","z":"d6a0a91d477d81c8","name":"Clear Chart","rules":[{"t":"set","p":"payload","pt":"msg","to":"[]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":300,"wires":[["516e34868b758de1"]]},{"id":"5e5b90ffc9f1961a","type":"ui_group","name":"Rampa_1","tab":"338878ddae580b7e","order":1,"disp":true,"width":20,"collapse":false,"className":""},{"id":"338878ddae580b7e","type":"ui_tab","name":"B","icon":"dashboard","disabled":false,"hidden":false}]
1 Like

That's basically what I need Thx, I just have to learn a way to save the data together with a time, so that the graph will show all the differences in values ​​in the last 10 minutes.
Ah, the way you did it, it shows the graph just by selecting it in the dropdown, it needs to be after pressing the button

You keep on giving us new glimpses of the specification!

What I would do is store sensor readings in a database.
Personally I use Mariadb, but others prefer InfluxDB for sensor data like this.
The chart can then be populated from an SQL query which can hopefully accomodate changed requirements.
But the data you pass for a stored data chart has to be in a spcific format with x,y values.

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