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

A big one - Refactoring & WebSocket Client Improvements #114

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

Conversation

dhutchison
Copy link

@dhutchison dhutchison commented Jul 8, 2020

This is a much bigger set of changes than I was intending to include in a single PR, but here it goes. I think it is time to start getting these changes looked at by a wider group. Ideally we can get these tested & merged in.

This has done a pile of refactoring to remove duplication in the plugin for how it was reading the status for devices. As part of this, and adding experimental support for getting the device status with WebSockets (#74), the approach to loading data has been separated out. In lib, there is now an api.js file which handles all the API operations which the plugin was performing. This then internally deals with working out what needs to go to the REST, WebSockets and Lan mode APIs depending on the feature flags enabled.

These feature flags are now documented in the README file, which is worth reading to get a feel for the changes being introduced.

There is also an additional fakeFan setting which I have been using to allow testing of Fan type devices. This refactoring has removed a lot of duplication in how the fan Active and Light statuses were being loaded, as these were just switches.

This has introduced for the LAN and WebSocket clients caching of device status information (albeit for a short period for the latter), which should help with issues where the websocket is closed due to too many quick requests being made for the same device.

The main area I have been unable to test changes in is for Blinds, so hoping someone is able to try some pre-release code to check if my branch functions.

Put the lan client behind an experimentalLanClient configuration setting
Seperating out API interaction code into seperate class
…et or http

Also fixes some bugs in previous commits, adds logging
 Uses a promise based approach to get the current device state for a device.
Also added a test call to the lan client to check promise approach works.

Still more work to do in this area.
Calling getDeviceStatus too quick results in errors, slowing down a bit.
Focus on Fan device testing with a fake device
@dhutchison dhutchison marked this pull request as ready for review July 8, 2020 22:59
@howanghk
Copy link
Owner

Wow thank you @dhutchison ! That's a lot of hard work! It would take some time for me to review this before merging.

@prasad-edlabadka
Copy link

Any tentative date for merging this?

@howanghk
Copy link
Owner

Hi @prasad-edlabadka please try https://github.com/bwp91/homebridge-ewelink which is more active and better.

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.

3 participants