[REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Python and python framework
moroen
Posts: 188
Joined: Sunday 15 January 2017 12:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by moroen » Friday 12 October 2018 19:11

moroen wrote:
Friday 12 October 2018 14:52

I think I've found the bug, but I'm currently at work, so I'm not able to fix it right now... I'll fix this as soon as possible, and post here when a new version is commited to github!

Regards,
M
The latest commit should fix this, and actually add groups as devices if so selected... :shock:

Regards,
M

User avatar
heggink
Posts: 581
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi
Domoticz version: V4.9999
Location: NL
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by heggink » Friday 12 October 2018 19:46

Just out of curiosity, what was wrong?
Pi3, latest beta
RFXCOM, z-wave (AEOTEC, switches, temhum, pir, contacts),
Plugwise2py, P1 'smart'meter & solar panel
Alexa, Wifi Cams motion detection
ESP: relays, PIR & Temp/TempHum
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest

moroen
Posts: 188
Joined: Sunday 15 January 2017 12:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by moroen » Friday 12 October 2018 20:26

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

mdenouden
Posts: 5
Joined: Sunday 23 August 2015 10:52
Target OS: Raspberry Pi
Domoticz version: beta
Location: Netherlands
Contact:

Re: [REQUEST] Ikea Trådfri Gateway (smart lights hub controller) plugin?

Post by mdenouden » Tuesday 16 October 2018 10:58

moroen wrote:
Friday 12 October 2018 19:11
moroen wrote:
Friday 12 October 2018 14:52

I think I've found the bug, but I'm currently at work, so I'm not able to fix it right now... I'll fix this as soon as possible, and post here when a new version is commited to github!

Regards,
M
The latest commit should fix this, and actually add groups as devices if so selected... :shock:

Regards,
M
Works great now! Thank you!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests