Adorkable / node-red-contrib-ui-led

A simple LED status indicator for the Node-RED Dashboard
MIT License
16 stars 12 forks source link

Changing LED color does not apply until input state changes #36

Closed juggledad closed 4 years ago

juggledad commented 5 years ago

Describe the bug Changing the color of the led and redeploying will not change the color of the led when that state is sent to the LED. You must change the state in order to get the new color.

i.e. have two buttons - one sends true the other false. Set false to RED deploy and press the false button. The LED shows RED.

To Reproduce Steps to reproduce the behavior:

  1. create wo buttons - one sends true the other false.
  2. attach them to the LED node
  3. Deploy
  4. press the 'false' button - led turns RED
  5. edit led node and change false to show the color BLUE
  6. deploy
  7. press the 'false' button - led still shows RED
  8. press the 'Tue' button - led turns GREEN
  9. press the 'false' button - led turns BLUE

Expected behavior after the changing the color and deploying, sending the same signal that was last sent should change the color (I.e. in step 7, the color should now be BLUE)

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context

yoiang commented 5 years ago

Hey @juggledad! I just reprod this and it worked using your steps, is it possible there is a mismatch of data types of CSS safe color names? Can you paste a copy of the flow?

juggledad commented 5 years ago

@yoilang here is the flow [{"id":"bfef9c9a.30c61","type":"inject","z":"f574ef05.8053f","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":100,"wires":[["df565fc3.d04b18"]]},{"id":"fd1d6e83.6e509","type":"inject","z":"f574ef05.8053f","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":160,"wires":[["df565fc3.d04b18"]]},{"id":"df565fc3.d04b18","type":"ui_led","z":"f574ef05.8053f","group":"bfedfe2a.8cd11","order":2,"width":0,"height":0,"label":"","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"name":"","x":420,"y":140,"wires":[]},{"id":"bfedfe2a.8cd11","type":"ui_group","z":"","name":"Unused","tab":"29fac533.be68d2","order":1,"disp":true,"width":"6","collapse":false},{"id":"29fac533.be68d2","type":"ui_tab","z":"","name":"Unused ui things","icon":"dashboard","order":3}]

The key to showing the issue is to press eithor the true or false inject button. Next change the color of that choice - so if you press the TRUE button, edit the led node and change the color or 'true'. Now do a deplay and press the TRUE button again. The color doesn't change.

Still a problem with th enode in version 0.2.4

My guess is that because the same input state is sent to the node (pressing 'true' twice - once before and once after the deploy) since the input value hasn't changed it doesn't get processed.

yoiang commented 5 years ago

Oh I see what you mean! Yes, the node currently does not process repeat values. Generally a node has to opt into receiving repeat values for the reason that technically true value signal is still true and unchanged regardless of the way it's displayed to the user.

If we were to be able to control our renderer independent of value changes from your steps as a user I would expect the LED to change immediately rather than needing to wait for the next true statement, what do you think? Lemme think if there is an easy way to accomplish this.

I may be enabling processing of repeat values for a separate feature coming up so your workflow will function from your expected steps, I'll let you know either way!

yoiang commented 4 years ago

Hey @juggledad ! I apologize it took so long to get this fix in, it had been sitting in another change waiting to go in. Finally resolved, if you have a chance let me know if 0.3.0 resolves the issue!