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

Switching lights on and off #16

Closed ahartman closed 2 years ago

ahartman commented 3 years ago

I am using your code reliably to set color temperature and/or brightness for white-spectrum bulbs, no problems here.

However, I am having huge problems in switching lights on or off.

  1. With syntax 'isOn', I can switch lights off but not on. In attached image 1 , the first 'off' message works, the second 'on' messages has no effect.
  2. With syntax 'payload' : 'on' (or 'off'), I get an error message, see attached image 2.
  3. I hope you can help me out. Regards, ahartman, Belgium

image 1 image 2
ChristophA commented 3 years ago

To switch the lights on and of I'm using a JSON formatted payload. For on: { "onOff": true } For off: { "onOff": false }

ahartman commented 2 years ago

Dear mjwwit,

From time to time, I see the error in the attached first screen image. I do not define anything on the node but the message sent to your node is good and contains valid Tradfri IDs. There seems to be no pattern as to when this shows up; it looks to happen more when I am working on the Node Red code and lots of messages get sent to Tradfri.

Then, not very often, I get another error 'invalid message' as seen in the second screen image. The message sent to the Tradfri gateway is at the top and similar message further below do not lead to the same error.

Any ideas? Regards, ahartman, belgium

Schermafbeelding 2021-10-11 om 06 55 56 Schermafbeelding 2021-10-11 om 13 23 13
ahartman commented 2 years ago

Dear mjwwit,

I found out when the error message 'invalid message' comes up. When you specify a fully defined control node, you only need to send 'something' to kick it into action, no need to specify a topic with IDs or a payload with JSON. That leads to the error message. So, the node still wants to receive a 'valid' message although it does not need any information in there.

Regards, ahartman, belgium

Schermafbeelding 2021-10-12 om 13 10 03
mjwwit commented 2 years ago

From time to time, I see the error in the attached first screen image. I do not define anything on the node but the message sent to your node is good and contains valid Tradfri IDs. There seems to be no pattern as to when this shows up; it looks to happen more when I am working on the Node Red code and lots of messages get sent to Tradfri.

Then, not very often, I get another error 'invalid message' as seen in the second screen image. The message sent to the Tradfri gateway is at the top and similar message further below do not lead to the same error.

Any ideas? Regards, ahartman, belgium

This is a different issue and looks like #19. Please add information relevant to that problem to the conversation at #19.

mjwwit commented 2 years ago

I found out when the error message 'invalid message' comes up. When you specify a fully defined control node, you only need to send 'something' to kick it into action, no need to specify a topic with IDs or a payload with JSON. That leads to the error message. So, the node still wants to receive a 'valid' message although it does not need any information in there.

The way this node works is that it combines the details you enter in the configuration with the details from the message is receives. This allows you to either configure the devices you want to control in the node, or dynamically control them in the message you send to the node. If, however, you don't configure anything in the node and your message also doesn't specify anything properly, the node does not know what to do.

So this is what's going on (from what I can see in the error message):

  1. The node receives a message that does it does not understand. In this case it's expecting either a number or a list of numbers in the message topic, but instead it's receiving a list with 2 empty bits of text ("").
  2. The node makes note of this by letting you know in the debug log (this is the error you see)
  3. The node tries to default to what you've configured in the node configuration. However, if you haven't configured anything there it will end up doing nothing.

If you want to get rid of this error message you will need to ensure that the messages your send match the requirements. The node documentation displays what it's expecting and where.

ahartman commented 2 years ago

As you can see in the attached screen image, I specified a group and the action ‘on’. If I understand correctly, there does not to be any additional information in the incoming msg; the node should know what to do and not send an error in my opinion or do i have this wrong?

Regards, ahartman

Op 13 okt. 2021, om 09:59 heeft Michael de Wit @.***> het volgende geschreven:

I found out when the error message 'invalid message' comes up. When you specify a fully defined control node, you only need to send 'something' to kick it into action, no need to specify a topic with IDs or a payload with JSON. That leads to the error message. So, the node still wants to receive a 'valid' message although it does not need any information in there.

The way this node works is that it combines the details you enter in the configuration with the details from the message is receives. This allows you to either configure the devices you want to control in the node, or dynamically control them in the message you send to the node. If, however, you don't configure anything in the node and your message also doesn't specify anything properly, the node does not know what to do.

So this is what's going on (from what I can see in the error message):

The node receives a message that does it does not understand. In this case it's expecting either a number or a list of numbers in the message topic, but instead it's receiving a list with 2 empty bits of text (""). The node makes note of this by letting you know in the debug log (this is the error you see) The node tries to default to what you've configured in the node configuration. However, if you haven't configured anything there it will end up doing nothing. If you want to get rid of this error message you will need to ensure that the messages your send match the requirements. The node documentation displays what it's expecting and where.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mjwwit/node-red-contrib-ikea-tradfri/issues/16#issuecomment-942031817, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFIBPBJ5BRQY6B6QJCPVYDUGU35BANCNFSM5BYK6IRA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mjwwit commented 2 years ago

You're not entirely wrong. In the situation you're describing the node will give an error, but the action will still be applied properly to the configured lights.

If you want to fix the error you need to make sure that all messages you send to the node match the requirements. In this specific case you can solve the issue by removing topic from the messages (since you've already configured which lights need to be controlled).

mjwwit commented 2 years ago

I've just released a new version (0.6.0) which includes checkboxes for every node so you can disable these message validation warning logs.

ahartman commented 2 years ago

Thank you. I will install it and see what it does.

Regards, ahartman, belgium

Op 27 dec. 2021, om 11:29 heeft Michael de Wit @.***> het volgende geschreven:

I've just released a new version (0.6.0) which includes checkboxes for every node so you can disable these message validation warning logs.

— Reply to this email directly, view it on GitHub https://github.com/mjwwit/node-red-contrib-ikea-tradfri/issues/16#issuecomment-1001496705, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFIBPD2RMJ7C4EAE2QFGDTUTA5XLANCNFSM5BYK6IRA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.