Button not getting parameters

(OLD Dashboard)

Sorry folks, I seem to be missing something here.

I have a button that accepts parameters but it only works if the inject node injects.

Brief code:

[{"id":"421170e716f91701","type":"inject","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"set background","props":[{"p":"background","v":"black","vt":"str"},{"p":"txt","v":"Reset indicator LED","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","x":380,"y":4770,"wires":[["ceb7f828.6f2d3","14b9662bf33ecd63"]]},{"id":"ceb7f828.6f2d3","type":"ui_button","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"Clear Flow error notification","group":"e48399e0.8415c","order":6,"width":"5","height":"1","passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"yellow","bgcolor":"{{msg.background}}","className":"","icon":"","payload":"on","payloadType":"str","topic":"","topicType":"str","x":420,"y":4810,"wires":[["28b45862e13683a0","a568edf585a66d0f"]]},{"id":"90f495fc9a492b8b","type":"change","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"black","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"No errors detected","tot":"str"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"topic","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":385,"y":4850,"wires":[["ceb7f828.6f2d3","14b9662bf33ecd63"]],"l":false},{"id":"614669d9.6a765","type":"inject","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":490,"y":4880,"wires":[["28b45862e13683a0"]]},{"id":"28b45862e13683a0","type":"junction","z":"c3ec93b2.f3154","g":"e00b697a44223e03","x":560,"y":4810,"wires":[["2671879ce407c7e9","90f495fc9a492b8b"]]},{"id":"e48399e0.8415c","type":"ui_group","name":"Flow error display","tab":"48f5e285.67a4c4","order":2,"disp":true,"width":"11","collapse":false},{"id":"48f5e285.67a4c4","type":"ui_tab","name":"ALARMS","icon":"mi-notification_important","order":6,"disabled":false,"hidden":false}]

The idea is that it is set (initially) to what I want.
Something happens, it gets/receives a message and the text is changed. (txt and background actually)

Then if/when I press the button, it RESETS the colour/text to normal.

But it isn't happening.

I've checked the messages and can't work out what it is I am doing wrong.

Thanks.

Slight update:

If I modify the code/flow things get weird.

New flow:

[{"id":"a87c0e92c98dbede","type":"inject","z":"c3ec93b2.f3154","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":4880,"wires":[["90f495fc9a492b8b"]]},{"id":"90f495fc9a492b8b","type":"change","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"black","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"No errors detected","tot":"str"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":355,"y":4880,"wires":[["ceb7f828.6f2d3","14b9662bf33ecd63"]],"l":false},{"id":"02bf8305ebddfb75","type":"inject","z":"c3ec93b2.f3154","name":"set background","props":[{"p":"background","v":"black","vt":"str"},{"p":"txt","v":"No more errors detected","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"1","topic":"","x":120,"y":4810,"wires":[["ceb7f828.6f2d3"]]},{"id":"ceb7f828.6f2d3","type":"ui_button","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"Clear Flow error notification","group":"e48399e0.8415c","order":6,"width":"5","height":"1","passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"yellow","bgcolor":"{{msg.background}}","className":"","icon":"","payload":"on","payloadType":"str","topic":"","topicType":"str","x":420,"y":4810,"wires":[["28b45862e13683a0","a568edf585a66d0f"]]},{"id":"421170e716f91701","type":"inject","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"set background","props":[{"p":"background","v":"black","vt":"str"},{"p":"txt","v":"Reset indicator LED","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","x":380,"y":4770,"wires":[["ceb7f828.6f2d3","14b9662bf33ecd63"]]},{"id":"614669d9.6a765","type":"inject","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":490,"y":4880,"wires":[["28b45862e13683a0"]]},{"id":"28b45862e13683a0","type":"junction","z":"c3ec93b2.f3154","g":"e00b697a44223e03","x":590,"y":4810,"wires":[["2671879ce407c7e9","90f495fc9a492b8b"]]},{"id":"e48399e0.8415c","type":"ui_group","name":"Flow error display","tab":"48f5e285.67a4c4","order":2,"disp":true,"width":"11","collapse":false},{"id":"48f5e285.67a4c4","type":"ui_tab","name":"ALARMS","icon":"mi-notification_important","order":6,"disabled":false,"hidden":false}]

If I press the set background node, things work. (That's a given)

If I press the on node, the button is WIPED and nothing shown.

If I press the added inject node: IT WORKS!

Why?

The new inject node injects into the change node and that output is then sent to the button, and displayed correctly.

the on node loops back to the change node too.

So why is one working and one not?

This seems really above my knowledge level.

Again: Thanks in advance.

Screen shots now included:

(Above)
This is the RESET condition.
It works. See next.

(Above)
Text shown as sent.

(Above)
I press the on node. This simulates the button being pressed.
Follow green lines and you see the message path how it loops back to a change node then goes back to the button.
Note the text.

(Above)

No text.

(Above)
Now pressing this NEW inject node follow green lines.
It goes to the change node then into the button node.
Note text.

(Above)

Text shown.

So I am really not understanding what's going on.

N.R 4.0.9
Dashboard 3.6.0
Ubuntu 22.04

Looking just at your original flow


I find it hard to see what's going on, so I rearranged the flow and deleted the junction node.
Thos is functionally the same, just easier (for me) to understand.

When the top inject node fires it sets the background colour black and the text to "Reset indicator LED"

And when the lower inject node fires or the button is pressed it sets the background to black (so no change) and the text to "No errors detected".

That is exactly what I see.
Indeed there is no other possible colour/text combination unless you have another input going directly to the button - an error alert perhaps setting background colour red and text "Tornado warning".

I can't see what the problem is here?

Sorry your expanded post is just too complex for me to grasp what's going on.

I negated the code that actually changes what the button is showing/displaying.

That is:

[{"id":"8ab67ffd.669df","type":"function","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"Test","func":"let colour = (msg.payload === \"on\") ? \"lime\" : \"red\";\nmsg.colour = colour\nlet colour2 = colour\nlet msg3 = {}\nmsg3.colour = null\nif (colour == \"lime\")\n{\n    colour2 = \"green\"\n}\nif (msg.colour == \"red\")\n{\n    msg3.background = \"red\"\n    msg3.txt = \"Flow error occurred\"\n}\nnode.status({fill:colour2,shape:\"dot\",text:\"Show\"});\nreturn [msg,msg3];","outputs":2,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":4630,"wires":[["f25ff9fd.e1d9a8","8f4c3132.3ef8e"],["ceb7f828.6f2d3"]]},{"id":"421170e716f91701","type":"inject","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"set background","props":[{"p":"background","v":"black","vt":"str"},{"p":"txt","v":"Reset indicator LED","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","x":380,"y":4770,"wires":[["ceb7f828.6f2d3","14b9662bf33ecd63"]]},{"id":"ceb7f828.6f2d3","type":"ui_button","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"Clear Flow error notification","group":"e48399e0.8415c","order":6,"width":"5","height":"1","passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"yellow","bgcolor":"{{msg.background}}","className":"","icon":"","payload":"on","payloadType":"str","topic":"","topicType":"str","x":420,"y":4810,"wires":[["a568edf585a66d0f","28b45862e13683a0"]]},{"id":"28b45862e13683a0","type":"junction","z":"c3ec93b2.f3154","g":"e00b697a44223e03","x":590,"y":4810,"wires":[["2671879ce407c7e9","90f495fc9a492b8b"]]},{"id":"2671879ce407c7e9","type":"change","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"set colour","rules":[{"t":"set","p":"colour","pt":"msg","to":"lime","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":645,"y":4810,"wires":[["2d46c61d39876a3a","40eb5945.ff13b8","488dc129.fc2408"]],"l":false},{"id":"614669d9.6a765","type":"inject","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":490,"y":4880,"wires":[["28b45862e13683a0"]]},{"id":"90f495fc9a492b8b","type":"change","z":"c3ec93b2.f3154","g":"e00b697a44223e03","name":"","rules":[{"t":"set","p":"background","pt":"msg","to":"black","tot":"str"},{"t":"set","p":"txt","pt":"msg","to":"No errors detected","tot":"str"},{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"event","pt":"msg"},{"t":"delete","p":"socketid","pt":"msg"},{"t":"set","p":"_msgid","pt":"msg","to":"cb927840a78c2b3d","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":355,"y":4880,"wires":[["ceb7f828.6f2d3","14b9662bf33ecd63"]],"l":false},{"id":"e48399e0.8415c","type":"ui_group","name":"Flow error display","tab":"48f5e285.67a4c4","order":2,"disp":true,"width":"11","collapse":false},{"id":"48f5e285.67a4c4","type":"ui_tab","name":"ALARMS","icon":"mi-notification_important","order":6,"disabled":false,"hidden":false}]

See orange parts.

Higher up a message arrives and goes into the test node (yeah, probably bad name)
If conditions are met, it sends a message (output 2) and that changes what the button shows.

When I'm done with all things, I want to reset the button to show that all is clear.
That is done else where in the flow. (See right with the q-gate node)

Anyway, trying to not digress too much....

The test node sends a message changing the button's text/colour.
I handle that and then press the button.
That then resets the button to saying all is good with things.

Sorry for not including that or better explaining it.

Anyway, for testing at the EDIT level, I added the on node just after the button so I could simulate it being pressed.

NEITHER work, but the other 3 inject nodes do change the button text/colour.
The three are: the other on button - outside the group, the set background one outside the group and the one inside the group.
I only added it to (maybe) better show what's going on.

A bigger picture of how things HAPPEN:

All is good with the world.
Note the big black button... RESET INDICATOR LED

An error happen.
Now the button is RED and say s FLOW ERROR OCCURRED.
(not sure about the spelling, but ....)

(Above)
I see an indication of who and what the error is.

I click the NEXT button and see details
I get the specific details for that error.

I press the WIPE button to clear the display

And now I want to clear the indication/button.

I press the BIG RED BUTTON and.....

Rather than displaying the ALL CLEAR text, it is .... blank.

But, as shown with the other screen shots: Press the other inject buttons:
The button accepts the new text/colour.

Ok, not to overwhelm you.

In your example:
the top inject works.

If I (either) press the button or press the lower inject node: the button goes blank.

Hmm. It's not by any chance black text on a black background?

Mine is yellow text on a black background but I don't know where the yellow came from, CSS in some unrelated flow maybe.

Thanks for mentioning that.

Well, as you just said: TEXT is yellow.

And the real (main) inject node sets the background as black, and the text.

(As seen here)

When an error happens it is set like this:

If I press the button (or press any of the faulty inject nodes the message sent to the button is:

Oh....!

Thanks.

That isn't THE problem, but I added an extra line to the to button debug node and there is a rogue message coming in there.

THANKS!

Your reply wasn't THE solution, but it made me add an extra line between nodes and found the rogue message.

THANKS AGAIN!

This node was the problem.

Code modified now.

let colour = (msg.payload === "on") ? "lime" : "red"
msg.colour = colour
let colour2 = colour
let msg3 = {}
msg3.colour = null
if (colour == "lime")
{
    colour2 = "green"
}
if (msg.colour == "red")
{
    msg3.background = "red"
    msg3.txt = "Flow error occurred"
    return [msg,msg3]
}
node.status({fill:colour2,shape:"dot",text:"Show"})
return [msg,null]

Just to put it out there.
It was returning msg3 in all cases, when really it should only be if an error happened.

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