Dashboard Switch for status and control

You need to look up what the bulb requires. I have no experience of the bulb you mention.

1 Like

Is there a way to solve that?
I mean a switch should show the actual state of the light and the switch should also have the possibility to change the light on or off.
I mean I'm not a programmer but it doesn't sounds like rocket science.

Yes, configure the switch as I have advised. That should solve it. Why will you not show the debug information that I keep asking for? What is coming out of the switch and what is going back into it in the failing condition? I can't do any more till you post that information.

1 Like

You mean I should replace the change-node with this one

in a function-node?
I will post the debug information as soon as possible.

Read my post again. It won't make any difference to the way it works, it is just a more efficient way of doing what you are doing in a Change and a Function node. You can change it if you want to but it is nothing to do with the problem.

1 Like

Now I have configured the switch like you said but its not working.


Thats from the switch debug_out

msg : Object
object
payload: "false"
socketid: "03PCWf1zELrqw5UcAAAE"
_msgid: "aeaef91d.9a9448"

What is not working? Videos are useless. Tell me what happens to the real light. Also I need to see what is coming back into the front of the switch as I have asked many times.

I cannot turn off the light by using the switch because the switch is, if the real light is on, always getting the input "true".

If the real light is on the switch input is

msg.payload : string[4]
"true"

I don't fully understand. If you switch the light off via external means what comes in to the switch and what does the switch then show, and if you switch the light off by external means what comes in to the switch and what does the switch then show?

1 Like

I don't fully understand you either :wink:
Let's start from the beginning again.
I have a smart bulb where the power (electric) is always on (like hue lights).
I'm able to control the light via deconz (Phoscon).
For deconz there's the node I've added to combine node red and deconz.
The deconz-input node is always sending the status of the selected light.
There's the function which is sending status to the switch (if the input-node sends "true" , the switch is set to true, else, the switch sends a "false" ).
The switch sends the true or false message to the deconz-out node. That's it.
What comes from the deconz-input to the switch

27.1.2021, 22:52:51node: debugh_switch_input
msg.payload : string[4]
"true"

And that is what comes out from the switch if I try to move the switch slider to turn the light of.

27.1.2021, 22:52:58node: debug_switch_output
msg : Object
object
payload: "false"
socketid: "0cy1y2Yeb5H8cHn7AAAF"
_msgid: "afa730ed.9fbb8"

Let's try and simplify it so I can understand.

  1. Disconnect the wire going into the ui_switch node.
    Set the ui_switch to Pass Through messages.
    Now, if you click the ui_switch off and on does the real light go off and on?

  2. Assuming that works then (with the wire into the ui_switch still disconnected) connect a debug node showing what is coming out of the function node to the left of the switch node. What does that show as you switch the ui_switch off and on?

  3. Post your current flow so I can check what you have now (leave off the Deconz nodes, I just have to keep deleting them and deleting the config node, which is annoying).

1 Like

It is late now, so I have to go. I will have a look at what you have posted in the morning.

1 Like

Thank you for not giving up on me! :smile:

Scenario1: Light is off, switch is off --> Press the switch to turn the light on --> Switch is on, light is on
Scenario2: Light is on, switch is on --> Press the switch to turn the light off --> Switch goes off light stays on
Scenario3: Light is off, switch is on --> Press the switch to turn the light off --> Switch goes off light goes on

  1. Logs from the debug node which is comming out of the function node (wire is disconnected into the ui-switch)

To Scenario1:

28.1.2021, 15:50:15node: debug_function_out
msg.payload : string[4]
"true"

To Scenario2:
Nothing

To Scenario3:

28.1.2021, 15:51:47node: debug_function_out
msg.payload : string[4]
"true"
[{"id":"29255051.dc251","type":"tab","label":"Dashboard UI","disabled":false,"info":""},{"id":"c4466cf7.5066f","type":"ui_switch","z":"29255051.dc251","name":"","label":"switch_light1","tooltip":"","group":"16ca559d.db74ea","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":850,"y":240,"wires":[["2ac55486.b107fc"]]},{"id":"956b86bb.f530c8","type":"change","z":"29255051.dc251","name":"","rules":[{"t":"change","p":"payload.on","pt":"msg","from":"true","fromt":"bool","to":"true","tot":"str"},{"t":"change","p":"payload.on","pt":"msg","from":"false","fromt":"bool","to":"false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":240,"wires":[["fa3731e3.be23"]]},{"id":"fa3731e3.be23","type":"function","z":"29255051.dc251","name":"","func":"if (msg.payload.on == \"true\"){\nmsg.payload = \"true\";\n}\nelse {\nmsg.payload = \"false\";\n}\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":680,"y":240,"wires":[["54c34b8e.d6b474"]]},{"id":"2ac55486.b107fc","type":"debug","z":"29255051.dc251","name":"debug_switch_output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1060,"y":300,"wires":[]},{"id":"54c34b8e.d6b474","type":"debug","z":"29255051.dc251","name":"debug_function_out","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":460,"wires":[]},{"id":"16ca559d.db74ea","type":"ui_group","name":"Standard","tab":"7874e5cb.93b9ec","order":1,"disp":true,"width":"6","collapse":false},{"id":"7874e5cb.93b9ec","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

You said in post #7

But it appears that is no longer the case. What has changed with the switch -> light control since then? You need to get that working again before doing anything else.

Ah i know what the problem was:
If i set the payload from the switch to string --> I can turn on the light but i cant turn it off.
If i set the payload from the switch to boolean --> Turn on and off works.
The Scenarios i´ve postet the switch payload was set to string. Should i test again with boolean?

Yes, change the switch to output booleans, and take out the function node and change the Change node so it is configured like this
image
It doesn't need to change the values, they should stay as boolean, so it is just necessary to Move msg.payload.on To msg.payload. Then retry the 1 and 2 from my earlier post. If they look OK then change the switch to NOT pass through and to Show State of Input. Then join the input wire up and see what happens.

IT WORKS! Thanks a lot for your help and pattience. Without the function-node plus the changes for the switch-node its finally working!

[{"id":"29255051.dc251","type":"tab","label":"Dashboard UI","disabled":false,"info":""},{"id":"c4466cf7.5066f","type":"ui_switch","z":"29255051.dc251","name":"","label":"switch_light1","tooltip":"","group":"16ca559d.db74ea","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":990,"y":180,"wires":[[]]},{"id":"956b86bb.f530c8","type":"change","z":"29255051.dc251","name":"","rules":[{"t":"move","p":"payload.on","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":180,"wires":[["c4466cf7.5066f"]]},{"id":"16ca559d.db74ea","type":"ui_group","name":"Standard","tab":"7874e5cb.93b9ec","order":1,"disp":true,"width":"6","collapse":false},{"id":"7874e5cb.93b9ec","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

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