1 """Intents for the client integration."""
3 from __future__
import annotations
5 import voluptuous
as vol
10 from .
import DOMAIN, INTENT_GET_TEMPERATURE
14 """Set up the climate intents."""
19 """Handle GetTemperature intents."""
21 intent_type = INTENT_GET_TEMPERATURE
22 description =
"Gets the current temperature of a climate device or entity"
24 vol.Optional(
"area"): intent.non_empty_string,
25 vol.Optional(
"name"): intent.non_empty_string,
29 async
def async_handle(self, intent_obj: intent.Intent) -> intent.IntentResponse:
30 """Handle the intent."""
31 hass = intent_obj.hass
32 slots = self.async_validate_slots(intent_obj.slots)
34 name: str |
None =
None
36 name = slots[
"name"][
"value"]
38 area: str |
None =
None
40 area = slots[
"area"][
"value"]
42 match_constraints = intent.MatchTargetsConstraints(
43 name=name, area_name=area, domains=[DOMAIN], assistant=intent_obj.assistant
45 match_result = intent.async_match_targets(hass, match_constraints)
46 if not match_result.is_match:
47 raise intent.MatchFailedError(
48 result=match_result, constraints=match_constraints
51 response = intent_obj.create_response()
52 response.response_type = intent.IntentResponseType.QUERY_ANSWER
53 response.async_set_states(matched_states=match_result.states)
intent.IntentResponse async_handle(self, intent.Intent intent_obj)
None async_setup_intents(HomeAssistant hass)