mjwwit / node-red-contrib-ikea-tradfri

Node-RED nodes to get updates from and control devices connected to an IKEA TRADFRI gateway
3 stars 3 forks source link

Switch control error messages in debug log #10

Closed Soiski71 closed 3 years ago

Soiski71 commented 3 years ago

Hi, I'm having similar issue as JBlond on getting the switch to accept the command. Actually it works ON/OF what ever code you send to it but gives annoying debug error. The light Control accepts to same code with out any issues.

Here the full message I send in inject.

6/24/2021, 9:55:28 PMnode: cf91895d.8001a8 msg : Object object _msgid: "30b3a0a4.a82e3" payload: object topic: array[1] payload: "on"

Either I'm really simple and alone in the universe but I really could not figure the role of the topic number ? Should it actually refere to the payload.instanceId ref number or is it just a random number :)

Help much appriciated and hey EXCELLENT WORK !!

mjwwit commented 3 years ago

I'm afraid I'll need a bit more detail. The full message you mentioned contains objects which probably contain the problem. You can easily copy the full message (including nested objects) by clicking the copy button that appears when you hover over a debug message: image

The topic property in the message contains a list of instanceIds or groupIds. These are basically unique identifiers given to Tradfri devices and rooms that are connected to the gateway.

Soiski71 commented 3 years ago

Here, Sorry thought I managed to get everything last time :)

{"_msgid":"660271a7.a073c","payload":{"topic":[1],"payload":"on"}}

Best Regards, Sami

mjwwit commented 3 years ago

I see the problem. You put the object specified in the documentation into the payload property of the message. The documentation is specifying the entire message though. You should update the nodes sending messages to the switch-control to look like this:

{
  "_msgid": "660271a7.a073c",
- "payload": {"topic": [1], "payload": "on"}
+ "topic": [1],
+ "payload": "on"
}
Soiski71 commented 3 years ago

Hi Thanks:

Still with this I get

{"_msgid":"3c58d8ed.b0b678","topic":"[1]","payload":"on"}

error: Invalid message received, using node config! Invalid value "[1]" supplied to : TradfriStateInputMessage/0: Partial<{ topic: (Int | Array) }>/topic: (Int | Array)/0: Int Invalid value "[1]" supplied to : TradfriStateInputMessage/0: Partial<{ topic: (Int | Array) }>/topic: (Int | Array)/1: Array

Funnily enough I made a typo when writing the first time "topic" as "toepic" and that version does not give me any errors... So actually sending only msg.payload ="on" does the trick with out error.

{"_msgid":"c5a54a2d.e3a798","payload":"on"}

mjwwit commented 3 years ago

You made a small error in your payload: you should be using "topic": [1] instead of "topic": "[1]"

Soiski71 commented 3 years ago

Hi Michael,

Agree seems that Topic needs to be number format and payload text string.

What is the function of the Topic here as it seems to work also without it ?