moroen / IKEA-Tradfri-plugin

A Python plugin for Domoticz to controll IKEA Gateway
68 stars 23 forks source link

Not all devices are imported #112

Closed nellemar closed 3 years ago

nellemar commented 3 years ago

I have got a strange problem, plugin is working, but not all devices are detected (24 of 27), mayby its because of the error when starting the plugin:

2020-08-26 07:55:50.922 Error: (IkeaBridge) 'onStart' failed 'KeyError'. 2020-08-26 07:55:50.922 Error: (IkeaBridge) ----> Line 683 in '/home/marco/domoticz/plugins/IKEA-Tradfri/plugin.py', function onStart 2020-08-26 07:55:50.922 Error: (IkeaBridge) ----> Line 550 in '/home/marco/domoticz/plugins/IKEA-Tradfri/plugin.py', function onStart 2020-08-26 07:55:50.922 Error: (IkeaBridge) ----> Line 485 in '/home/marco/domoticz/plugins/IKEA-Tradfri/plugin.py', function registerDevices 2020-08-26 07:55:50.922 Error: (IkeaBridge) ----> Line 83 in '/home/marco/domoticz/plugins/IKEA-Tradfri/tradfricoap/device.py', function Description 2020-08-26 07:55:50.922 Error: (IkeaBridge) ----> Line 159 in '/home/marco/domoticz/plugins/IKEA-Tradfri/tradfricoap/device.py', function Level

Could it be because i connected a non ikea device to the tradfri bridge? cause all the devices paired after the one who failed, are not detected/imported

moroen commented 3 years ago

Most probably yes... I would guess the info returned from the gateway for the non-ikea device does't match the expected format, and thus the plugin fails when it tries to import it to domoticz.

Does the non-ikea device appear when listing devices from the command line?

$ python3 plugin.py list

And if you know the id, what is the return value from the raw command?

$ python3 plugin.py raw <ID>

If you can provide the output of these two commands, it might be possible to get the non-ikea device imported into domoticz, or at least make the plugin just ignore it, and continue importing the other devices.

moroen commented 3 years ago

Or you could try the small attemt at a fix just pushed to the development branch...

$ git checkout development
$ git pull

I've not been able to test this, since I do not have any non-Ikea devices, but this fix should enable the plugin to skip any non-unrecognized devices, and continue adding those that follows!

nellemar commented 3 years ago

i've tried both options

Using the development branch makes the error go away, but the devices paired after the non ikea devices, will not be added.

the plugin.py list command generates an error:

Traceback (most recent call last): File "plugin.py", line 133, in lights.append(dev.Description) File "/home/marco/domoticz/plugins/IKEA-Tradfri/tradfricoap/device.py", line 83, in Description self.DeviceID, self.Name, self.State, self.Level, self.Hex File "/home/marco/domoticz/plugins/IKEA-Tradfri/tradfricoap/device.py", line 159, in Level return self.lightControl[constants.attrLightDimmer] KeyError: '5851'

Is it possible the get the id in a different way? found it by trying:

python3 ./plugin.py raw 65567 {'9001': 'afdak', '9003': 65567, '9002': 1591789970, '9020': 1598564235, '9054': 0, '9019': 1, '3': {'0': 'ROBB smarrt', '1': 'ROB_200-003-0', '2': '', '3': '2.5.3_r47', '6': 1}, '5750': 2, '3311': [{'5850': 1, '9003': 0}]}

Its this device: https://www.robbshop.nl/inbouwschakelaar-zigbee-robb-smarrt?sqr=robb&

moroen commented 3 years ago

The output from raw was very helpful.

Please pull the latest commit to development, and try again!

nellemar commented 3 years ago

This works.... almost.

all the devices are imported, i can turn it on, but the status wont change so i cant turn it off i did another raw output dump The one from yesterday was with the light turned on: so to be complete:

python3 ./plugin.py raw 65567 {'9001': 'afdak', '9003': 65567, '9002': 1591789970, '9020': 1598599780, '9054': 0, '9019': 1, '3': {'0': 'ROBB smarrt', '1': 'ROB_200-003-0', '2': '', '3': '2.5.3_r47', '6': 1}, '5750': 2, '3311': [{'5850': 0, '9003': 0}]}

python3 ./plugin.py raw 65567 {'9001': 'afdak', '9003': 65567, '9002': 1591789970, '9020': 1598599780, '9054': 0, '9019': 1, '3': {'0': 'ROBB smarrt', '1': 'ROB_200-003-0', '2': '', '3': '2.5.3_r47', '6': 1}, '5750': 2, '3311': [{'5850': 1, '9003': 0}]}

first one, light off, second one light on.

thanks for the good work,

your ikea-tradfri commandline tools works, and sees all the devices

65567: afdak (ROB_200-003-0) - False:None - None

nellemar commented 3 years ago

You can close this one. with the lastest plugin, it all works (on windows). including on and of for the non ikea switch thanks

nellemar commented 3 years ago

last comment says it all