Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On-screen shape and fill color #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bartbutenaers
Copy link

Dear Jacques (@Jacques44),

Thanks for sharing this contribution!

In my current case, my messages only contain the status text (but no shape or fill color). E.g. when I select a new scene in my dashboard ('at home', 'sleeping', 'at work', ...), a 'blue ring' should be displayed for all these scenes.

To accomplish this, I have added two dropdowns to your properties screen:

image

To make sure that no existing flows are broken by this enhancement, I used following approach:

  • The dropdowns are optional (there is a blanc line in the selection list): no values need to be selected.
  • When a message arrives containing a msg.fill or a msg.shape field, those fields will overrule the dropdown values.

Here is my test flow:
image

[{"id":"486a63eb.1f6d6c","type":"bigstatus","z":"f711b886.a58148","name":"","locale":"","shape":"","fill":"","show_date":false,"show_duration":false,"x":836.7656173706055,"y":488.6132869720459,"wires":[[]]},{"id":"59b4705e.694bb","type":"inject","z":"f711b886.a58148","name":"Test 1","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":422.16396713256836,"y":427.0782096982002,"wires":[["42a7642e.6e6cbc"]]},{"id":"42a7642e.6e6cbc","type":"change","z":"f711b886.a58148","name":"Set error","rules":[{"t":"set","p":"payload","pt":"msg","to":"Major problem","tot":"str"},{"t":"set","p":"fill","pt":"msg","to":"red","tot":"str"},{"t":"set","p":"shape","pt":"msg","to":"ring","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":591.1522674560547,"y":426.99999886751175,"wires":[["486a63eb.1f6d6c"]]},{"id":"2ae62885.343178","type":"inject","z":"f711b886.a58148","name":"Test 2","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":422.92958068847656,"y":476.27733689546585,"wires":[["47574abe.925724"]]},{"id":"47574abe.925724","type":"change","z":"f711b886.a58148","name":"Set warning","rules":[{"t":"set","p":"payload","pt":"msg","to":"Small warning","tot":"str"},{"t":"set","p":"fill","pt":"msg","to":"yellow","tot":"str"},{"t":"set","p":"shape","pt":"msg","to":"ring","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":601.9178810119629,"y":476.1991260647774,"wires":[["486a63eb.1f6d6c"]]},{"id":"6465588a.c2f7b8","type":"inject","z":"f711b886.a58148","name":"Test 3","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":420.92958068847656,"y":525.2773368954659,"wires":[["636f6191.afdb"]]},{"id":"636f6191.afdb","type":"change","z":"f711b886.a58148","name":"Set normal","rules":[{"t":"set","p":"payload","pt":"msg","to":"Everything fine","tot":"str"},{"t":"set","p":"fill","pt":"msg","to":"green","tot":"str"},{"t":"set","p":"shape","pt":"msg","to":"dot","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":599.9178810119629,"y":525.1991260647774,"wires":[["486a63eb.1f6d6c"]]},{"id":"11921d15.09c7d3","type":"inject","z":"f711b886.a58148","name":"Test 4","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":415.765625,"y":624.75,"wires":[["6a18c419.64418c"]]},{"id":"6a18c419.64418c","type":"change","z":"f711b886.a58148","name":"SET ONLY TEXT","rules":[{"t":"set","p":"payload","pt":"msg","to":"Small warning","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":614.7539253234863,"y":624.6717891693115,"wires":[["486a63eb.1f6d6c"]]},{"id":"1b5b797f.27ee67","type":"comment","z":"f711b886.a58148","name":"Legacy tests","info":"","x":417.015625,"y":386.60546875,"wires":[]},{"id":"fac58daa.a0687","type":"comment","z":"f711b886.a58148","name":"New test of message without shape or color","info":"","x":512.765625,"y":585.75,"wires":[]}]

Hopefully you like this contribution.
Hope to hear from you soon !

Kind regards,
Bart

Enhancement to allow both the shape and the fill color to be specified in the properties view.  These on-screen properties can be overruled by the message properties.
Enhancement to allow both the shape and the fill color to be specified in the properties view.  These on-screen properties can be overruled by the message properties.
Enhancement to allow both the shape and the fill color to be specified in the properties view.  These on-screen properties can be overruled by the message properties.
@dceejay
Copy link

dceejay commented Aug 10, 2017

Bart, by default we prefer the msg to only override properties if the property is not set in the config. I.E. if the user has specified something that is what it should be.

Screen properties (set by user) have higher priority than message properties: both for shape and fill.
Screen properties (set by user) have higher priority than message properties: both for shape and fill.
@bartbutenaers
Copy link
Author

@dceejay, @Jacques44,

I've added a small change to make sure the config properties (when set) will override the message properties, and not the other way around. The readme.md file is also updated.

Kind regards,
Bart

@Jacques44
Copy link
Owner

Hello,
All the devs I've made with dual config/msg configuration have the following behaviour

  1. config set by the IHM is the default
  2. msg, if set, will override to enhance the defaults

By reading your messages, I can see that rules for overriding require more messages 👍 👎 !

As I don't want to be too restrictive, I think a way to solve this is to add a special "overridable" flag to trigger a behaviour or the other...

What to you think of that?

@bartbutenaers
Copy link
Author

Dear Jacques (@Jacques44),

Thanks for responding !

Good question. Some of my own contributions also behave like yours: if the msg contains some configuration, it will override the default behaviour from the user config. Didn't knew at the time being that the preferred Node-Red behaviour was the other way around ... And now I cannot change it anymore, otherwise existing flows would become corrupt ;-( For my new contributions I will take into account there standard.

The checkbox might indeed solve the issue. But then your contribution is also not following 100% the Node-Red standard ... So it might be enough to add an extra note to your node's help info (to indicate which setting has highest priority). But perhaps you or @dceejay have another idea about this. Or perhaps you could post this question on the forum, because we won't be the only 2 contributors on this planet wondering how to solve this.

Kind regards,
Bart

@lucaberta
Copy link

Hi @bartbutenaers @Jacques44 @dceejay,

I have just come across the bigstatus node after a quick search on a way to show something visual on the Node-RED flow page, and it appeared like a very good node to use for my purposes.

I could not see if a quick way to set the shape and color of the icon was possible, as clearly this is something that your other "big nodes" do by the default, and since I wanted a quick and easy way to also have an icon displayed.

From what I can @bartbutenaers has found a quick way to do it, albeit it's a static shape and color for what I can see, rather then dependent on the value of the message passed.

I would love to see this pull request merged, to try to use it, unless @Jacques44 would rather keep this nifty feature out of his code, in order to leverage the control of the icon upstream.

Thanks, Luca

@lucaberta
Copy link

Disregard my comment, it's not worth to effort to rehash this.

A quick function node is more than enough, and it can be used to have the choice of color and shape of the node status icon directly in one single node. The examples in the node description page were good enough for me, a relative newbie to Node-RED.

Thanks, Luca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants