dkerr64 / homebridge-yolink

Apache License 2.0
12 stars 2 forks source link

Add support for YoLink "finger" device #28

Closed dkerr64 closed 2 years ago

dkerr64 commented 2 years ago

Describe the solution you'd like:

Add support for YoLink "finger" device.

[20/08/2022, 17:07:45] [YoLink] YoLink device type: 'Finger' is not supported (Classroom garage door (xxx)) (initialize)
Please report all bugs at https://github.com/dkerr64/homebridge-yolink/issues
{"deviceId":"xxx","deviceUDID":"xxx","name":"Classroom garage door","token":"xxx","type":"Finger","parentDeviceId":null}

@hdinwiddie if you can please capture any other logs that reference this device please (e.g. use the YoLink app to press/release, that should trigger notifications on this plugin log.

dkerr64 commented 2 years ago

@hdinwiddie I'm looking at this and I think the finger device is like a push button... ie, has no state, it is neither on or off. When you activate it, it performs a push and release action. Can you confirm that? If so then I can implement it as a simple stateless pushbutton switch.

Now, of course, the bigger issue is that this is designed to work in conjunction with a garage door sensor... so can be used to open/close a garage door and maintain open/closed status by checking state of that sensor. That part will take a bit more work.

Thanks.

hdinwiddie commented 2 years ago

You've got it exactly right, but I'm conflicted about it having to work with a sensor as it seems to limit its use. I'd like to see it have the ability to work fine with or without the sensor. Here's a picture that might help you visualize what we're working with. IMG_1038

dkerr64 commented 2 years ago

I think first step is to be able to activate the "finger" from Homebridge... and that is probably best done with a simple "switch" that automatically turns itself off within a second of it being activated.

Now what we have are door sensors and door opener switches. I need to think of a way that a user can specify that two should be linked together to represent e.g. a garage door opener. If a user did that then they would no longer appear in Homebridge/Homekit as separate devices but rather as a single Garage Door. This will take more time !

dkerr64 commented 2 years ago

@hdinwiddie can you please activate the Finger device from the YoLink app, and also press the up and down buttons on the device and send me the logs from this plugin. I am hoping that when you activate it from those sources, some messages will be sent.

And what does the up/down button do? Is it supposed to represent garage door up/down, or just the "finger" action?

Thanks

hdinwiddie commented 2 years ago

Here is the log for the finger and for the sensor. I think they should be listed as separate devices because you can actually use one without the other. The finger will operate without the sensor but in the YoLink app, it gives you a warning because it can't actually know what the status is without a paired sensor. The sensor can either be paired to give an opener combo for folks who don't already have a smart opener as it's a really simple way of doing it and makes for a ridiculously easy install as you don't have to get out a ladder or even get close to the actual opener. If you don't use them in combo, a sensor alone mounted to the door will give you an open/closed status for use in whatever way you want whether as a voice notification or trigger to an automation for lights, etc. I'm attaching both the log and a couple screenshots of using the opener without a paired sensor. I'm still showing actions of an unpaired sensor which I have so understand I was just putting it in two positions to simulate the door opening/closing. In effect, it's much like a door sensor in that it just has two states...open and closed IMG_1041 IMG_1042 homebridge.loggarage door.txt .

hdinwiddie commented 2 years ago

I'm sorry I didn't answer the part about the up/down buttons. They aren't used from a programming standpoint but are there to let you set the range of travel of the finger from its "down" position to its "up" position, You won't see them in the logs.

dkerr64 commented 2 years ago

@hdinwiddie Thanks for the description and log. I'll look at it tonight.

hdinwiddie commented 2 years ago

Oops, I was wrong about the up/down buttons. They don't set the range but merely set how close (up/down) the finger is to the button you're wanting to press. It goes down until it feels a stop and then goes right back up. You can't make it stay down. If it were a relay (we still have that to talk about that YoLink device if you're willing) it would be called an "inching relay." Everything else I said was correct...I think

dkerr64 commented 2 years ago

@hdinwiddie can you please test with version 1.1.5 that I just posted. The finger device should appear as a regular switch but when you turn it "on" it will trigger the finger and then turn itself off after 1 second.

I am interested in seeing the "RECEIVED" log for anything identified as "Finger"... I am looking to see what data it returns for e.g. battery or anything else.

Thanks.

hdinwiddie commented 2 years ago

