heggink wrote: Friday 12 October 2018 19:46
Just out of curiosity, what was wrong?
A little bit of "not thinking completely through a change" combined with not rigorous enough testing before commiting to github...
The adapter distinguishes between the different kinds of devices, i.e. if a device is a light, a group or a outlet, because different kind of devices need different calls to the gateway for switching on/off, setting levels and so on. On the plugin-side, everything is just a device. Before the outlets existed, the plugin didn't distinguish between a light or a group, from the plugin's perspective, groups where just a light exactly like a solitary bulb. With outlets, the plugin need to differentiate between lights (bulbs and groups) and outlets to display the proper icon.
The error, even though triggered in updateDeviceState, actually was in registerDevices:
Before the latest commit:
Code: Select all
if aLight["Type"] == "Outlet":
register outlet
if aLight["Type"] == "Light":
register light
and now:
Code: Select all
if aLight["Type"] == "Outlet":
register outlet
if aLight["Type"] == "Light" or aLight["Type"] == "Group":
register light
Before outlets, registerDevices didn't check the aLigh["Type"] at all, because "everything is a light anyway, so why bother checking?". So when needing to separate between outlets and lights, I simply forgot that Type might be "Group". So groups just wasn't added to the table of lights, wasn't added as a device in domoticz, and when updateDevice tried to retrieve the domoticz unit id from the lights-table, the device didn't exist, hence "Error: (Tradfri) 'onMessage' failed 'KeyError'" in line 131 when the device being updated was a group...
Stupid mistake really...
Regards,
M