Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support de la télécommande ikea Tradfri #64

Closed
ChoOo7 opened this issue Oct 12, 2018 · 65 comments
Closed

Support de la télécommande ikea Tradfri #64

ChoOo7 opened this issue Oct 12, 2018 · 65 comments

Comments

@ChoOo7
Copy link

ChoOo7 commented Oct 12, 2018

Bonjour

J'ai bien lu ton article
https://faire-ca-soi-meme.fr/test/2017/06/06/ikea-tradfri-zigbee-3-0-compatibilite-zigate/

Ce que je cherche à faire, ce n'est pas d'associer ma télécommande à une lampe, mais à associer la télécommande à ma zigate, pour ensuite binder les événements sur le broker pour lancer diverses actions.

Je n'arrive pas à associer la télécommande à la zigate / à recevoir des evenements

Lorsque je tiens le bouton appuyé 10 seconde,s rien coté zigate

Et si je fias un factory reset, j'arrive à avoir des choses
string(26) "zigate/device_changed/38b8"
string(128) "{"endpoints": [], "addr": "38b8", "info": {"addr": "38b8", "ieee": "d0cf5efffe05aa5d", "mac_capability": "10000000", "rssi": 3}}"
string(4) "XXXX"
string(26) "zigate/device_changed/38b8"
string(128) "{"endpoints": [], "addr": "38b8", "info": {"addr": "38b8", "ieee": "d0cf5efffe05aa5d", "mac_capability": "10000000", "rssi": 3}}"

Mais rien ensuite concernant les clics sur les boutons

Est-ce quelque chose de possible ?

Merci

@ChoOo7
Copy link
Author

ChoOo7 commented Oct 14, 2018

A ce que j'ai compris, la télécommande Ikea ne diffuse pas son status alors que par exemple le bouton aqara si.

Dans tes articles, j'ai vu que en mode "sniffing", tu peut voir passer les trames entre la télécommande et l'ampoule. Donc au niveau du hardware, on pourrait bien détécter le "clic".

Pourquoi ne pas laisser cette possibilité au niveau du firmware "normal" je voir toutes les trames ?

@ChoOo7
Copy link
Author

ChoOo7 commented Oct 15, 2018

J'ai un autre souci plus ou moins lié, je ne sais pas trop
Voir doudz/zigate#30 (comment)
L'association de mon ampoule et ma télécommande à la zigate fait que la télécommande n'arrive plus à pilote la scène de l'ampoule (mais les autres boutons continuent de marcher)

@KiwiHC16
Copy link

KiwiHC16 commented Nov 7, 2018

La telecommande Ikea envoie ses messages sur une adresse groupe. La Zigate recoit bien ce message mais ne le transmet pas. Actuellement pas de solution "simple" possible.

@doudz
Copy link
Contributor

doudz commented Nov 12, 2018

Si effectivement la zigate voit les messages "passés", peut-être faudrait-il implémenter un nouveau type de réponse afin qu'une application tierce puisse exploiter ces messages, même si les messages sont destinés à un autre équipement.
@fairecasoimeme qu'en penses-tu ?

Par exemple un message type 0x9000 "routed message" avec en paramètre

  • source addr
  • source endpoint
  • (source cluster)
  • dest addr
  • dest endpoint
  • dest cluster
  • payload

Un peu comme si on pouvait faire du "sniffing" à tout moment

@KiwiHC16
Copy link

Ne semble pas simple dans la mesure ou cette partie est dans les librairies NXP, donc pas accessible facilement. Une autre piste serait d'ajouter la zigate au groupe (comme une ampoule), je n'ai pas encore eu le temps de regarder plus avant cette solution.

@doudz
Copy link
Contributor

doudz commented Nov 12, 2018

J'avais pensé à ça aussi mais je n'ai pas de télécommande pour essayer

@fairecasoimeme
Copy link
Owner

Salut à tous,

Je confirme que la partie qui ignore le paquet envoyé par la télécommande se situe dans une librairie compilé (lib qui gère le protocole bas niveau).
J'ai aussi tenté d'associer la ZiGate à un groupe mais je pense que ce n'est pas possible non plus car c'est contraire à son rôle.... Il faudrait que la ZiGate soit aussi en mode "device".
Bref, je n'ai pas trouvé de solution qui ne remette pas en cause les principes élémentaires de la ZiGate.