Ok, David, I used the finger to actually open/close my garage door first without the sensor and the state didn't change, but each time I pressed the open it would change state from open to closed. At the end of the log, I used the paired sensor and just flipped it open/closed as it would if it were attached. I hope it all makes sense when you look at the log. BTW I'm headed for bed (I'm an OLD guy) so will pick up with anything you ask in the morning. Thanks for what you're doing with this homebridge.log garage.txt .

hdinwiddie commented 2 years ago

@dkerr64 Ok, let's try this log. I cycled the finger ("classroom garage") several times and while I was at it cycled the YoLink garage door sensor several times. In the YoLink app I paired the sensor with the finger to get rid of warnings that it wasn't paired. I really like your version of this as it allows the finger to be used with any push button switch mechanical switch that could benefit from a longer "finger" than that in the SwitchBot device which I also have. This gives a lot of flexibility in how it might be used homebridgegaragedoor.log.txt .

dkerr64 commented 2 years ago

@hdinwiddie What you are seeing is expected for now... I have not "connected" a door sensor to the garage door controller (finger) in my plugin yet, so activating the button will not cause the door to show up as open (or closed). That is a work-in-progress. When done you will be able to pair together a sensor/controller which will then show up in Homebridge as a garage door.

I'll let you know when that is ready for testing... it is turning up some code design issues that require widespread changes (I had not anticipated the concept of having two YoLink "devices" attached to one Homebridge "accessory", I had assumed 1-to-1).

dkerr64 commented 2 years ago

@hdinwiddie please test with version 1.2 I just published. See the README documentation on binding two devices together for a Garage Door. You will need to add this to the config file (with your unique device IDs)...

"garageDoors": [
  {
    "controller": "0123456789abcdef",
    "sensor": "abcdef0123456789"
  }
] 

If the controller and sensor are battery powered then a battery "service" for each is added as well. I am interested in knowing if this works for you... as both your "finger" and "door sensor" are battery powered, it would mean two separate batteries being reported to HomeKit. I don't know if that works. I know one does... it looks like this...

image

But I don't know if two works.

Thanks

hdinwiddie commented 2 years ago

@dkerr64 That works Great the way it is now. I know you want the logs so I'm attaching them. First I operated the finger with the sensor in my hand to simulate door-open and door-closed. The status in Homebridge Accessories and in Homekit worked correctly showing the status of the door and allowing the door to be operated. Near the end I operated the finger several times without changing the sensor. The finger operated and because it didn't know the status it just showed "door opening" or "door closed" but it didn't stop it from working (I personally like it that way." I then operated the opener sensor by itself several times and it worked as you see in the log. This will allow the sensor to be purchased by someone and used by itself without the garage door finger. The configuration was easy thanks to the tip about the device ID's in the log. I can't see what more you'd want to do, but let me know if there's anything I can help with. You're doing a great job with the YoLink devices!! By the way, Eric said he hadn't heard back from you and I think you'll find him helpful in getting new things to work with. I did order the lock so will be able to help with that item if/when you're ready. homebridgeGarage.log .txt !

dkerr64 commented 2 years ago

@hdinwiddie I have noticed some sync issues between Apple Home and Homebridge... sometimes the icons don't show the same state. It usually sorts itself out after a few minutes.

I have added new feature to the garage door... when you activate the button it will go into either "opening" or "closing" state. Once the door sensor reports that it has completed, it changes into either "open" or "closed" state. Things can get out-of-sync if you control the door from the actual garage opener as well as Apple Home, especially if you press and press again before the door fully opens or closes.

YoLink devices cannot tell if a door is partially open or closed. But I can monitor the "opening" and "closing" such that if it does not complete within a specified timeout, then the door state reported to HomeBridge / Apple Home is reset to whatever its current state is. I have just implemented that with a default of 45 seconds (can be set between 10 and 120).

hdinwiddie commented 2 years ago

I thought it was just me that noticed the sync issues. It does happen sometimes and does sort itself out. I'm glad you explained it. I just did the update to 1.2.1 and see the entry for garage normal opening/closing time. I may actually try this on my garage door today as I've got it where I can see it and the door sensor and am not letting it actually push the door opener button. I already have other opener trigger devices like MyQ (Homebridge Plugin) and a Ewelink (another Homebridge Plugin) 4-port relay connected to yet another remote and don't want to start having trouble with my Alexa notification routines, but that's my problem to sort out. I'm attaching a screenshot of my current iPhone home screen so you can see that delayed status in my widget can be a bit irritating. That's not the YoLink opener showing but the MyQ opener IMG_1049 .

dkerr64 commented 2 years ago

Thanks for the update. I'm hopeful that I have garage doors working well now.