Create and display log in dashboard

Hi.

What appears to be what I want is in the last post in this thread:

Unfortunately the guy who posted this isn't replying.

What I want is to have a true and false signal being logged and saved and then displayed on the dashboard.
Then I can see when the door has been opened and when the door bell has been used.

I can see the nodes used but what's happening in the nodes is the question.

//Kim

If you add those nodes to your flow and connect it to your data source, it should more or less work as is.

The simple time node adds msg properties for the current time, which you can then use as a time stamp for the log.

The switch / function nodes are likely used to format the text so it looks nice in the log.

The file out node stores this information in to a file of your choosing.

The file watch node checks to see if something has been added to the log file, and if it has then it triggers the exec node which is running a tail command on the file (which outputs the last lines of the log).

This then goes to the template node to display the info on the dashboard.

Set it up and have a go :wink:

If you get stuck then you can ask for specific help.

I tied and I just get stuck.
I have no clue for the function node. I would have used a template node to combine the simpletime and the payload for "on/off" - but there's probably someting to combine or instruct the save file node.

Ok so I got it to work 90%.

So the file writing, saving and tail function is good.
Now it's just a matter of displaying it the right way.

As you all can see, the output is cluttered. Could anyone give Information on how to organize the output in the dashboard?

I've tried to reuse this code, but I don't fully understand how it works.

I cannot see that ?

Can you post your flow? Export the nodes in the editor, copt to clipboard and then in message press ctrl E then paste.

Forgot to add the picture:

Flow:

[{"id":"5e7af029d7f474a9","type":"inject","z":"a59677cc44057423","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":320,"y":300,"wires":[["a3ef769b309faf9f"]]},{"id":"7dce200972e248aa","type":"debug","z":"a59677cc44057423","name":"debug 116","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":970,"y":340,"wires":[]},{"id":"d799e3f4ab703c50","type":"simpletime","z":"a59677cc44057423","name":"","mydate":true,"myymd":true,"myyear":true,"mymonth":true,"mymonthn":true,"mydom":true,"mydoy":true,"myday":true,"myhourpm":true,"myhour":true,"mytime":true,"mytimes":true,"myminute":true,"myminutes":true,"mysecond":true,"mymillis":true,"myepoch":true,"myrawdate":true,"mypm":true,"x":470,"y":240,"wires":[["4ba5f0c5cbe4dccc"]]},{"id":"6e5b2cb9e5a0c875","type":"inject","z":"a59677cc44057423","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":310,"y":200,"wires":[["d799e3f4ab703c50"]]},{"id":"3be0a903267eabb8","type":"exec","z":"a59677cc44057423","command":"tail -n 4 ~/TestFile.txt","addpay":"","append":"","useSpawn":"true","timer":"","winHide":false,"oldrc":false,"name":"","x":700,"y":360,"wires":[["7dce200972e248aa","f03fce73fb7471d5"],[],[]]},{"id":"9229c3a4974c9be5","type":"file","z":"a59677cc44057423","name":"","filename":"~/TestFile.txt","filenameType":"str","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":1030,"y":240,"wires":[[]]},{"id":"a3ef769b309faf9f","type":"file in","z":"a59677cc44057423","name":"","filename":"~/TestFile.txt","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":470,"y":300,"wires":[["a5929dca97db8d57","3be0a903267eabb8"]]},{"id":"a5929dca97db8d57","type":"debug","z":"a59677cc44057423","name":"debug 147","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":420,"wires":[]},{"id":"3cead93eaa25f41f","type":"template","z":"a59677cc44057423","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{mydom}}/{{mymonthn}}-{{myyear}}.{{mytimes}}-{{payload}}","output":"str","x":840,"y":240,"wires":[["9229c3a4974c9be5"]]},{"id":"60c3c3628b903a22","type":"inject","z":"a59677cc44057423","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":310,"y":240,"wires":[["d799e3f4ab703c50"]]},{"id":"4ba5f0c5cbe4dccc","type":"change","z":"a59677cc44057423","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"ON","fromt":"str","to":"Test ON","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"OFF","fromt":"str","to":"Test OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":240,"wires":[["3cead93eaa25f41f"]]},{"id":"f03fce73fb7471d5","type":"ui_template","z":"a59677cc44057423","group":"6c1f9d4984a3f2d6","name":"","order":1,"width":10,"height":7,"format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":960,"y":300,"wires":[[]]},{"id":"6c1f9d4984a3f2d6","type":"ui_group","name":"Default","tab":"463f26aa73519adc","order":1,"disp":true,"width":10,"collapse":false,"className":""},{"id":"463f26aa73519adc","type":"ui_tab","name":"Test","icon":"dashboard","disabled":false,"hidden":false}]

