-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Add BBSolar Smart Plant Light support, improve device handling for more complex mixins. #414
Open
jeremypm
wants to merge
19
commits into
albertogeniola:0.4.X.X
Choose a base branch
from
jeremypm:0.4.X.X
base: 0.4.X.X
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…, allowing significantly more robust filtering and selection of devices.
…mixins Feature/add dynamic dispatch for mixins
…luminanceMixin. Some cleanup is still required.
…l all relevant functions. This allows things like diamond inheritance to work correctly. Also renamed luminance test case.
…ss of plantlights.
…hanges to a given light, causing the luminance to "jump"
Feature/add bbsolar support
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for the BBSolar Smart Plant Light (https://bbsolar.cc/products/smart-grow-light). This is a complex series of changes.
In order to support this, two new mixins were created:
These mixins (especially the plantLightMixin) wouldn't have worked with the existing backend. Implementing this (extremely weird) product required a significant amount of work on the backend. This PR also folds a range of changes in the device class. The BBSolar Smart Plant Lights use multiple channels to represent a single "physical" light, which should be represented as a device. However, it doesn't expose any "unique" abilities to indicate that this is the case.
The present approach to identifying mixin components (e.g. via abilities) doesn't facilitate this sort of identification. This PR migrates from using the ABILITY_MATRIX (within the device_factory) to a dynamic loading/dispatch facility. First, all mixins are loaded from the given package. Mixins are annotated with a special class: DynamicFilteringMixin, which exposes the "filter" function. When a new cached type is build, the filter function is run for each device ability/type. If it returns true, that mixin is assumed to be part of the device.
Separation of the "extended" abilities is handled by class inheritance. For example, the ToggleMixin class represents the TOGGLE ability, and extends from DynamicFilteringMixin. The ToggleXMixin class extends from Toggle, and contains a unique filter function for TOGGLEX abilities. Some logic within the class loader prevents Toggle from being loaded if a subclass already is (e.g.toggleX).
Other changes were required, such as the addition of the channelRemappingMixin class, which allows the detected channel info to be remapped. This is required since the light presents 10 channels: main, light A, light B (which only support on/off operations) and each individual channel (which support luminance).
Finally, call chaining (e.g. use of super()) was removed for push notifications and device updates performed in the mixin. This is required to allow the multiple inheritance required for the plantLight to work correctly.
The plantLightMixin presents the light as 3 channels: first is a main channel, which allows control of both light strips. The next two represent each light.
Test cases have been added for the mixins and the backend modifications.