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

Allow more flexibility in service calls #561

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

th3w1zard1
Copy link
Collaborator

@th3w1zard1 th3w1zard1 commented Apr 8, 2023

This PR removes the following check from service calls:

if not lights and not entity_ids in service_call.data:
    raise ValueError(
    "Please inform the developers of your use case."
    " You must currently pass either the lights or the switches."
)

That is all. Wait no one more:

  • Service calls now default to CONF_TRANSITION instead of CONF_INITIAL_TRANSITION

Why I thought limiting the potential of the service calls just to baby unintentional inputs is beyond me as 5 minutes into trying to use the new service calls I wanted to adapt every switch at once.

Alternatively we could validate an optional argument CONF_USE_ALL_ENTITIES: bool when False will output the old errors, True will use all switches.

This PR does not modify the 'lights existing in multiple switches' validation.

I did refactor the schemas for some of the const.py entries (e.g. they all start with SCHEMA_ now

custom_components/adaptive_lighting/switch.py:393:1: C901 'async_setup_entry' is too complex (22)
@th3w1zard1
Copy link
Collaborator Author

th3w1zard1 commented Apr 8, 2023

EDIT: fixed by 8cc803f

if you didn't read the commit message it says:

custom_components/adaptive_lighting/switch.py:393:1: C901 'async_setup_entry' is too complex (22)

I know it's because there's too much stuff in async_entry_setup but as is the problem with the other PRs there's no easy way to fix it. #452, #559, and probably others all have this issue.

@th3w1zard1 th3w1zard1 linked an issue Apr 9, 2023 that may be closed by this pull request
@th3w1zard1 th3w1zard1 changed the title Allow more flexibility in service calls Allow more flexibility in service calls (fails pre-commit) Apr 10, 2023
@th3w1zard1 th3w1zard1 changed the title Allow more flexibility in service calls (fails pre-commit) Allow more flexibility in service calls Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom turn_on & turn_off services
2 participants