-
Notifications
You must be signed in to change notification settings - Fork 24
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
Wake on Lan #199
base: master
Are you sure you want to change the base?
Wake on Lan #199
Conversation
The skipped tests are very odd... I have a distinct memory of getting test coverage up to 100%, I must not have pushed it. If you were more than halfway done with tests, then I'd appreciate them, otherwise I can look for the branch where I was adding tests and I can write tests for this change myself. |
Nah, I was just getting started. |
My
|
Oh, I see what you're saying. My TV says Not sure how that should be codified without knowing more about WoL support. |
Maybe it would be better to fire off a |
I think firing off packets to both addresses makes sense. But what do you mean about having to call |
Ah sorry I misremembered how things worked. I was thinking that the setters needed to return the new value but maybe not. I'm just not sure what happens if you say power on, homebridge thinks the tv was successfully powered on, but in reality the tv never received the WOL packet. Before this change, if it couldn't reach the tv, then the homebridge callback would be called with and error. Now it's possible to call the callback with success, when the command didn't actually work. |
.catch(callback); | ||
.on('get', async (callback) => { | ||
try { | ||
const info = await pTimeout(this.roku.info(), this.requestTimeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this again, will this ever work as expected? If the TV is off, this will fail immediately and never trigger the TimeoutError check below. I don't think we even need to use pTimeout at all. We can always try sending the WOL packet if this initially fails. Then you'd have to retry this.roku.info()
to see if it actually turned on (the retry would need to be done after some timeout to give it time to turn on), then if it still isn't on, you call callback with the error, otherwise with null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this again, will this ever work as expected?
It's been working for me so far 😛.
If the TV is off, this will fail immediately and never trigger the TimeoutError check below.
Nope, this.roku.info()
doesn't resolve until around 10 seconds later if the TV is offline; node-fetch which is used by the Roku package sorta has timeout support but I don't think the Roku package implements it.
Good point; maybe we could add something that runs 5-10 seconds after the WoL packet is sent to see if the TV is now on? |
Related to #4.
I believe the information in the above issue may be outdated, or my TV may just be different (2020 series 6). My situation:
/device-info
endpoint that WoL is supported.So the TL;DR is that adding WoL support helps lower my energy bill while still allowing HomeKit to turn on my TV. 😛
It's a fairly naive implementation right now but seems to work well. One caveat is that scenes which change the input and turn on the TV at the same time don't work if the TV is offline; but that doesn't seem like a dealbreaker.
I started adding tests but then realized that many were skipped. Is that something you want me to still do?