Node-red-contrib-ui-state-trail problem

Greetings everyone,

I had created a CSV file with two column of data which are "state" and "timestamp".
Then, I tried to wrote some true/false and timestamp into the CSV file.
But when I tried to read the CSV to the state trail, the display shown black colour for each state and the time label gone.
Can anyone help me to solve the problem? Thank you in advance.

Best Regards.

Dashboard display :
image

Flow :

State trail setting :

Csv data :

You have set the node to look for boolean true and false... - does the csv to json return boolean or just a string "TRUE"

2 Likes

Black for time slice is good indicator, that such state is not configured. But as the black color may be also configured color, I didn't mention it in readme anywhere. Things go much worse if black is configured and occurs for not configured slice also. Node is not prepared to discover that situation.
If historical data is sent to node, it may happen that nodes configuration has been changed meanwhile. Question is, is it error situation? May be warnings but if there is 1200 of them there will be machine gun in log.
That's why there is currently silent agreement with situation.

1 Like

Dear dceejay,

Thanks for your replied, I tried to change my boolean to string for state which are "true" and "false". And it works!
But I had found the problem that the output for csv to json changed from boolean and integer to string for both state and timestamp by using a debug node.

Here is the node I used for convert csv to json

Below is the result

For now, the state trail does not have timestamp because the value is string right now. Is there any possible way to change the string value to integer?

Best Regards.

Little snippet how to convert element properties in array

[{"id":"83df52e9.922dc","type":"function","z":"86fb73e0.f92d","name":"","func":"var arr = [{\"timestamp\":\"123456789\",\"state\":\"true\"},\n{\"timestamp\":\"456123456\",\"state\":\"true\"},\n{\"timestamp\":\"789456\",\"state\":\"false\"},\n{\"timestamp\":\"98696546\",\"state\":\"true\"}]\nmsg.payload = arr\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":220,"wires":[["6a6d94f8.ba43bc","84c46c7.1a9cf9"]]},{"id":"e98aedec.4fe99","type":"inject","z":"86fb73e0.f92d","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":220,"wires":[["83df52e9.922dc"]]},{"id":"6a6d94f8.ba43bc","type":"function","z":"86fb73e0.f92d","name":"","func":"\nlet arr = msg.payload\nfunction fixTime(el){\n    el.timestamp = parseInt(el.timestamp)\n}\narr.forEach(fixTime)\nmsg.payload = arr\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":220,"wires":[["fc12428e.f3748"]]},{"id":"84c46c7.1a9cf9","type":"debug","z":"86fb73e0.f92d","name":"before","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":450,"y":180,"wires":[]},{"id":"fc12428e.f3748","type":"debug","z":"86fb73e0.f92d","name":"after","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":510,"y":280,"wires":[]}]
1 Like

Thank you for the fast response, it had solved for my problem. :heart_eyes: :heart_eyes:

1 Like

Sorry, I have one more question here. Why I am getting the "TypeError: Cannot set property 'period' of undefined" after I use the msg.control.period in a function node.
image

I should fix the readme on that topic.
Problem is the control object must be created before you can set any properties for it.

Correct will be:

msg.control = {period:p}

or

msg.control = {}
msg.control.period  = p
1 Like

Thank you again for the information. :rofl: :rofl:

Dear hotNipi,

Sorry for disturbing again, I had some problem for displaying the state trail.
I tried to use a msg.control = {period:p}; for the state trail based on my data.
But there's a weird line above the state trail, it is because of the number of state is too much for it to handle?

Data 1 - 1050 states for a 10 seconds interval
image

Data 2 - 2100 states for a 10 seconds interval
image

Data 3 - 5250 states for a 10 seconds interval
image

Data 4 - 105 states for a 10 seconds interval
image

Best Regards.

Yeah, dots. And there is many of them. Dot means that at this point there is so small time-slice (state record with very short duration) that it can't be rendered.
See https://flows.nodered.org/node/node-red-contrib-ui-state-trail and scroll to Chapter "The Scaling Time". There is formula how to calculate smallest possible time-slice which can be rendered.
Knowing that value you can adjust the period correctly (or adjust widget size).

1 Like

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