Simple question from a beginner

I'm a node red beginner. I'm trying to solve what I think is a simple problem.
An illumination sensor (MQTT) supplies the brightness as a value between 0 and 15000.
The goal is a NODE with an output (true/false) which outputs true from a certain brightness value. switches back to false when the brightness value falls below.
my attempt is:

[{"id":"e0c6a123.6cfe58","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"710896e58f65c071","type":"mqtt in","z":"e0c6a123.6cfe58","name":"bre_snsbx170_lux","topic":"/BRE-SnsBx170/STAT/Lux","qos":"1","datatype":"auto-detect","broker":"e314300a.e8a55","nl":false,"rap":true,"rh":0,"inputs":0,"x":130,"y":100,"wires":[["aafe50798cd70349"]]},{"id":"18e506ec766aa592","type":"debug","z":"e0c6a123.6cfe58","name":"IstHell","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":930,"y":100,"wires":[]},{"id":"435b8e162aa6632e","type":"inject","z":"e0c6a123.6cfe58","name":"Daylight-1k","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1000","payloadType":"num","x":160,"y":200,"wires":[["aafe50798cd70349"]]},{"id":"ae85673a31a3fa68","type":"debug","z":"e0c6a123.6cfe58","name":"debug 18","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":680,"y":220,"wires":[]},{"id":"0dd661bc63f89f66","type":"inject","z":"e0c6a123.6cfe58","name":"Daylight-2k","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2000","payloadType":"num","x":131.48333740234375,"y":158.48333740234375,"wires":[["aafe50798cd70349"]]},{"id":"aafe50798cd70349","type":"switch","z":"e0c6a123.6cfe58","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"1500","vt":"str"},{"t":"lte","v":"1500","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":430,"y":120,"wires":[["7b0d2d7dc631bb54","ae85673a31a3fa68"],["7878c77ba3104cf6","ae85673a31a3fa68"]]},{"id":"7b0d2d7dc631bb54","type":"change","z":"e0c6a123.6cfe58","name":"Gr1500","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"Gr1500","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":100,"wires":[["18e506ec766aa592"]]},{"id":"7878c77ba3104cf6","type":"change","z":"e0c6a123.6cfe58","name":"Kl1500","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"Kl1500","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":140,"wires":[["a7164ec93382d121"]]},{"id":"a7164ec93382d121","type":"debug","z":"e0c6a123.6cfe58","name":"IstDunkel","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1000,"y":140,"wires":[]},{"id":"e314300a.e8a55","type":"mqtt-broker","name":"Server-Mqtt","broker":"192.168.10.136","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"3","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

ni node red it looks like this:

the problem is the Change-Node never go to false. the true at the output is only ever updated.
what am I doing wrong?

In the switch node change the selection options to numbers (0-9) rather than text (a-z)

image

Depending on what you are doing with the output, you may need some hysteresis.

Otherwise when the light level is very close to the threshold value it may keep switching between the light and dark outputs. So if you are driving a light for example you may find it keeps switching on and off rapidly.

An easy way to do that is to leave a "dead band" between the two values where no action is taken.

payload > 1500 light
payload <= 1400 dark

Then anywhere in between does nothing.

hallo Buckskin,
Thanks very much,
I adjusted it, this doesn't change the problem with the two change nodes, they both remain on true.

Neither of your change nodes sets msg.payload to false.

Give this a try

[{"id":"710896e58f65c071","type":"mqtt in","z":"e0c6a123.6cfe58","name":"bre_snsbx170_lux","topic":"/BRE-SnsBx170/STAT/Lux","qos":"1","datatype":"auto-detect","broker":"e314300a.e8a55","nl":false,"rap":true,"rh":0,"inputs":0,"x":105,"y":105,"wires":[["aafe50798cd70349"]]},{"id":"18e506ec766aa592","type":"debug","z":"e0c6a123.6cfe58","name":"IstHell","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":910,"y":135,"wires":[]},{"id":"435b8e162aa6632e","type":"inject","z":"e0c6a123.6cfe58","name":"Daylight-1400","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1400","payloadType":"num","x":145,"y":210,"wires":[["aafe50798cd70349"]]},{"id":"ae85673a31a3fa68","type":"debug","z":"e0c6a123.6cfe58","name":"debug 18","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":680,"y":220,"wires":[]},{"id":"0dd661bc63f89f66","type":"inject","z":"e0c6a123.6cfe58","name":"Daylight-1500","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1500","payloadType":"num","x":141.48333740234375,"y":158.48333740234375,"wires":[["aafe50798cd70349"]]},{"id":"aafe50798cd70349","type":"switch","z":"e0c6a123.6cfe58","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"1500","vt":"str"},{"t":"lte","v":"1400","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":430,"y":120,"wires":[["7b0d2d7dc631bb54","ae85673a31a3fa68"],["7878c77ba3104cf6","ae85673a31a3fa68"]]},{"id":"7b0d2d7dc631bb54","type":"change","z":"e0c6a123.6cfe58","name":"Gr1500","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"Gr1500","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":675,"y":105,"wires":[["18e506ec766aa592"]]},{"id":"7878c77ba3104cf6","type":"change","z":"e0c6a123.6cfe58","name":"Kl1500","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"Kl1400","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":675,"y":150,"wires":[["18e506ec766aa592"]]},{"id":"e314300a.e8a55","type":"mqtt-broker","name":"Server-Mqtt","broker":"192.168.10.136","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"3","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

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