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

Python and python framework

Moderator: leecollings

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

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

Post by moroen »

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: 977
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

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

Post by heggink »

Just out of curiosity, what was wrong?
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

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

Post by moroen »

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 / ODroid
Domoticz version: beta
Location: Netherlands
Contact:

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

Post by mdenouden »

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!
htilly
Posts: 14
Joined: Saturday 09 January 2016 22:05
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Stockholm
Contact:

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

Post by htilly »

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

Regards,
M
Hi!

Did you push this to dev or master?

Having the same issue. Using stable branch and the Docker image.
Added a case on GIT:
https://github.com/moroen/IKEA-Tradfri-plugin/issues/50

But it might be better to have the discussion here?

Everything else seems to be working except that the light does not show up in Domoticz.

BR
Tilly
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

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

Post by moroen »

htilly wrote: Thursday 18 October 2018 12:39
The latest commit should fix this, and actually add groups as devices if so selected... :shock:

Regards,
M
Hi!

Did you push this to dev or master?

Having the same issue. Using stable branch and the Docker image.
Added a case on GIT:
https://github.com/moroen/IKEA-Tradfri-plugin/issues/50

But it might be better to have the discussion here?

Everything else seems to be working except that the light does not show up in Domoticz.

BR
Tilly
The outlets are currently only supported in the development-branch. I'll try to update master as well...

Regards,
M
bilbolodz
Posts: 18
Joined: Wednesday 15 March 2017 9:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by bilbolodz »

htilly wrote: Thursday 18 October 2018 12:39 Everything else seems to be working except that the light does not show up in Domoticz.
I've similar problem. How to make bulbs visible into Domoticz?
htilly
Posts: 14
Joined: Saturday 09 January 2016 22:05
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Stockholm
Contact:

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

Post by htilly »

moroen wrote: Thursday 18 October 2018 15:30
htilly wrote: Thursday 18 October 2018 12:39
The latest commit should fix this, and actually add groups as devices if so selected... :shock:

Regards,
M
Hi!

Did you push this to dev or master?

Having the same issue. Using stable branch and the Docker image.
Added a case on GIT:
https://github.com/moroen/IKEA-Tradfri-plugin/issues/50

But it might be better to have the discussion here?

Everything else seems to be working except that the light does not show up in Domoticz.

BR
Tilly
The outlets are currently only supported in the development-branch. I'll try to update master as well...

Regards,
M
Hmm, well this is a bulb. My setup right now is quite simple. One gateway, one controll and one bulb. Trying to get everything to work before shopping more =)

