treban / pimatic-tradfri

This plugin provides a tradfri interface for pimatic.
https://pimatic.org/plugins/pimatic-tradfri/
GNU General Public License v2.0
11 stars 3 forks source link

Tradfri dimmable bulb recognized as a remote control #26

Closed cklam2 closed 6 years ago

cklam2 commented 6 years ago

Pimatic version :

0.9.42

Plugin version :

0.1.17

Problem / Feature :

The Tradfri dimmable bulb is recognized as remote control when performing device discovery.

Message Log:

info [pimatic]: Device discovered: pimatic-tradfri : LIGHT: Living Room (RGB) - TRADFRI bulb E27 CWS opal 600lm
info [pimatic]: Device discovered: pimatic-tradfri : RemoteControl: Bedroom Light (Dim) - TRADFRI bulb E27 opal 1000lm

First bulb, a RGB bulb is recognized correctly as light but the second one, a dimmable-only bulb isn't.

Note

In the code the device ID is listed correctly in the switch so it should be due to this statement if (device[5750] == 0) ?

cklam2 commented 6 years ago

Mm, seems that I've found the reason for this behavior in another project, see this thread: https://github.com/ggravlingen/pytradfri/issues/135

What they are saying is that the bulb's firmware is giving the wrong information, even after a firmware update. To solve this, make sure that the bulb's firmware is updated through the Gateway, then reset the gateway and re-register your bulbs.

This could be true cause I saw that my bulb's firmware got updated to 1.2.214 after I registered it yesterday.

So I'll try that trick and come back to this later.

treban commented 6 years ago

thanks for the advice. i will check if this is the same with my gateway. is only the recognition faulty? or the control also.

cklam2 commented 6 years ago

I do not think the bug is in your software. It should be the tradfri bulb firmware.

Older versions are sending 'wrong' Coap messages. In this message the 5750 (TYPE) is 0 (remote) instead of 2 (bulb) and this should be solved after a firmware update + reset of the hub.

However did not yet get the chance to reset and see if that solves the issue. Hope I can do that soon.

Btw, is there any way for me to check those Coap messages?

treban commented 6 years ago

Yeah, its a gateway issue.

You can add in tradfri.coffee after line 119 a debug output. The device variable contains the coap response in json.

            devices.forEach((device) =>
              env.logger.debug(device)
              @lclass = switch
cklam2 commented 6 years ago

Got debug logging working. Here the coap msg from the RGB bulb which is identified correctly as 'LIGHT':

{ '3': 
   { '0': 'IKEA of Sweden',
     '1': 'TRADFRI bulb E27 CWS opal 600lm',
     '2': '',
     '3': '1.3.002',
     '6': 1 },
  '3311': 
   [ { '5706': 'efd275',
       '5707': 5309,
       '5708': 52400,
       '5709': 32886,
       '5710': 27217,
       '5850': 0,
       '5851': 190,
       '9003': 0 } ],
  '5750': 2,
  '9001': 'Living Room (RGB)',
  '9002': 1517697162,
  '9003': 65537,
  '9019': 1,
  '9020': 1519598784,
  '9054': 0 }

And here the coap message from the dim-only bulb which is identified as remote.

{ '3': 
   { '0': 'IKEA of Sweden',
     '1': 'TRADFRI bulb E27 opal 1000lm',
     '2': '',
     '3': '1.2.214',
     '6': 1 },
  '5750': 0,
  '9001': 'Bedroom Light (Dim)',
  '9002': 1519248013,
  '9003': 65542,
  '9019': 1,
  '9020': 1519604646,
  '9054': 0,
  '15009': [ { '5850': 0, '5851': 162, '9003': 0 } ] }

Observations:

Tonight will reset the gateway and re-register all devices and see if the coap message changed, fingers crossed. If that's the case then the only thing you can do to improve is add detection for section 15009(?) and show a warning to user. Or just add a note in the readme.md.

cklam2 commented 6 years ago

Well, unregistering that specific bulb with the IKEA app and registering again with remote control did the trick. Didn't need to reset entire hub/gateway.

The CoAP message after doing that:

{ '3': 
   { '0': 'IKEA of Sweden',
     '1': 'TRADFRI bulb E27 opal 1000lm',
     '2': '',
     '3': '1.2.214',
     '6': 1 },
  '3311': [ { '5850': 1, '5851': 129, '9003': 0 } ],
  '5750': 2,
  '9001': 'Bedroom Light (Dim)',
  '9002': 1519669002,
  '9003': 65543,
  '9019': 1,
  '9020': 1519669011,
  '9054': 0 }

Now showing section '3311' and more important, 5750 has value 2. Therefore finally being recognized correctly by pimatic-tradfri as 'LIGHT'.

@treban, close this issue or add some detection for these kinds of scenario's, just for warning purposes?