dkerr64/homebridge-yolink

Add support for YoLink Key Fob

dkerr64 opened this issue · 15 comments

Describe the solution you'd like:
Add support for YoLink Key Fob

Sample device json to handle...

{
	"deviceId": "xxx",
	"deviceUDID": "xxx",
	"name": "YoLink Fob",
	"token": "xxx",
	"type": "SmartRemoter",
	"parentDeviceId": null
}

I went through all four button presses.

[8/10/2022, 2:08:09 PM] [YoLink] mqtt received: yl-home/c460b484e49b4c08b33647d9815c9741/d88b4c0100038868/report
{"event":"SmartRemoter.StatusChange","time":1660154889197,"msgid":"1660154889197","data":{"event":{"keyMask":4,"type":"Press"},"battery":4,"version":"0405","devTemperature":26,"loraInfo":{"signal":-77,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c0100038868"}
[8/10/2022, 2:08:09 PM] [YoLink] Received mqtt message 'SmartRemoter.StatusChange' for device: YoLink Fob (d88b4c0100038868) State: 'undefined'
[8/10/2022, 2:08:09 PM] [YoLink] Unsupported mqtt event: 'SmartRemoter.StatusChange'
Please report at https://github.com/dkerr64/homebridge-yolink/issues
{"event":"SmartRemoter.StatusChange","time":1660154889197,"msgid":"1660154889197","data":{"event":{"keyMask":4,"type":"Press"},"battery":4,"version":"0405","devTemperature":26,"loraInfo":{"signal":-77,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c0100038868"}
[8/10/2022, 2:08:11 PM] [YoLink] mqtt received: yl-home/c460b484e49b4c08b33647d9815c9741/d88b4c0100038868/report
{"event":"SmartRemoter.StatusChange","time":1660154891651,"msgid":"1660154891650","data":{"event":{"keyMask":8,"type":"Press"},"battery":4,"version":"0405","devTemperature":26,"loraInfo":{"signal":-78,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c0100038868"}
[8/10/2022, 2:08:11 PM] [YoLink] Received mqtt message 'SmartRemoter.StatusChange' for device: YoLink Fob (d88b4c0100038868) State: 'undefined'
[8/10/2022, 2:08:11 PM] [YoLink] Unsupported mqtt event: 'SmartRemoter.StatusChange'
Please report at https://github.com/dkerr64/homebridge-yolink/issues
{"event":"SmartRemoter.StatusChange","time":1660154891651,"msgid":"1660154891650","data":{"event":{"keyMask":8,"type":"Press"},"battery":4,"version":"0405","devTemperature":26,"loraInfo":{"signal":-78,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c0100038868"}
[8/10/2022, 2:08:13 PM] [YoLink] mqtt received: yl-home/c460b484e49b4c08b33647d9815c9741/d88b4c020002efe4/report
{"event":"MotionSensor.StatusChange","time":1660154893421,"msgid":"1660154893421","data":{"state":"normal","battery":3,"version":"046f","ledAlarm":true,"alertInterval":1,"nomotionDelay":1,"sensitivity":3,"loraInfo":{"signal":-70,"gatewayId":"d88b4c1603011301","gateways":1},"stateChangedAt":1660154893420},"deviceId":"d88b4c020002efe4"}
[8/10/2022, 2:08:13 PM] [YoLink] Received mqtt message 'MotionSensor.StatusChange' for device: Utility Room Motion Sensor (d88b4c020002efe4) State: 'normal'
[8/10/2022, 2:08:14 PM] [YoLink] mqtt received: yl-home/c460b484e49b4c08b33647d9815c9741/d88b4c010003b80d/report
{"event":"Siren.setState","time":1660154894589,"msgid":"1660154894588","data":{"state":"alert","loraInfo":{"signal":-60,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c010003b80d"}
[8/10/2022, 2:08:14 PM] [YoLink] Received mqtt message 'Siren.setState' for device: Siren Alarm (d88b4c010003b80d) State: 'alert'
[8/10/2022, 2:08:14 PM] [YoLink] Unsupported mqtt event: 'Siren.setState'
Please report at https://github.com/dkerr64/homebridge-yolink/issues
{"event":"Siren.setState","time":1660154894589,"msgid":"1660154894588","data":{"state":"alert","loraInfo":{"signal":-60,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c010003b80d"}
[8/10/2022, 2:08:14 PM] [YoLink] mqtt received: yl-home/c460b484e49b4c08b33647d9815c9741/d88b4c0100038868/report
{"event":"SmartRemoter.StatusChange","time":1660154894940,"msgid":"1660154894940","data":{"event":{"keyMask":1,"type":"Press"},"battery":4,"version":"0405","devTemperature":26,"loraInfo":{"signal":-77,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c0100038868"}
[8/10/2022, 2:08:14 PM] [YoLink] Received mqtt message 'SmartRemoter.StatusChange' for device: YoLink Fob (d88b4c0100038868) State: 'undefined'
[8/10/2022, 2:08:14 PM] [YoLink] Unsupported mqtt event: 'SmartRemoter.StatusChange'
Please report at https://github.com/dkerr64/homebridge-yolink/issues
{"event":"SmartRemoter.StatusChange","time":1660154894940,"msgid":"1660154894940","data":{"event":{"keyMask":1,"type":"Press"},"battery":4,"version":"0405","devTemperature":26,"loraInfo":{"signal":-77,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c0100038868"}
[8/10/2022, 2:08:15 PM] [YoLink] mqtt received: yl-home/c460b484e49b4c08b33647d9815c9741/d88b4c010003b80d/report
{"event":"Siren.setState","time":1660154895289,"msgid":"1660154895289","data":{"state":"alert","loraInfo":{"signal":-60,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c010003b80d"}
[8/10/2022, 2:08:15 PM] [YoLink] Received mqtt message 'Siren.setState' for device: Siren Alarm (d88b4c010003b80d) State: 'alert'
[8/10/2022, 2:08:15 PM] [YoLink] Unsupported mqtt event: 'Siren.setState'
Please report at https://github.com/dkerr64/homebridge-yolink/issues
{"event":"Siren.setState","time":1660154895289,"msgid":"1660154895289","data":{"state":"alert","loraInfo":{"signal":-60,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c010003b80d"}
[8/10/2022, 2:08:15 PM] [YoLink] mqtt received: yl-home/c460b484e49b4c08b33647d9815c9741/d88b4c010003b80d/report
{"event":"Siren.setState","time":1660154895916,"msgid":"1660154895915","data":{"state":"normal","loraInfo":{"signal":-60,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c010003b80d"}
[8/10/2022, 2:08:15 PM] [YoLink] Received mqtt message 'Siren.setState' for device: Siren Alarm (d88b4c010003b80d) State: 'normal'
[8/10/2022, 2:08:15 PM] [YoLink] Unsupported mqtt event: 'Siren.setState'
Please report at https://github.com/dkerr64/homebridge-yolink/issues
{"event":"Siren.setState","time":1660154895916,"msgid":"1660154895915","data":{"state":"normal","loraInfo":{"signal":-60,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c010003b80d"}
[8/10/2022, 2:08:16 PM] [YoLink] mqtt received: yl-home/c460b484e49b4c08b33647d9815c9741/d88b4c010003b80d/report
{"event":"Siren.setState","time":1660154896566,"msgid":"1660154896566","data":{"state":"normal","loraInfo":{"signal":-60,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c010003b80d"}
[8/10/2022, 2:08:16 PM] [YoLink] Received mqtt message 'Siren.setState' for device: Siren Alarm (d88b4c010003b80d) State: 'normal'
[8/10/2022, 2:08:16 PM] [YoLink] Unsupported mqtt event: 'Siren.setState'
Please report at https://github.com/dkerr64/homebridge-yolink/issues
{"event":"Siren.setState","time":1660154896566,"msgid":"1660154896566","data":{"state":"normal","loraInfo":{"signal":-60,"gatewayId":"d88b4c1603011301","gateways":1}},"deviceId":"d88b4c010003b80d"}

Thanks for the example button pressing. It looks like there is no documentation for this key fob at the YoLink site. I have ordered one as I think I will need actual device in hand to get this one working.

The buttons are configurable as well. That is probably the best route to take if you wish to incorporate it. Not a terrible purchase if your phone is unavailable and you have the alarm active.

My key fob is supposed to arrive tomorrow, so will tackle this one after I am able to play with it and see what messages it generates.

Please try 1.0.11 that I just published. It will setup a stateless programmable switch for the Yolink key fob. You can then attach actions to button press / double press / long press in HomeKit. I have noticed that you will not see anything change in the user interface of either Homebridge or Apple Home / etc. when you press buttons. But I did attach an action to turn on a light (single press) and then turn off (double press).

Work to be done to figure out if there is a way to use a single press to toggle... that is, if light on then turn it off, if off then turn it on.

I'm not a developer, but just an eager user. The keyfob is working with double-press and long press (no single press) and allows it to control Homekit scenes. This is great and much appreciated. Oh, both the single and double press just do the double press or so it appears. What I meant to say is both the single and double press do the same thing...register as a double press.

@hdinwiddie can you turn on verbose logging and report what is logged when you single press the button please (note, 1.0.14 that I pushed just now converted all "debug" to "verbose" so it is not necessary to enable debug mode, just turning on verbose will get the maximum logging). Thanks.

I"m not sure if this is what you meant, but this is the result of a single, double, and long press with verbose turned on:
[16/08/2022, 21:25:11] [YoLink] [verbose] mqtt received: yl-home/3b2cba5564d345e1ae52a04878d2ce8f/d88b4c0100035d21/report
{"event":"SmartRemoter.StatusChange","time":1660699511008,"msgid":"1660699511006","data":{"event":{"keyMask":2,"type":"Press"},"battery":4,"version":"0403","devTemperature":27,"loraInfo":{"signal":-66,"gatewayId":"d88b4c1603000b8c","gateways":1}},"deviceId":"d88b4c0100035d21"}
[16/08/2022, 21:25:11] [YoLink] [verbose] Battery level for YoLink Fob (d88b4c0100035d21) is: 75..100%
[16/08/2022, 21:25:11] [YoLink] MQTT: SmartRemoter.StatusChange for device YoLink Fob (d88b4c0100035d21) button 2 single press event
[16/08/2022, 21:25:23] [YoLink] [verbose] mqtt received: yl-home/3b2cba5564d345e1ae52a04878d2ce8f/d88b4c0100035d21/report
{"event":"SmartRemoter.StatusChange","time":1660699523932,"msgid":"1660699523931","data":{"event":{"keyMask":2,"type":"Press"},"battery":4,"version":"0403","devTemperature":27,"loraInfo":{"signal":-67,"gatewayId":"d88b4c1603000b8c","gateways":1}},"deviceId":"d88b4c0100035d21"}
[16/08/2022, 21:25:23] [YoLink] [verbose] Battery level for YoLink Fob (d88b4c0100035d21) is: 75..100%
[16/08/2022, 21:25:24] [YoLink] [verbose] mqtt received: yl-home/3b2cba5564d345e1ae52a04878d2ce8f/d88b4c0100035d21/report
{"event":"SmartRemoter.StatusChange","time":1660699524441,"msgid":"1660699524440","data":{"event":{"keyMask":2,"type":"Press"},"battery":4,"version":"0403","devTemperature":27,"loraInfo":{"signal":-67,"gatewayId":"d88b4c1603000b8c","gateways":1}},"deviceId":"d88b4c0100035d21"}
[16/08/2022, 21:25:24] [YoLink] MQTT: SmartRemoter.StatusChange for device YoLink Fob (d88b4c0100035d21) button 2 double press event (time between presses = 509ms, threshold = 800ms)
[16/08/2022, 21:25:24] [YoLink] [verbose] Battery level for YoLink Fob (d88b4c0100035d21) is: 75..100%
[16/08/2022, 21:25:37] [YoLink] [verbose] mqtt received: yl-home/3b2cba5564d345e1ae52a04878d2ce8f/d88b4c0100035d21/report
{"event":"SmartRemoter.StatusChange","time":1660699537544,"msgid":"1660699537544","data":{"event":{"keyMask":2,"type":"LongPress"},"battery":4,"version":"0403","devTemperature":27,"loraInfo":{"signal":-66,"gatewayId":"d88b4c1603000b8c","gateways":1}},"deviceId":"d88b4c0100035d21"}
[16/08/2022, 21:25:37] [YoLink] MQTT: SmartRemoter.StatusChange for device YoLink Fob (d88b4c0100035d21) button 2 long press event
[16/08/2022, 21:25:37] [YoLink] [verbose] Battery level for YoLink Fob (d88b4c0100035d21) is: 75..100%

@hdinwiddie I am not seeing the problem. The log you sent me shows all three click types are recognized...

[16/08/2022, 21:25:11] [YoLink] MQTT: SmartRemoter.StatusChange for device YoLink Fob (d88b4c0100035d21) button 2 single press event
[16/08/2022, 21:25:24] [YoLink] MQTT: SmartRemoter.StatusChange for device YoLink Fob (d88b4c0100035d21) button 2 double press event (time between presses = 509ms, threshold = 800ms)
[16/08/2022, 21:25:37] [YoLink] MQTT: SmartRemoter.StatusChange for device YoLink Fob (d88b4c0100035d21) button 2 long press event

and hose are generated based on four distinct messages received from YoLink (it takes two messages within 800ms to register as a double click).

David, you are right! I must have misconfigured it. I'm getting actions for all three types of button presses. It works great. I'd love to see the YoLink plugs working. Thanks for what you're doing.

@hdinwiddie I have opened a new issue #23 to log your request for adding YoLink outlets. Can you provide a copy of the log entry that states "YoLink device type: xxx is not supported by this plugin" and put it into #23 please. We can take it from there (will need some further log info, but only after I get the scaffolding in to support your outlets.

Thanks.

Closing this issue as I believe YoLink flex fob is now working. If anyone finds a problem please open a new issue. Thanks.

Here are two results from my YoLink outlet/plugs for your consideration:
[17/08/2022, 20:37:24] [YoLink] YoLink device type: 'Outlet' is not supported by this plugin (deviceID: d88b4c01000446bf)
Please report all bugs at https://github.com/dkerr64/homebridge-yolink/issues
{"deviceId":"d88b4c01000446bf","deviceUDID":"11171e2fc4684121a11b768aee7a1988","name":"Eero Router Power","token":"529BEF3A9327B4F16279C148FE7F4777","type":"Outlet","parentDeviceId":null}
[17/08/2022, 20:37:24] [YoLink] YoLink device type: 'Outlet' is not supported by this plugin (deviceID: d88b4c0100027529)
Please report all bugs at https://github.com/dkerr64/homebridge-yolink/issues
{"deviceId":"d88b4c0100027529","deviceUDID":"3dc1c62c7c544617a089b91e97e66595","name":"Infinity Bulb","token":"C3E7F542E0E4E8349D18BFEEA0675879","type":"Outlet","parentDeviceId":null}

@hdinwiddie please continue outlet discussion over in #23. Thanks.