So my problem is that using master branch with Docker image and Domoticz 4.9700 I can´t get the light bulb to show up as a device in Domoticz :(

Oho, and thanks for an awesome plugin. Really looking forward to get this to work!

/Tilly
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

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

Post by moroen »

htilly wrote: Thursday 18 October 2018 17:48 So my problem is that using master branch with Docker image and Domoticz 4.9700 I can´t get the light bulb to show up as a device in Domoticz :(
Oho, and thanks for an awesome plugin. Really looking forward to get this to work!
/Tilly
These errors usually stem from mismatching the version of domoticz with the branch of the plugin... Are you sure you're using the correct branch of the plugin? I see you're running stable domoticz. The default branch when cloning the repo is development...

If you're on the correct branch, please let me know and please provide the log from domoticz. I'm not using docker, so the problem might be there if the branches are correctly matched... :?

Regards,
M
htilly
Posts: 14
Joined: Saturday 09 January 2016 22:05
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Stockholm
Contact:

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

Post by htilly »

moroen wrote: Thursday 18 October 2018 18:54
htilly wrote: Thursday 18 October 2018 17:48 So my problem is that using master branch with Docker image and Domoticz 4.9700 I can´t get the light bulb to show up as a device in Domoticz :(
Oho, and thanks for an awesome plugin. Really looking forward to get this to work!
/Tilly
These errors usually stem from mismatching the version of domoticz with the branch of the plugin... Are you sure you're using the correct branch of the plugin? I see you're running stable domoticz. The default branch when cloning the repo is development...

If you're on the correct branch, please let me know and please provide the log from domoticz. I'm not using docker, so the problem might be there if the branches are correctly matched... :?

Regards,
M
Aha, default development you say =)
Problem solved by updating Domoticz to beta!

I'm off to IKEA :-D

/Tilly
User avatar
heggink
Posts: 977
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

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

Post by heggink »

Supposedly Ikea are due to release tradfri curtain motors . Would love to have a couple of those...
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
bilbolodz
Posts: 18
Joined: Wednesday 15 March 2017 9:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by bilbolodz »

htilly wrote: Thursday 18 October 2018 19:12Problem solved by updating Domoticz to beta!
If it is NOT your playground but "real home" using BETA od Domoticz it's extremely BAD IDEA.....
User avatar
heggink
Posts: 977
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

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

Post by heggink »

bilbolodz wrote:
htilly wrote: Thursday 18 October 2018 19:12Problem solved by updating Domoticz to beta!
If it is NOT your playground but "real home" using BETA od Domoticz it's extremely BAD IDEA.....
Depends: most betas are very stable but the occasional one is bad. If you are on the beta thread then you need to follow GitHub to understand what changes are being made and follow the forum to see if issues are reported. And always have a backup.
I upgrade regularly and have had my share of issues in the past summer learnt the hard way. That said, sometimes there is no alternative like in this case where the were some major changes between beta and prod.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
bilbolodz
Posts: 18
Joined: Wednesday 15 March 2017 9:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by bilbolodz »

heggink wrote: Thursday 18 October 2018 20:59 That said, sometimes there is no alternative like in this case.
Of course it's "up to the author" but providing plugin (if there are not really important reasons) only for betas it a "bad habit".
bilbolodz
Posts: 18
Joined: Wednesday 15 March 2017 9:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by bilbolodz »

So question to the author: is there a way to use (only with bulbs) these plugin with stable (not beta) version of Domoticz?
User avatar
heggink
Posts: 977
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

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

Post by heggink »

bilbolodz wrote:
heggink wrote: Thursday 18 October 2018 20:59 That said, sometimes there is no alternative like in this case.
Of course it's "up to the author" but providing plugin (if there are not really important reasons) only for betas it a "bad habit".
Disagree. This is all Pro bono work. I have written a few python plugins myself. In open source, you get what you get and if you need more, you are down to the authors willingness and ability to help or you do it yourself. In this case, it would mean that the author would have to have an extra system to test just for you. I would agree with you if people get paid but that's not the case.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
bilbolodz
Posts: 18
Joined: Wednesday 15 March 2017 9:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by bilbolodz »

Could someone please point to solution how to add bulbs into Domoticz (stable Domoticz version and master branch)?
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

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

Post by moroen »

bilbolodz wrote: Thursday 18 October 2018 23:26 Could someone please point to solution how to add bulbs into Domoticz (stable Domoticz version and master branch)?
I'll stay clear of the "bad habit" discussion, but the plugin supports bulbs for stable domoticz:

You need to use the MASTER branch of the plugin with the STABLE version of domoticz. It supports lights and groups just fine.
If you need support for sockets, at the moment, you need to use the DEVELOPMENT branch of the plugin, with the BETA version of domoticz...

Since the plugin is in constant development, the development branch is the default when cloning, but the master is just a:

Code: Select all

$ git checkout master
away...

This is written in the readme, and have been mentioned in this thread quite a couple of times. Please note that when switching between branches, you need to delete the plugin from the hardware page in domoticz and add it again, as the two versions handles ident/psk quite differently.

I just compiled the latest stable version of domoticz and tested the master branch of the plugin, and it works as expected. If you are certain you have matched the branches and it still doesn't work, please provide the log and I'll try to help you. Support for sockets in stable domoticz will arrive when either I have the time to implement it, or someone else makes the needed changes and issue a pull request.

Regards,
M
Last edited by moroen on Friday 19 October 2018 1:49, edited 4 times in total.
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

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

Post by moroen »

heggink wrote: Thursday 18 October 2018 19:42 Supposedly Ikea are due to release tradfri curtain motors Image. Would love to have a couple of those...
I was not aware that IKEA was planning this, but I guess if and when it's released, it would be the perfect excuse to finally installing automated curtains in the house... ;)

Regards,
M
bilbolodz
Posts: 18
Joined: Wednesday 15 March 2017 9:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by bilbolodz »

Finally I've manged to get IKEA gateway running with stable version of Domoticz (moroen many, many thanks). I'll try to summarize some obvious fact but maybe it would be useful to someone:
1) With stable version of Domoticz you HAVE to use master branch of repository (default after git clone is development branch)
2) Both parts (plugin and adapter) has two versions (master and development). It has to much themself (you cannot use stable plugin with development adaptor)
3) In stable version at Domoticz plugin page you have to provide:
-IP address of IKEA gateway
-Identity
-Preshared key (PSK)
Identity and PSK could be: '"Client_identity" and preshared key from sticker but these solution is not advised by IKEA, it's better to generate own identity and PSK using generate-psk.py script
4) In stable version of plugin address of adapter is hardcoded to 127.0.0.1 in plugin. If your are running adapter on different machine than Domoticz you have to change it manually in code and restart Domoticz
5) In development version of Domoticz plugin you have to only provide IP address BUT address of ADAPTER (not gateway as in stable version), Identity and PSK should be saved into config.json file, you can generate these file with configure.py script (you have to put IP of gateway and PSK from sticker as parameters). Without config file adapter won't start!
6) I've modified Dockerfile (and merged into moroen github) to make process of creating config file automatic during start of docker container. Remeber to put IP and PSK into GW_config file before starting container (--env-file=GW_config parametr for docker).
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest