Invert does not invert msg.payload from a switch

#1

If I connect a dashboard switch to a boolean invert, no inversion takes place when I activate the switch. In fact the status of the invert remains as 'unknown' and there is no output in debug. If I use a boolean inject to the switch, msg.payload from teh inject passes through through the witch and the invert functions correctly.

Any ideas what is going on?

Thanks

0 Likes

#2

what does debug direct on the switch report ?
How do you have the switch configured ?

0 Likes

#3

Debug remains empty when I activate the switch and the status indicator which representes the output value of invert remains 'unknown'. The switch is configured to On payload: True, Off payload: False.

0 Likes

#4

Are you sure that a debug on the output of the Switch (not the invert) remains empty when you click the switch?
You say you have On payload True, but what type is that (string, boolean etc)?

0 Likes

#5

Apologies. On the switch, debug reports the correct values according to On (True) and Off (False).

0 Likes

#6

Switch paylaod type is Boolean

0 Likes

#7

Export a flow consisting of the Switch, Invert and the Inject node that works and paste it here. Put a line containing three backtick characters before the flow and after it so it is correctly formatted here.

0 Likes

#8

Also tell us which invert node you are using. I guess you installed one of the node-red-contrib nodes or set of nodes, but which one?

0 Likes

#9
[{"id":"97f739d1.c6a63","type":"ui_switch","z":"3d366024.220ff8","name":"","label":"switch","group":"dfdb85a8.82471","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":480,"y":274,"wires":[["7a1eec6b.3dcedc"]]},{"id":"7a1eec6b.3dcedc","type":"Invert","z":"3d366024.220ff8","name":"Invert","x":680,"y":274,"wires":[["ea03ab2c.43401"]]},{"id":"ea03ab2c.43401","type":"debug","z":"3d366024.220ff8","name":"","active":true,"console":"false","complete":"false","x":898,"y":274,"wires":[]},{"id":"dfdb85a8.82471","type":"ui_group","z":"","name":"Default","tab":"5552dd2e.54054c","disp":true,"width":"6"},{"id":"5552dd2e.54054c","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]

Invert node is from node-red-contrib-boolean-logic 0.0.3

0 Likes

#10

You have not included the Inject node that does make the invert switch change

0 Likes

#11

Apologies again. With the inject nodes:>

[{"id":"7edc9ef0.bebd18","type":"ui_switch","z":"ab3db175.f6be9","name":"","label":"switch","group":"dfdb85a8.82471","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":339,"y":362,"wires":[["1afca744.1c0421"]]},{"id":"1afca744.1c0421","type":"Invert","z":"ab3db175.f6be9","name":"Invert","x":539,"y":362,"wires":[["256867d7.873cf8"]]},{"id":"256867d7.873cf8","type":"debug","z":"ab3db175.f6be9","name":"","active":true,"console":"false","complete":"false","x":757,"y":362,"wires":[]},{"id":"5455b0e5.a9f35","type":"inject","z":"ab3db175.f6be9","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"x":148,"y":290,"wires":[["7edc9ef0.bebd18"]]},{"id":"b62c82e0.a0682","type":"inject","z":"ab3db175.f6be9","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"x":84,"y":437,"wires":[["7edc9ef0.bebd18"]]},{"id":"dfdb85a8.82471","type":"ui_group","z":"","name":"Default","tab":"5552dd2e.54054c","disp":true,"width":"6"},{"id":"5552dd2e.54054c","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]
0 Likes

#12

I can see that it does not work. The issue seems to be that the invert node needs a topic specified in order to work. The Inject node defaults to an empty string but the Switch node defaults to no topic. Add a topic to the switch and it works. I think that is a bug in the Invert node.

1 Like

#13

That's great. Thank you so much for your help (and patience).

0 Likes

#14

please report the issue to the owner of that node. Thanks

0 Likes