Les télécommandes qui respectent la norme fonctionnent toutes de la même manière. Seul Xiaomi, à ma connaissance, utilise les télécommandes (ou plutôt interrupteur) comme actionneur.

Si vous avez d'autres idées je suis preneur ...

@ISO-B
Copy link
Collaborator

ISO-B commented Dec 30, 2018

I managed to get some progress to this problem. You can add ZiGate to group or at least I managed to do this twice. Currently using latest source code from github built with debug on and doudz/zigate python library. Hardware wise Trådfri 980lm e27 bulb and 5 button remote both using latest firmware,

  1. Reset ZiGate
  2. Put ZiGate to permit join and reset ikea bulb to get it joining
  3. Put ZiGate to permit join and reset Ikea remote remote
  4. Pair Ikea bulb and remote using touchlink from remote
  5. Request groups from bulb. There should be only one group
  6. Add ZiGate to this group.

After that it is possible to see debug message every time remote send command. Only color temperature command is manufacturer specific. I added function to ZiGate to enable manufacturer specific commands for remote. It shows that color temperature command is for scenes cluster. I haven't yet have time to investigate is it possible to figure which buttons is pressed. After that it might be possible to catch remote press and give user information.

Also there is no way to change scenes or groups on remote because it wont have input cluster for those clusters. If we could get remote paired to ZiGate using touchlink we could probably capture remote button presses without remote sending commands to devices also,

@fairecasoimeme
Copy link
Owner

Sorry, but how could you add ZiGate to the group ?
ZiGate have a 0x0000 short address. I have tried many times but I have never succeeded.
You did this with ZWGUI ?

@ISO-B
Copy link
Collaborator

ISO-B commented Dec 30, 2018

No, I didn't use ZWGUI. I used python library(https://github.com/doudz/zigate). I don't use ZWGUI at all. It is good source(especially source code which is easy to read) for looking commands and what parameters are needed, but other than that it feels buggy.

@fairecasoimeme
Copy link
Owner

Ok, I use ZWGUI only to tests some commands too. it's usefull... but could you share your command to group the ZiGate or the parameters you used because as I said, I have never succeeded to add a ZiGate to a group.

@ISO-B
Copy link
Collaborator

ISO-B commented Dec 30, 2018

This is how I do it with python. Included couple debug messages so you can see what commands are sent

# Start library
import logging
logging.basicConfig()
logging.root.setLevel(logging.DEBUG)
import zigate
z = zigate.connect(port=None)

# Permit joining for 60 seconds
>> z.permit_join(60) 

# From debug messages find bulb short address. Mine was this time 35e6
>> z.get_group_membership('35e6', 0x01)
DEBUG:zigate:Msg to send b'00620006b50235e6010100'
DEBUG:zigate:Encoded Msg to send b'0102106202100216b5021235e602110211021003'

# Check group
>> z.groups
{'3880': {('35e6', 1)}}

# Add ZiGate to group
>> z.add_group('0000', 0x01, '3880')
DEBUG:zigate:Msg to send b'00600007dd02000001013880'
DEBUG:zigate:Encoded Msg to send b'0102106002100217dd02120210021002110211388003'

Requesting groups from ZiGate (address 0000) will crash ZiGate.

@pipiche38
Copy link

Just a naive comment, it is showing progress, but adding the Zigate controller to the group is so far not bringing any features rather than just seen debug messages . Correct ?

As indeed , the remote can manage group and the Zigate can manage the same group too

@ISO-B
Copy link
Collaborator

ISO-B commented Dec 30, 2018

Yes, at the moment ZiGate is only able to see commands sent to group. There is possibility to add functionality to convert those commands to button presses which could be directed to user.

ZiGate can manage group without being member of group.

Only good way that I can see would be ability to pair and touchlink remote just to ZiGate so user could rewrite all button presses on ZiGate end.

@fairecasoimeme
Copy link
Owner

