-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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
Intent: Set light color #12633
Intent: Set light color #12633
Conversation
params[ATTR_RGB_COLOR] = color_util.color_name_to_rgb(color_name) | ||
try: | ||
params[ATTR_RGB_COLOR] = color_util.color_name_to_rgb(color_name) | ||
except ValueError: |
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.
color_name_to_rgb
will now raise instead of silently returning white if no match found. I've added that logic back in the only place that depended on it.
The two things I would change would be to change it to HassTurnOnSet and have it support turning on the light and setting brightness as well as color since you wouldn't want to have to Turn it on, Set it to green, and set brightness to 50% as three intents, you would want an intent to handle all of those as one step. "Turn the living room light to green and fifty percent" (turn on implied). And I apologize I won't have too much time to work on the snips side since I am traveling for a conference over the next couple weeks. |
Thanks for the feedback and that's a great point! Will address it. |
89a3e2f
to
0c8281b
Compare
Alright, so I made it now so that you can pass in brightness and color. Response will also be based on whatever was set. This makes even a better case for not basing it off the ServiceIntentHandler. I do wonder if we can generalize it a bit more but we'll see that once we have added a couple more to other components. |
46eaf62
to
36984a4
Compare
Description:
Add an intent for changing the color of a light.
I initially tried to add this logic into
helpers.intent.ServiceIntentHandler
but failed miserably. I realized that for the set color service to be supported, I needed to add support for:So after hacking it into it, I realized that I made it only more confusing. So instead, I went with another approach: make reusable pieces of functionality to quickly add together a new intent handler.
I borrowed a trick from aiohttp: if you raise
IntentHandlerError
, it should be converted to speech for the end user (Snips, Alexa, etc). That way we can have reusable helper methods that can trigger a response when they encounter an error.CC @tschmidty69
Related issue (if applicable): #12087
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>
Checklist:
If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass