pixelit-project / node-red-contrib-pixelit

Node-RED nodes to control the Pixel It easily and comfortably.
https://github.com/o0shojo0o/PixelIt/discussions
MIT License
5 stars 4 forks source link

Only show screen when value above 0 #29

Closed mciaio closed 3 hours ago

mciaio commented 1 year ago

I have several screens working and all based on a value. Let's take solar power as an example. I want it to update and show the solar watts from panels only above 0 watts. When it is 0 watts, I want it to not show in the rotation. I mostly have it working, but instead of going away at 0, it reads the last value forever which is normally 1 watt. I noticed this is possible from the 'days til christmas" screen but can't duplicate it. I am pulling the values from MQTT, is that the problem?

I am using a function node with this code:

`var percent = msg.payload

msg.payload = percent;

if (percent === 0) { msg.show = false } else if (percent > 0) { return msg; }`

oli-19 commented 1 year ago

were you able to fix it? because I have the same problem

mciaio commented 1 year ago

Yes, I did get some help. Here is the code I am using now.

var percent = msg.payload;

if (percent > 0) { msg.show = true; node.status({ fill: "green", shape: "dot", text: "percent > 0, show" }); } else { msg.show = false; node.status({ fill: "red", shape: "dot", text: "percent <= 0, hide" }); } return msg;

oli-19 commented 1 year ago

thank you very much

Metaln00b commented 6 months ago

If you get the error Screen data cannot store! on the Core Node, do not forget to set the msg.duration value to at least 1 anyway :D