Ok, I just tested and ZiGate intercept messages from remote controller. I don't know if It's a good things (concerning the norm) but It's works !
I confirm the issue when ZiGate ask the group with get group command to 0x0000 address.

This solution is a kind of hack because the coordinator is not a device and mix roles is hassle. I will think about it and I'll see how to give this enhancement without make damages.

Concerning touchlink, It's the same, normally it's for device or router...

I'll see how It's the best compromise and I'll inform to you.

Great thanks @ISO-B

@fairecasoimeme
Copy link
Owner

Yop,

I updated some files in SDK and source code in branch 3.0f.
Now you can intercept ON/OFF and LEVELCONTROL pushed buttons . I didn't implement Scene control yet because It's more sensible.
I fix the issue when zigate request groups. it don't crash now but it's buggy.
Tell me if it's good for you.

@ISO-B
Copy link
Collaborator

ISO-B commented Dec 30, 2018

I watched couple of Ikea gateway and Phillips hub videos and it seems that both are able to handle touchlink pairing. Also read somewhere that coordinator should be able to handle touchlink. So I think that we should try that too.

@fairecasoimeme
Copy link
Owner

I don't know, it's weird because for me it is necessary that the initiator of the touchlink is within 50 cm of the object so even if the ZiGate is able to do a touchlink, it doesn't seem to me very useful.
I will look for the touchlink solution on my side too but in the meantime, I validate the operation with groups for the 3.0f version

@ISO-B
Copy link
Collaborator

ISO-B commented Jan 2, 2019

If I understand correctly ZiGate should work as client(initiator) for remotes. When remotes touchlink lights those should join to same network with ZiGate and remote. Not sure though is there any benefit using touchlink over regular pairing. Have anyone any experience of using Ikea or hue hubs with touchlink?

@ISO-B
Copy link
Collaborator

ISO-B commented Jan 3, 2019

Made little bit more research about this. To achieve programmable buttons from ikea remote will prevent remote working without ZiGate and library. This process is mostly done with library not with ZiGate firmware.

Pairing

First thing is to get ZiGate and remote paired. I am not actually sure is touchlink between remote and ZiGate needed. If remote tells group address to ZiGate while touchlinking, it would be awesome to have touchlink. If remote wont tell group straight to ZiGate it's possible to get it from bulbs.

After that it is time to pair bulb to ZiGate and remote. This could be possible to do just using remote touchlink. It should add bulb to ZiGate's network. If it is not possible then pair bulb to ZiGate first and after that touchlink bulb with remote.

Library

When everything is set up it's time to use ZiGate library of your choice.

  1. Get group from bulb. (Not needed if remote can tell it while touchlinking ZiGate)
  2. Add same group address for ZiGate. (Needed for getting button presses from remote)
  3. Remove group from bulb. (This will prevent remote working without library)
  4. Add new group to bulb.
  5. Repeat steps 3 and 4 for all bulbs that you want control with remote.
    After those steps use library to map button presses to desired commands.

Firmware

Only thing that is needed firmware wise is way to pass commands(or decoded button presses) from remote to user library. Rest functionality is handled with library.

Conclusion

This is only way that I could figure how to get it work. It feels bit hacky, but if you don't want to use it don't add ZiGate to same group with remote and you don't get extra messages for your library. Without removing group from bulbs your remote works as before.

This can already be done since fairecasoimeme added functionality to intercept pushed buttons from remote using group on ZiGate.

Things to figure

Things that still need more research are:

  1. Does bulb or remote send any information for networks coordinator(ZiGate) when they touchlink?
  2. What info ZiGate gets from remote when touchlink is used between them?
  3. ZiGate should be client(initiator) when touchlinking with remote?
  4. How can remote add bulbs to ZiGate's network?
    • Is touchlink between remote and ZiGate needed for this or is it enough just pair them?
    • Does bulb need to be first paired with ZiGate before remote can touchlink with it?

Does this all sound logical or stupid?

@max5962
Copy link

max5962 commented Jan 6, 2019

Bonjour,
Je ne suis pas sûr de comprendre le but de ce ticket et donc de savoir si je suis hors sujet ^^.
Je souhaite

