I am trying to display an error if the value is less than or equal to zero, but it for some reasons isn't working. I have tried searching, but no luck. I know it is probably something very small that needs to be fixed though I am not able to figure it out. I have been struggling on this for 2 days now. Any help will be appreciated. I am not sure if there is a way to add a node or display it within the code.
I prefer if I can add a separate node to display error. I have attached my flow below. If someone can please help me with the solution for this.
[{"id":"cb816b24.fe39e8","type":"inject","z":"350d0535.68069a","name":"LuxReading","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Lux:340","payloadType":"str","x":210,"y":360,"wires":[["a47c5a17.2edfb8"]]},{"id":"aea09e2c.4c494","type":"split","z":"350d0535.68069a","name":"","splt":":","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":530,"y":360,"wires":[["7fcd5036.5961b"]]},{"id":"7fcd5036.5961b","type":"switch","z":"350d0535.68069a","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":690,"y":360,"wires":[["29a1d2c9.5eefee"]]},{"id":"29a1d2c9.5eefee","type":"function","z":"350d0535.68069a","name":"Comparison ","func":"msg.payload = Number (msg.payload);\nmsg.Lux; // new stored value\nvar actualLux = 400;\n\n//comapring reading and the actual value for red\nif(msg.payload <= 0) // if less than or equal to zero then it should\n // disaply error\n{\n msg.Lux = \"Something is wrong\";\n return msg;\n}\nelse if (msg.payload == actualLux) // keeps it same if matches\n{\n return msg;\n}\nelse if(msg.payload > actualLux) // adjust the value accordingly\n{\n correction = msg.payload - actualLux;\n msg.Lux = msg.payload - correction;\n return msg;\n}\nelse if(msg.payload < actualLux) // adjust the value accordingly\n{\n correction = actualLux - msg.payload;\n msg.Lux = msg.payload + correction;\n return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":850,"y":360,"wires":[["a4c764cf.6e1a38"]]},{"id":"a4c764cf.6e1a38","type":"debug","z":"350d0535.68069a","name":"Lux_Value","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1040,"y":360,"wires":[]},{"id":"a47c5a17.2edfb8","type":"switch","z":"350d0535.68069a","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Lux","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":360,"wires":[["aea09e2c.4c494"]]}]
Thank you!!