Change your UI template to
<div style="white-space: pre-wrap;" ng-bind-html="msg.payload"></div>

That did the trick!
Thanks :pray:

The complete flow is:

[{"id":"5e7af029d7f474a9","type":"inject","z":"a59677cc44057423","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":320,"y":300,"wires":[["a3ef769b309faf9f"]]},{"id":"7dce200972e248aa","type":"debug","z":"a59677cc44057423","name":"debug 116","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":970,"y":340,"wires":[]},{"id":"d799e3f4ab703c50","type":"simpletime","z":"a59677cc44057423","name":"","mydate":true,"myymd":true,"myyear":true,"mymonth":true,"mymonthn":true,"mydom":true,"mydoy":true,"myday":true,"myhourpm":true,"myhour":true,"mytime":true,"mytimes":true,"myminute":true,"myminutes":true,"mysecond":true,"mymillis":true,"myepoch":true,"myrawdate":true,"mypm":true,"x":470,"y":240,"wires":[["4ba5f0c5cbe4dccc"]]},{"id":"6e5b2cb9e5a0c875","type":"inject","z":"a59677cc44057423","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":310,"y":200,"wires":[["d799e3f4ab703c50"]]},{"id":"3be0a903267eabb8","type":"exec","z":"a59677cc44057423","command":"tail -n 4 ~/TestFile.txt","addpay":"","append":"","useSpawn":"true","timer":"","winHide":false,"oldrc":false,"name":"","x":700,"y":360,"wires":[["7dce200972e248aa","f03fce73fb7471d5"],[],[]]},{"id":"9229c3a4974c9be5","type":"file","z":"a59677cc44057423","name":"","filename":"~/TestFile.txt","filenameType":"str","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":1030,"y":240,"wires":[[]]},{"id":"a3ef769b309faf9f","type":"file in","z":"a59677cc44057423","name":"","filename":"~/TestFile.txt","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":470,"y":300,"wires":[["a5929dca97db8d57","3be0a903267eabb8"]]},{"id":"a5929dca97db8d57","type":"debug","z":"a59677cc44057423","name":"debug 147","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":420,"wires":[]},{"id":"3cead93eaa25f41f","type":"template","z":"a59677cc44057423","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{mydom}}/{{mymonthn}}-{{myyear}}.{{mytimes}}-{{payload}}","output":"str","x":840,"y":240,"wires":[["9229c3a4974c9be5"]]},{"id":"60c3c3628b903a22","type":"inject","z":"a59677cc44057423","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":310,"y":240,"wires":[["d799e3f4ab703c50"]]},{"id":"4ba5f0c5cbe4dccc","type":"change","z":"a59677cc44057423","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"ON","fromt":"str","to":"Test ON","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"OFF","fromt":"str","to":"Test OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":240,"wires":[["3cead93eaa25f41f"]]},{"id":"f03fce73fb7471d5","type":"ui_template","z":"a59677cc44057423","group":"6c1f9d4984a3f2d6","name":"","order":1,"width":10,"height":7,"format":"<div style=\"white-space: pre-wrap;\" ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":960,"y":300,"wires":[[]]},{"id":"6c1f9d4984a3f2d6","type":"ui_group","name":"Default","tab":"463f26aa73519adc","order":1,"disp":true,"width":10,"collapse":false,"className":""},{"id":"463f26aa73519adc","type":"ui_tab","name":"Test","icon":"dashboard","disabled":false,"hidden":false}]
1 Like

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