dkerr64/homebridge-yolink

Add support for YoLink outlet

dkerr64 opened this issue · 15 comments

Describe the solution you'd like:
Support YoLink single- and multi-outlets.

@hdinwiddie can you please test version 1.0.15 that I just published, I have added experimental support for single outlets. I do not know if it will work so I would appreciate if you can capture logs with verbose enabled. You will also have to enable experimental mode. So in the config settings please set...

"verboseLog": true,
"enableExperimental": true,

Let me know how it goes.

Thank you.

@hdinwiddie I should add that what I did was simply tell the plugin to treat an outlet as a switch... a quick and dirty hack so can gather data on the info sent to/from the device. So it will appear in home bridge as a switch not an outlet for now.

@dkerr64 I'm not at all sure what I'm doing, but grabbed this from the verbose log which looked like it found my YoLink outlet/plug which I'm using to power cycle my Eero router:

{"deviceId":"d88b4c01000446bf","deviceUDID":"11171e2fc4684121a11b768aee7a1988","name":"Eero Router Power","token":"529BEF3A9327B4F16279C148FE7F4777","type":"Outlet","parentDeviceId":null}

I'm not seeing it in the Accessories. I also saw this in the log that you might want to see:

[18/08/2022, 11:17:23] [YoLink] Fatal error during YoLink plugin initialization:
TypeError: Cannot read properties of undefined (reading 'hasBattery')
at new YoLinkPlatformAccessory (/var/lib/homebridge/node_modules/homebridge-yolink/src/platformAccessory.ts:45:51)
at YoLinkHomebridgePlatform.registerDevices (/var/lib/homebridge/node_modules/homebridge-yolink/src/platform.ts:184:25)
at YoLinkHomebridgePlatform.discoverDevices (/var/lib/homebridge/node_modules/homebridge-yolink/src/platform.ts:127:18)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

If you need more, tell me. I'm pretty excited about what you've done and what you're doing.

@hdinwiddie thanks for testing. The error is unexpected, I will look into it. Also, I have ordered a YoLink outlet which should arrive tomorrow... so good chance I will have single outlets working this weekend.

@hdinwiddie please try version 1.1 that I just published.

You have lots of devices!!! Thanks for the log, I will look through it as soon as I have time.

I'l loving your log, lots of good stuff in here. I will open separate issues to track implementing the finger device and multi-outlet. I don't have either any while I might be tempted to buy the power strip, I'm not sure what I'd use the finger for!

The more interesting discussion is what to do about all the retry/errors. I have observed this myself (see latest README). The YoLink API is responding okay (the can't connect to device is coming back from them, not generated by me). New with this update I added retry's on failure where as before it just failed. And I am logging it all. I was not expecting it to be very common, but your experience suggests that it might be common. The problem is not fatal, but maybe 5 retries over space of 10 seconds is not tolerant enough... I should perhaps give more time for YoLink to recover, and repeat maybe 10 times (I could make it configurable too). And I could reduce the logging to verbose for each retry and info for final failure (which is not fatal, as Homebridge will still try again later). This would make it far less scary in the logs.

@hdinwiddie you can certainly point Eric at this plugin. I have not proactively mentioned this plugin on e.g. Reddit mainly because I wanted to mature it a bit... but I think I'm at the point where it is worth getting more eyes on it.

I have opened #28 and #29 to track finger and multi-outlet... please add any info (logs) you have on those devices there. I suggest turning off debug (homebridge) and verbose (this plugin config) if either were set.

I will push version 1.1.2 soon, that will reduce the intensity of logging for retries (if you set liteLog to true then you won't see all the retry attempts).

@hdinwiddie Github blocks public sharing of email addresses, so I can't see the address you posted. But I think I know his direct address, if not I certainly know the support address at YoSmart. I'll send him an email.