HassTurnOn/Off intents to also handle cover entities (#86206)
* Move entity/area resolution to async_match_states * Special case for covers in HassTurnOn/Off * Enable light color/brightness on areas * Remove async_register from default agent * Remove CONFIG_SCHEMA from conversation component * Fix intent tests * Fix light test * Move entity/area resolution to async_match_states * Special case for covers in HassTurnOn/Off * Enable light color/brightness on areas * Remove async_register from default agent * Remove CONFIG_SCHEMA from conversation component * Fix intent tests * Fix light test * Fix humidifier intent handlers * Remove DATA_CONFIG for conversation * Copy ServiceIntentHandler code to light * Add proper errors to humidifier intent handlers
This commit is contained in:
parent
8f10c22a23
commit
5aca996f22
8 changed files with 429 additions and 228 deletions
|
@ -41,10 +41,18 @@ class HumidityHandler(intent.IntentHandler):
|
|||
"""Handle the hass intent."""
|
||||
hass = intent_obj.hass
|
||||
slots = self.async_validate_slots(intent_obj.slots)
|
||||
state = intent.async_match_state(
|
||||
hass, slots["name"]["value"], hass.states.async_all(DOMAIN)
|
||||
states = list(
|
||||
intent.async_match_states(
|
||||
hass,
|
||||
name=slots["name"]["value"],
|
||||
states=hass.states.async_all(DOMAIN),
|
||||
)
|
||||
)
|
||||
|
||||
if not states:
|
||||
raise intent.IntentHandleError("No entities matched")
|
||||
|
||||
state = states[0]
|
||||
service_data = {ATTR_ENTITY_ID: state.entity_id}
|
||||
|
||||
humidity = slots["humidity"]["value"]
|
||||
|
@ -85,12 +93,18 @@ class SetModeHandler(intent.IntentHandler):
|
|||
"""Handle the hass intent."""
|
||||
hass = intent_obj.hass
|
||||
slots = self.async_validate_slots(intent_obj.slots)
|
||||
state = intent.async_match_state(
|
||||
hass,
|
||||
slots["name"]["value"],
|
||||
hass.states.async_all(DOMAIN),
|
||||
states = list(
|
||||
intent.async_match_states(
|
||||
hass,
|
||||
name=slots["name"]["value"],
|
||||
states=hass.states.async_all(DOMAIN),
|
||||
)
|
||||
)
|
||||
|
||||
if not states:
|
||||
raise intent.IntentHandleError("No entities matched")
|
||||
|
||||
state = states[0]
|
||||
service_data = {ATTR_ENTITY_ID: state.entity_id}
|
||||
|
||||
intent.async_test_feature(state, HumidifierEntityFeature.MODES, "modes")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue