On/off Ikea Tradfri with Loxone

Hello all,

I have started with NR few hours ago...

I am trying to achieve simple thing. I would like to control Ikea sockets connected to Ikea Tradfri gateway via Loxone. I have setup NR and added two paletts node-red-contrib-ikea-tradfi and node-red-contrib-loxone and connected them to the Ikea Tradfri gateway and Loxone miniserver.

I can manage Ikea socket via simple inject on and off to the socket and it is working fine.

I have created virtual switch in Loxone config and I can see it in NR. If I press it in Loxone app, it sends 0 and 1 to NR, I can see it via debug.

I wrote function to convert 0/1 to off/on. If I see debug output from function it successfully converts 0/1 to off/on

if (msg.payload == 0) {
msg.payload = "off";
return msg;
}
else if (msg.payload == 1) {
msg.payload = "on";
return msg;
}
return null;

But if I connect output from the function to the Ikea socket I have this error message:

Invalid message received, using node config!
Invalid value "Lampička Honza" supplied to : TradfriSwitchControlMessage/0: Partial<{ topic: (Int | Array), payload: TradfriSwitchControlAction }>/topic: (Int | Array)/0: Int
Invalid value "Lampička Honza" supplied to : TradfriSwitchControlMessage/0: Partial<{ topic: (Int | Array), payload: TradfriSwitchControlAction }>/topic: (Int | Array)/1: Array

What am I doing wrong?

Thanks

Jan K.

Welcome to the forum @jkosatko

Feed the inject nodes that work to switch it on/off into a debug node and show us what they show. Then feed the messages that do not work into a debug node and show us what they show.

This is result of inject to switch it on:

image

this is output form Loxone virtual switch button:

image

this is result of my "convert" function:

image

which is in addition strange, because it should be "on" as per function:

image

Thanks

This is both "environments" separated:


and this is when I receive error message:

It looks as if it is complaining about msg.topic, which is shown at the top of your debug 1 node. In the debug output there is no topic. Have a look at the help text for the node and see what the topic is for. It may be that you just need to add delete msg.topic in your function.

For the problem with the function not recognising the payload correctly, unfortunately you have not posted an image showing both debug 2 and debug 1 outputs together.

Thanks!
I have changed "function" to the "change" to resolve detection issue and added deletion for the msg.topic and it works fine.

1 Like

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