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

Fix connection issues #7

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

davidjbradshaw
Copy link

@davidjbradshaw davidjbradshaw commented Jan 3, 2023

Hi thanks for creating this. I've been using it with my UHZ65 for a couple of months, but I've found that the connection between my projector and HomeBridge to be a bit intermittent and often times out. Issues #3 and #5 might be related to this as well.

I've made a few changes to make it recover silently when this happens, rather than throw an error at HomeKit. To achieve this I've made the following changes.

  • Stop switch flicking back to previous state, whist waiting for projector to start up, and then correcting itself. After the command is sent, updates to switch state are ignored for 3 seconds.
  • If no response from boot/shutdown messages in 1.5 seconds, drop connections, reopen and resend command.
  • If reconnect fails three times, stop and report error to HomeKit.
  • Send status command once per second, this can be changed with the optional pollInterval config setting, this is mainly to stop the projector silently dropping the connection, but does also make getting status changes from the projector more robust as well.
  • If 10 status requests go unanswered, drop and reopen connection.

In addition to this, I've added some extra logging and a logLevel to the config, with options for off, default and debug. Finally I converted the Magic Numbers to consts at the top of the file and tidied a couple of bits to help me as I went through this.

This was only meant to be a simple PR, but I seem to have rewritten about half the code and and expanded it by the same amount. I hope that is all OK.

Dave.

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

Successfully merging this pull request may close these issues.

1 participant