Change to another output on input

So I'm new to all the programming. :slight_smile:

I learn a lot from reading what all you make.
And thanks for that.
But now i need something and is hoping that some of you can help me learn this.

I need a function node, where I can change output for all payloads.

So if I input with a msg.payload = right_click
I want to have the output for all other payloads lead to another output.

I have a remote, and want to change lights, so if i push toggle, the lamp on the table toggles,
then i "right_click" and the toggle can now turn of and on the light on the wall.
Hope some of you can help me out, and thanks in advance. :slight_smile:

I also have a "left_click" so if I can change back and forth that is nice, and i have more then 2 lamps. :slight_smile:

Perhaps a switch node can help you out.

I can't se a way, to make the switch that way. Maby it's just me.

Try this flow

[{"id":"ca9f5398.bdfe38","type":"inject","z":"5120f156.f4f4e","name":"","topic":"","payload":"left_click","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":324,"y":240,"wires":[["b83bad90.84fe9"]]},{"id":"8f6789e8.968ba","type":"inject","z":"5120f156.f4f4e","name":"","topic":"","payload":"right_click","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":324,"y":288,"wires":[["b83bad90.84fe9"]]},{"id":"b83bad90.84fe9","type":"switch","z":"5120f156.f4f4e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"left_click","vt":"str"},{"t":"eq","v":"right_click","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":506,"y":264,"wires":[["70163f18.6dd9f8"],["4170e584.60c0c4"]]},{"id":"70163f18.6dd9f8","type":"debug","z":"5120f156.f4f4e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":694,"y":240,"wires":[]},{"id":"4170e584.60c0c4","type":"debug","z":"5120f156.f4f4e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":694,"y":288,"wires":[]}]

Will do, once i get back to my pc. In an hour or so. But thanks for helping. :blush:

I looked at it now, but that i understand.

My need is more the way of controlling all the data with a single switch, so i can put ind "turn_on_light" to lamp1, then switch and put the "turn_on_light" to lamp2. :slight_smile:

Perhaps you should provide some data we can work with, or what the input is.
Do you mean switch on the dashboard, physical switch, logical switch ?

What is your input, and what do you want as output.

I have an IKEA remote, the round one,with 5 physical switches.
I wanna turn on my lights with toggle, then when i press "arrow-right"
it switches to another light, then when i press the "arrow-right" again, it switches to the 3 light.

I have found a way to do it, with switches, but i can only switch one way, not the other way around. :slight_smile:

I have mad this, as a subflow.

[{"id":"b1f41687.9504c8","type":"switch","z":"ab257b02.ffd96","name":"Set flow.toggle-me","property":"toggle-me","propertyType":"flow","rules":[{"t":"eq","v":"3","vt":"str"},{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":970,"y":380,"wires":[["3dbf00d.a4d688"],["f957fd1e.0b504"],["ab9e5ec9.2b9d2"]]},{"id":"3dbf00d.a4d688","type":"change","z":"ab257b02.ffd96","name":"Set to 1","rules":[{"t":"set","p":"toggle-me","pt":"flow","to":"1","tot":"str"},{"t":"set","p":"toggle-me","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":340,"wires":[[]]},{"id":"58a85b9.60326a4","type":"inject","z":"ab257b02.ffd96","name":"Startup","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":1060,"y":300,"wires":[["3dbf00d.a4d688"]]},{"id":"f47f1b5.f83efe8","type":"inject","z":"ab257b02.ffd96","name":"Toggle","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":770,"y":480,"wires":[["b1f41687.9504c8"]]},{"id":"2c8ffd11.771f9a","type":"inject","z":"ab257b02.ffd96","name":"Do something","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":770,"y":120,"wires":[["54018814.d1b928"]]},{"id":"f6c6173a.0989c8","type":"switch","z":"ab257b02.ffd96","name":"1,2,3","property":"toggle-me","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"},{"t":"eq","v":"3","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":1190,"y":200,"wires":[["6bb47044.0aed3"],["dd379602.c5c89"],["71b46800.9ae3b8"]]},{"id":"54018814.d1b928","type":"change","z":"ab257b02.ffd96","name":"Fecth state","rules":[{"t":"set","p":"toggle-me","pt":"msg","to":"toggle-me","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":200,"wires":[["f6c6173a.0989c8"]]},{"id":"f957fd1e.0b504","type":"change","z":"ab257b02.ffd96","name":"Set to 2","rules":[{"t":"set","p":"toggle-me","pt":"flow","to":"2","tot":"str"},{"t":"set","p":"toggle-me","pt":"msg","to":"2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":380,"wires":[[]]},{"id":"ab9e5ec9.2b9d2","type":"change","z":"ab257b02.ffd96","name":"Set to 3","rules":[{"t":"set","p":"toggle-me","pt":"flow","to":"3","tot":"str"},{"t":"set","p":"toggle-me","pt":"msg","to":"3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":420,"wires":[[]]},{"id":"130f9132.2540b7","type":"switch","z":"ab257b02.ffd96","name":"","property":"payload.action","propertyType":"msg","rules":[{"t":"cont","v":"toggle","vt":"str"},{"t":"cont","v":"arrow_right_click","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":770,"y":280,"wires":[["54018814.d1b928","4f6d02a2.ab779c"],["b1f41687.9504c8","624ce1dd.5dca38"]]},{"id":"71b46800.9ae3b8","type":"function","z":"ab257b02.ffd96","name":"toggle","func":"msg.payload = { \"state\":\"toggle\"};\nreturn msg;","outputs":1,"noerr":0,"x":1350,"y":240,"wires":[[]]},{"id":"dd379602.c5c89","type":"function","z":"ab257b02.ffd96","name":"toggle","func":"msg.payload = { \"state\":\"toggle\"};\nreturn msg;","outputs":1,"noerr":0,"x":1350,"y":200,"wires":[[]]},{"id":"6bb47044.0aed3","type":"function","z":"ab257b02.ffd96","name":"toggle","func":"msg.payload = { \"state\":\"toggle\"};\nreturn msg;","outputs":1,"noerr":0,"x":1350,"y":160,"wires":[[]]},{"id":"624ce1dd.5dca38","type":"debug","z":"ab257b02.ffd96","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":380,"wires":[]},{"id":"4f6d02a2.ab779c","type":"debug","z":"ab257b02.ffd96","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":700,"y":200,"wires":[]}]

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