Switch node is not working

I trying to get a very simple flow to work. It has a virtual alexa device which is connected at all times to my amazon account. I then have this going to a switch node with String ON and one with string OFF.
These then link to a call service node from home assistant. This node is linked to a smart plug.

If i link virtual device directly to the call service node it works fine. plug comes on. Thats fine but i need to add a switch so i can also turn it off. If i add a debug to the end of the call service node and ask alexa to turn on device, it shows in the debug window. If i also have a debug on the ON leg of the Switch node i get no output. Its almost like the switch node is broken, yet i have replaced it a few times.

Hello,
Can you show us a screenshot of the output you see in the debug tab when a debug node is directly connected to the virtual device and another one of your switch node settings? This would be really helpful to be able to understand your problem and find possible solutions.

Johannes

Thanks for the quick reply. I cant show you any debug info that comes out the switch legs. It doesn't create any. Attached is some screen shots.

switch settings

virtual device debug virtual device settings

I know the link has been removed from switch to the plug devices. That was just for testing and debugging.

Your switch node is set up to check msg.payload for ON or OFF but if you look at what you are getting in the msg.payload its not a string but an object. This object includes a powerState property which has this information. So you will have to change your switch node to check for the ON and OFF strings in msg.payload.powerState instead for the check to work.

Forgive me, i'm very new to this. So is that changing then the property to the msg.payload.powerstate in the switch node? I don't need a chnage node?

I just tried it and its working. Such a small thing and it worked. I been messing for hours on trying to work this out. Thanks do much.

1 Like

Have a read of the docs page Working with Messages, that should prove very helpful. Also, if you have not done so already, then watch right through the Node-red Essentials videos linked to the the docs. You will soon get back the hour or so spent doing that.

1 Like

Thanks colin. I'll do that. It will probably inspire lots of cool ideas for automatons. Trouble is i don't have many plugs, switches etc at the moment. I'm hoping to move house in 2021 and really going to go for it.

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