Outlet Ikea <-> zigate (pour avoir le status et l'allumer) (appareillage classique)

Ikea remote <-> outlet (pour contrôler la prise)
(Appareillage Ikea)

1/ Si je fais ça, j'arrive a voir le statut de la prise et la contrôler via zigate ET le bouton ?

2/ si oui, dans quel cas il est utile d'avoir les "ordres" du bouton vu qu'on a le résultat (prise allumé ou éteinte" ?

Merci

@ISO-B
Copy link
Collaborator

ISO-B commented Jan 7, 2019

I am not completely sure that I understand what you are asking since I don't speak french.

  1. No, unless you also add ZiGate to remotes group with outlet.
  2. In that case you should always see button pressed first and outlet state after that.

If it is now possible to pair ZiGate with both remote and outlet and you can already use remote to control outlet then you should get outlet new status from outlet when remote changes it. Only reason that I can imagine where you could need to get remote button presses is if you would like to use ikea outlet and other manufacturer outlet(unless it can be paired with ikea remote) and get them to switch state at the same time. If it's not that time sensitive you could just change other outlet to same state after receiving ikea outlet state.

Hopefully I answered questions that you asked 😄

@ISO-B
Copy link
Collaborator

ISO-B commented Jan 8, 2019

@fairecasoimeme tested 3.0f branch with bulb and remote and messages work fine. Only problem that I noticed is that if ZiGate thinks that light is turned off then lower brightness button won't do nothing. It's probably something to do with enabling ONOFF server on ZiGate that it wont show commands when ONOFF is on OFF state.

It might be best if we ignore requested action and just send command to user.

@ISO-B
Copy link
Collaborator

ISO-B commented Jan 9, 2019

Found solution for this. Going to make pull request later today.

@fairecasoimeme
Copy link
Owner

Great ! I wait your update to include in the 3.0f version
Thx

@ISO-B
Copy link
Collaborator

ISO-B commented Jan 31, 2019

Tested it and you are correct.

1. Sending add group(0x0060) to ZiGate will only generate 8000 response. It probably should also generate 8060 response. This is should be easy to fix.

2. 8062 returning always 5 groups even if no groups have been added might be something to do way NXP has decided to handle group register. It seems that they fill group capacity with incorrect group id (0xffff) and max length group name. This is probably to make sure that there is always room for adding groups. If wished this could be removed or modified not to send ffff groups. @fairecasoimeme do you have thoughts about this?

3. 8062 always returns 5 groups with ffff, even if there should be added groups.  Tested with using debug from uart1 which shows that there is group added and also remote commands are received using that group id. It should show added groups insted of ffff

1 and 3 are things that needs to be fixed.

Found fix to all of those. Haven't yet had time to test if it broke how ZiGate handles groups. Now responses come as they should and also no ffff groups are showing up. Will make PR after more testing.

@fairecasoimeme
Copy link
Owner

fairecasoimeme commented Jan 31, 2019

@max5962

I found how to pair ikea remote control to oulet

Ikea remote control talk only with 0x0000 group

So,

1- pair remote and outlet with zigate
2- add 0000 group to remote control
3- add 0000 group to outlet

And that's all

I'll add the device (with explanations) to compatibility devices on zigate.fr

https://zigate.fr/produit-telecommande-ikea-tradfri-compatible-zigate/

@pipiche38
Copy link

Is there a place where we could get a consolidated documentation for the IKEA Remote Pairing and the Group Management.

From what I see with the 3.0f, they are now 2 'reserved' groups 0x0000 and 0xffff. Correct ?

I see from the previous post how to pair the remote with an outlet, but how do you do with a Bulb.
Currently with 3.0f, the remote after reset and pairing it with a Bulb doesn't have anymore action to the bulb. And I do not see anything coming at the Zigate side.

Am I missing something ?

@ISO-B
Copy link
Collaborator

ISO-B commented Feb 2, 2019

Ikea remote control talk only with 0x0000 group

I assume that you tested using other groups as well?

From what I see with the 3.0f, they are now 2 'reserved' groups 0x0000 and 0xffff. Correct ?

You are partially correct. Both 0x0000 and 0xffff are invalid groups by Zigbee standard. You probably should be add those to any device that follows strictly Zigbee standard for group ids. For some reason Ikea has decided to use group 0x0000 with Outlet controller remote. So in this case I would say that it is 'reserved'. 0xffff group is what NXP has decided to use to reserve memory for groups.

I see from the previous post how to pair the remote with an outlet, but how do you do with a Bulb.
Currently with 3.0f, the remote after reset and pairing it with a Bulb doesn't have anymore action to the bulb. And I do not see anything coming at the Zigate side.

Am I missing something ?

I don't have that remote so I can't say for sure but I think this is how it will work. First you pair remote with ZiGate and after that add both remote and ZiGate to group 0x0000. Now you should be able to see which remote button is pressed. Pair bulb to ZiGate. Write program that handles incoming remote presses and sends commands to bulb.

@KiwiHC16 I made PR #137 which should fix those group command

@pipiche38
Copy link

@ISO-B Thanks for that.

I'll try again and will try directly with ZGUI. But right now, no way to get the Remote with membership group 0x0000. Do I have to do something on the remote ? As this is a battery device and I'm not sure that is on Receive when Idle .

Question: When adding Zigate to group 0x0000. I believe we use 0x0000 has the Network Adddress of the Zigate and 01 has the Endpoint with Address Mode 0x02, or should I use the IEEE addresse, or it doesn't matter ?

BTW, the Xiaomi Plug has 0x0000 group membership by default. This might explain why Ikea does the same .

@pipiche38
Copy link

Making progress

I'm able to add 0x0000 to group 0x0000. However :
I do not get 8062 to confirm the add .
When query 0000 for group membership, only ffff is reported .

I beleive this is related to the bug early reported. I'm going to handle that in the plugin code

@pipiche38
Copy link

Stupid question. Cannot we make Zigate part of group 0x0000 by default ?

@ISO-B
Copy link
Collaborator

ISO-B commented Feb 3, 2019

I took better look for https://zigate.fr/produit-telecommande-ikea-tradfri-compatible-zigate/ and noticed that it doesn't have input cluster for Groups so we are not able to change its group unless it has hidden input input cluster for groups.. It however have ZLL: Commissioning cluster which can change devices group depending how it is implemented.

I'll try again and will try directly with ZGUI. But right now, no way to get the Remote with membership group 0x0000. Do I have to do something on the remote ? As this is a battery device and I'm not sure that is on Receive when Idle .

It won't receive when idle. 5 button remote receives commands if you press button before and after sending command. It really doesn't matter since there is not useful clusters to send commands. I don't know how @fairecasoimeme managed to add remote to group 0x0000 or is it already there.

Question: When adding Zigate to group 0x0000. I believe we use 0x0000 has the Network Adddress of the Zigate and 01 has the Endpoint with Address Mode 0x02, or should I use the IEEE addresse, or it doesn't matter ?

It should not matter, but I personally use address mode 0x02, because short addresses are easier to remember and faster to write.

Making progress

I'm able to add 0x0000 to group 0x0000. However :
I do not get 8062 to confirm the add .
When query 0000 for group membership, only ffff is reported .

I beleive this is related to the bug early reported. I'm going to handle that in the plugin code

PR #137 should fix this.

Stupid question. Cannot we make Zigate part of group 0x0000 by default ?

Yes we could, but I would not do it. Not all users will need ZiGate to be in group 0x0000 and might need 5 groups for something else. They would have to remote it from group 0x0000. For me it is the best solution to leave group table empty by default and let user add groups they need. You can make your code to add ZiGate to group 0x0000 every time you start it. If it is already in group then you will just get response with group already exist status code.

@pipiche38
Copy link

@ISO-B thanks. Maybe the version I got from Akila doesn't include this PR. That could explain

@KiwiHC16
Copy link

KiwiHC16 commented Feb 4, 2019

Hi All,
I have included this into the plugin. Command 8085 and 8095 work very well.
I'm stuck with command 80A7 as I don't find the format of the content. So can't decode it.
Where could I find these information ?
If the format is the one in python's lib (https://github.com/doudz/zigate/blob/master/zigate/responses.py row 750)
then I have an issue because messages I received are not aligned.
Thanks for the info.

@pipiche38
Copy link

pipiche38 commented Feb 4, 2019

Decode80A7:

SQN int8
EP int8
ClusterID Int16
Cmd int8
Direction int8
?? int16 + int8 ( most likely related to scene number)
Source Address: int16

@ISO-B
Copy link
Collaborator

ISO-B commented Feb 5, 2019

I couldn't figure what those extra values are so I left them undecoded.

uint8 u8Direction;
uint8 u8Attr1;
uint8 u8Attr2;
uint8 u8Attr3;

@pipiche38
Copy link

@ISO-B thanks for such work, this is really moving Zigate ahead

@KiwiHC16
Copy link

KiwiHC16 commented Feb 5, 2019

Very good, all working this morning !!!
The only thing I can't get the the hold state for Left and Right button (link to my remote firmware ?).
Thanks a lot @ISO-B

@pipiche38
Copy link

It does work, but still (with the early announcement version from @fairecasoimeme ), I do not get:

0x8060 when adding 0x0000 to a group

When requesting for Group Membership to 0x0000 , I'm getting 5 times 0xffff and not the network address which Zigate belongs too.

@ISO-B
Copy link
Collaborator

ISO-B commented Feb 5, 2019

@KiwiHC16 Can you test with doudz python library? It should show left and right holds. If it doesn't then it is probably firmware related.

@pipiche38 latest release on Github v3.0f_PR doesn't have that fix. You can build binary from my fork if you are in hurry. I think that fairecasoimeme will test my PR before accepting it.

@pipiche38
Copy link

@ISO-B I do confirm that hold left/right works with the version I've got from Akila.

The V3.0f I'm refering is one I got from Akila end of last week, and would tend to agree that your PR is not in, but must be in before a full release.

@KiwiHC16
Copy link

KiwiHC16 commented Feb 6, 2019

@fairecasoimeme told me that he will look at the PR probably before releasing 3.0f.
I can't see any message on air interface so I guess it's due to the ikea remote firmware. I will connect it to Ikea GW and see if an OTA will be done. If so I'll check again the hold button situation.

@KiwiHC16
Copy link

KiwiHC16 commented Feb 6, 2019

I put the remote to the Ikea GW and no upgrade was done.
I'm back on ZiGate and I have the hold as expected.
I did probably shut my eyes yesterday when I was holding the buttons...
So all perfect.

@pipiche38
Copy link

Currently doing some implementation test, and I have some difficulties to decode the Left/Right Release message on message 0x80A7

As command is concerned I receive 0x09 - Which is inline with your work @ISO-B
But as Direction and Unknown, this seems to be more challenging and not straightforward.

Like the Direction and Unknown value could be more related to the Time of the hold rather than if it was left or right.As well this message seems coming several time

@ISO-B
Copy link
Collaborator

ISO-B commented Feb 15, 2019

I couldn't figure release message payload. I also tough time but values seemed to be all over place, like long press one time had big value and sometimes short. Release is always related to button that is last pressed, since you can only press on button. Maybe I need to switch release to use direction 2 so it would be unknown.

@pipiche38
Copy link

Ok, so then we are on the same page !

@lsteelandt
Copy link

lsteelandt commented Mar 23, 2019

Hi @fairecasoimeme, in your comment below in bold, I don't know how to pair the ikea remote with Zigate.

.......

1- pair remote and outlet with zigate
2- add 0000 group to remote control
3- add 0000 group to outlet
......

Using Test_GUI (ZGWUI), I put the Zigate in PermitJoin (Blue led blinking).
I hold the IKEA remote button (The square On/off one), see at one moment the red led slowly flashing but nothing seems to be receive by the Zigate (no mouvement on text box "Received Message).

Can you give some detail of how to pair the Ikea remote with the Zigate ?

Thanks,
Luc

@ISO-B
Copy link
Collaborator

ISO-B commented Mar 24, 2019

Put ZiGate to permit join mode and press 4 times Ikea remote touch link button within 5 seconds or so.

@pipiche38
Copy link

Should be closed, as this is fixed since 3.0f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants