IKEA Trådfri Gateway

I’m now up and running with a Tradfri gateway and four bulbs in openHAB. Fantastic stuff.

I don’t get the bulbs to work by creating text items and channel-configuration. I have to create items in PaperUI first. Not sure if this is binding-correlated.
Obiously it’s a big problem the Gateway itself crashes at least once per day, which is a common problem.

Why would you create text items and assign the channel-configuration to that?
Since most people here seem to have few to zero issues, i would suggest that something on your end is not working correctly.

If you share your configuration, maybe people might help you.

This binding is a great start! The Ikea bulbs have a very high light quality for the cost. For me the individual control of the brightness and colorTemperature both work very well, but I have a frustrating issue.

Here is the issue. When I put in the control of both brightness and colorTemperature of the same bulb in the same Rule then the brightness control always fails. If I remove the colorTemperature line from the rule, then the brightness works again.

rule "DAYLIGHT"
when
    Item DAYLIGHT changed to 1
then
	sendCommand(ikeatradfri_whitespectrum_bulb_gwb072bfb31b8f_65540_brightness, 100)	
    sendCommand(ikeatradfri_whitespectrum_bulb_gwb072bfb31b8f_65540_colorTemperature, 100)	
end

Can anyone spot what I’m doing wrong or is there a bug in the binding?

A wild guess: try a Thread::sleep(1000) between the two sendCommands().
If that works, se how low you can go. Value in ms.

Regarding the Tradfri Hub, I also do see stability issues after a week or so.
Response becomes sluggish, up to 10s for on/off to respond, both from OH and the Ikea App.

It is not a one off as I did see the same at a second location and that was just after a few minutes with no OH involved at all.

After a Hub power cycle things are back to normal, but the problem with OH and the binding is that it stops working.

Hub and all bulbs and panels are marked as Online in HABmin, but commands do not work.
Restarting the bundle from Karaf does not help: openhab> bundle:restart "IkeaTradfri Binding"
The only remedy to regain control is $ sudo systemctl restart openhab2.service

Having played some more with Tradfri I have found these two shortcomings: (not OH related)

  1. The phone app can only connect to 1 Hub at a time. If you need to switch Hub, the QR code needs to be scanned and the one you are leaving is forgotten.

  2. Bulbs and panels can only have 1 remote in a group, so no ‘stairway’ function with 2 Ikea remotes is possible. Trying to pair a second remote makes it forget the first one. Using the app+Hub it is possible to move lights between groups, but not remotes. Luckily OH can fix this, using any remote :slight_smile:

I can confirm those observations. I did buy the remote to control every bulb which isnt even possible. You can control one device with another device only if it is in the same group, which is pointless regarding the remote. And it seems the remote sensor does communicate directly to the paired bulb (without the gateway). You can control two bulbs with one motion sensor, if the sensor is paired to both and all are in the same group.
I just can warn buying the remote, if you’re going to work with groups in different rooms.

I take that for a Kind approach to help.

Of course I do want do use text items in my items-file, so I can work without paperUI AND I think you have to go that way when you do want to make use of the hue-emulation-binding.

I linked the items by paperUI. The channel is correct, I tested several times.In my sitemap they are working. I did manage to get one bulb recognized by hue-emulation, but the others just don’tget recognized.
Strange Thing is: First there were several ‘brightness’ items found by Alexa/Echo (which I did not put in the .items-file), but the ones put in the items-file are not being recognized.
Bad Thing is they do not appear again, since I did throw those 'brightness’things in the Alexa/Echo-app away.
I just dont know why there is a different behaviour here with tradfri compared to other items that are also linked by PaperUI AND referenced by one item in the .items-file.

 [ "Lighting" ]

Sitemap:

Slider item=lightLivingRoomDeathStarDimmer label="WohnzimmerLampe StarWars Helligkeit"

lights.items

Dimmer  lightLivingRoomDeathStarDimmer "Licht Todesstern [%.1f]" [ "Lighting" ] <ikea>  (gLights)  { channel="ikeatradfri:whitespectrum_bulb:gwb072bf27be41:65545:brightness " }

@Kai, just installed your latest Ikea .jar and it seems to have broken the :state channel.

On the previous version, I could set and get :state, but not anymore.
Dimming and colour setting works OK.

This is the log when trying to set :state to ON or OFF from paperUI or HABdroid:

2017-06-10 18:55:21.316 [ERROR] [adfri.handler.IkeaTradfriBulbHandler] - Unkown channel ikeatradfri:whitespectrum_bulb:gwb072bf25aee1:65543:state

I found it quite useful to just control state ON/OFF and use the Ikea remote to control dimmer level and colour temperature.

And it seems that the old binding does not play with today’s OH2 snapshot:

2017-06-10 19:17:02.963 [ERROR] [.core.network.stack.ReliabilityLayer] - Exception in MessageObserver: null
java.lang.NullPointerException
        at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1975)[:1.8.0_131]
        at org.openhab.binding.ikeatradfri.handler.IkeaTradfriGatewayHandler$2.onError(IkeaTradfriGatewayHandler.java:186)[10:org.openhab.binding.ikeatradfri:2.1.0.201704272025]
        at org.eclipse.californium.core.CoapClient$MessageObserverImpl.failed(CoapClient.java:999)[10:org.openhab.binding.ikeatradfri:2.1.0.201704272025]
        at org.eclipse.californium.core.CoapClient$MessageObserverImpl.onTimeout(CoapClient.java:960)[10:org.openhab.binding.ikeatradfri:2.1.0.201704272025]
        at org.eclipse.californium.core.coap.Message.setTimedOut(Message.java:512)[10:org.openhab.binding.ikeatradfri:2.1.0.201704272025]
        at org.eclipse.californium.core.coap.Request.setTimedOut(Request.java:485)[10:org.openhab.binding.ikeatradfri:2.1.0.201704272025]
        at org.eclipse.californium.core.network.stack.ReliabilityLayer$RetransmissionTask.run(ReliabilityLayer.java:368)[10:org.openhab.binding.ikeatradfri:2.1.0.201704272025]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_131]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_131]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)[:1.8.0_131]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.8.0_131]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_131]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_131]
        at java.lang.Thread.run(Thread.java:748)[:1.8.0_131]

Guess I stay on the snapshot and re-write my rules to not use the :state channel for now.

I’m trying to test this binding for Ikea Trådfri, but it seems like I’m missing something. When I look in the logs it says that there is an unresolved requirement: Import-Package: org.eclipse.californium.core. I think that I have to add a jar file with that name to my addons folder in OpenHAB. The problem is that I dont know where to find that file so I hope someone can help me with this.

Ole, indeed the state channel has been removed, but this is not a regression, but a bug fix, because it was not correct to have it in the first place - the brightness channel accepts ON and OFF as well, so it is a full replacement here.

I have also added a README.md to the binding now.[quote=“juppe1, post:50, topic:26135”]
it says that there is an unresolved requirement: Import-Package: org.eclipse.californium.core
[/quote]

I had refactored the binding to not contain the californium bundles anymore - so indeed it doesn’t work anymore to merely install the tradfri jar, you will also need to install the openhab-transport-coap feature.

As this complicates things for testing, I have done a thorough review and refactoring of the binding yesterday and I would actually claim it is in a state that it can be merged - so unless there is any veto, I will do so in the next days!

5 Likes

Quite, just changed :state to :brightness in the Switch definitions in my .items file.

@kai could you please do one more test before you merge?
Power cycle the Tradfri gateway and see if it reconnects?
For the previous version HABmin and paperUI says gateway and items are Online, but commands are not getting through.

I have noticed that the gateway can get sluggish after a week or two so it would be really nice if we could restart it and it would reconnect properly.
This can be done either using a remote switch or maybe with a command through the coap interface?

And, almost forgot; thank you for stepping up and finishing this binding! :slight_smile:

1 Like

So when the binding is merged it will work out of the box then without any manual copying of files?
How can I then update my installation so the new binding is working?

How do I install openhab-transport-coap?

Is there anyone that can help me with the openhab-transport-coap?
Where can I find it and how do I install it?

I have never installed it (as I can remember). Just started with the original .jar in this thread.
Maybe that did it by magic?

The answer I got from Kai was that its not bundled in teh jar anymore, so if you get the latest version you have to install openhab-transport.coap.
OMR, do you still have that original jar file?

Certainly. From 28. april 2017

https://1drv.ms/u/s!Ak62_W4agNNTiRwBklAFxwNPFamq

But maybe @kai could chime in explaining exactly how to install the openhab-transport.coap?

Thanks, Hope that the binding will be in openhab soon, so we dont have to do this manually.

I know Kai wants to merge it for the upcoming 2.1.0 Release of OH2.