-
-
Notifications
You must be signed in to change notification settings - Fork 146
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
Change attributes in AdaptiveSwitch via service call #443
Change attributes in AdaptiveSwitch via service call #443
Conversation
switch should now set settings in __settings__ method and only define the nonchangeable initial attributes in its __init__ method
8ca9490
to
6b1a52d
Compare
4d56611
to
af4b343
Compare
next on bugtest agenda: try to break the component with malformed arguments.
All example values have been directly pulled from 'const.py' allowing users to press 'fill example data' to fill defauts. For some reason 'sunrise_offset' and 'sunset_offset' couldn't be strings
d0705b0
to
c2cf1b6
Compare
I bugtested this using a myriad of extraordinary values in the service call, the only oddity I could find was sunrise_offset and sunset_offset are both required to be a number. example: |
Please don't hesitate to ask for any changes in my implementation! Love the project, thanks for developing it! |
for more information, see https://pre-commit.ci
This PR is as finished as it'll ever be. |
This looks awesome! Great job 😄 I think I will be able to give this a try tonight or otherwise tomorrow. |
@basnijholt I just finished your suggested reviews here |
@basnijholt Could you respond to my other reviews here before you merge this one?
|
I merged in the master branch and fixed the merge conflict. |
I think the offset should be smaller than a value at which the sunset+offset ≥ next sunrise. |
Please don't merge without PR review approval. And also use squash. |
Squashed commit of the following: commit ef15d6a Author: Benjamin Auquite <halomastar@gmail.com> Date: Mon Mar 27 03:18:43 2023 -0500 Readd `platform` from older release commit 8d867e5 Merge: a858b94 0127496 Author: Benjamin Auquite <halomastar@gmail.com> Date: Mon Mar 27 03:01:23 2023 -0500 Merge branch 'master' into change-config-via-service-call commit 0127496 Author: Bas Nijholt <basnijholt@gmail.com> Date: Sun Mar 26 22:47:50 2023 -0700 Add example of how to pass command line args (#483) commit a858b94 Author: Bas Nijholt <bas@nijho.lt> Date: Sat Mar 25 21:11:55 2023 -0700 Rename switch.__settings__ to switch._set_changeable_settings commit bb6eac1 Author: Bas Nijholt <bas@nijho.lt> Date: Sat Mar 25 21:10:17 2023 -0700 small change in handle_change_switch_settings commit 2005806 Merge: a7acdb1 66e65e2 Author: Bas Nijholt <bas@nijho.lt> Date: Sat Mar 25 20:46:19 2023 -0700 Merge remote-tracking branch 'origin/master' into change-config-via-service-call commit a7acdb1 Merge: c9d42ad 8c630c9 Author: Benjamin Auquite <halomastar@gmail.com> Date: Sat Mar 25 15:43:27 2023 -0500 Merge remote-tracking branch 'upstream/master' into change-config-via-service-call commit c9d42ad Author: Benjamin Auquite <halomastar@gmail.com> Date: Sat Mar 25 14:49:34 2023 -0500 @basnijholt's reviews commit 538341f Author: Benjamin Auquite <halomastar@gmail.com> Date: Sat Mar 25 13:43:00 2023 -0500 More formatting All mess and no formatting makes jack a dull boy. commit 9c72787 Author: Benjamin Auquite <halomastar@gmail.com> Date: Sat Mar 25 13:11:15 2023 -0500 Update README.md commit ba1b6cb Author: Benjamin Auquite <halomastar@gmail.com> Date: Sat Mar 25 12:57:40 2023 -0500 Removed unmodifyable options from service call. modifying `interval`, `name`, or `lights` isn't possible. commit bdb4733 Author: Benjamin Auquite <halomastar@gmail.com> Date: Tue Mar 21 23:01:43 2023 -0500 Run pre-commit again commit 3809b6d Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed Mar 22 03:41:37 2023 +0000 [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci commit 71c9bd5 Author: Benjamin Auquite <halomastar@gmail.com> Date: Tue Mar 21 22:41:07 2023 -0500 Run pre-commit commit 3ba8190 Author: Benjamin Auquite <halomastar@gmail.com> Date: Tue Mar 14 05:58:39 2023 -0500 Delete change_switch_settings_full_service_data.txt commit 0111379 Author: Benjamin Auquite <halomastar@gmail.com> Date: Tue Mar 14 05:55:26 2023 -0500 Delete temp.txt commit c2cf1b6 Author: Benjamin Auquite <halomastar@gmail.com> Date: Tue Mar 14 04:24:13 2023 -0500 Removed custom workflow from pytest.yaml commit 7a2edbf Author: Benjamin Auquite <halomastar@gmail.com> Date: Tue Mar 14 04:00:50 2023 -0500 Update services.yaml All example values have been directly pulled from 'const.py' allowing users to press 'fill example data' to fill defauts. For some reason 'sunrise_offset' and 'sunset_offset' couldn't be strings commit 30135c3 Author: Benjamin Auquite <halomastar@gmail.com> Date: Tue Mar 14 03:13:00 2023 -0500 Updated services.yaml commit 8f101da Author: Benjamin Auquite <halomastar@gmail.com> Date: Tue Mar 14 03:01:03 2023 -0500 added fixes from bugtests next on bugtest agenda: try to break the component with malformed arguments. commit 4b38729 Author: Benjamin Auquite <halomastar@gmail.com> Date: Tue Mar 14 02:10:12 2023 -0500 Update pytest.yaml commit cb92ce6 Author: Benjamin Auquite <halomastar@gmail.com> Date: Tue Mar 14 02:09:24 2023 -0500 refactored slightly commit af4b343 Author: Benjamin Auquite <halomastar@gmail.com> Date: Tue Mar 14 01:58:18 2023 -0500 fixed syntax errors commit 5e8b065 Author: Benjamin Auquite <halomastar@gmail.com> Date: Mon Mar 13 23:50:41 2023 -0500 rewrote method of changing settings switch should now set settings in __settings__ method and only define the nonchangeable initial attributes in its __init__ method commit 506c810 Author: Benjamin Auquite <halomastar@gmail.com> Date: Sun Mar 12 16:06:32 2023 -0500 initial bugtest done commit 84b95d6 Author: Benjamin Auquite <halomastar@gmail.com> Date: Sun Mar 12 12:40:45 2023 -0500 initial commit no tests done
@@ -130,6 +130,14 @@ adaptive_lighting: | |||
| `lights` | yes | entity_id(s) of lights, if not specified, all lights in the switch are selected. | | |||
| `manual_control` | yes | Whether to add ('true') or remove ('false') the light from the 'manual_control' list, default: true | | |||
|
|||
`adaptive_lighting.change_switch_settings` (new in 1.5.0) Change any of the above configuration options of Adaptive Lighting (such as `sunrise_time` or `prefer_rgb_color`) with a service call directly from your script/automation. |
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.
1.7.0
I have changed the merge to a squash merge and made some "review" changes in #485 😄 |
* Retroactive review changes for #443 * Move up __init__ * Add test for test_change_switch_settings_service * Add docs * Add test for defaults * Remove unused function * Add skip var * move pylint marker * Refactor validate * Update README.md --------- Co-authored-by: Benjamin Auquite <halomastar@gmail.com>
A possible alternative to PR #235
I added a service call for users to modify a switch on the fly, exactly how they would in the config flow, while still keeping overhead low.
__settings__
is called by__init__
andchange_switch_settings()
to set all variables defined in the service call data and the config flow.__init__
now only initializes variables we don't want the user touching, such as_lock
andswitch._name
the function validate() had to be refactored slightly to allow calling with service call data instead of ConfigEntry.
change_switch_settings()
has been fully written up inservices.yaml
, with example data pulled straight from the defaults ofconst.py