1
0
mirror of https://github.com/home-assistant/core.git synced 2025-05-22 14:57:14 +00:00
Allen Porter 6675b497bd
Improve LLM tool descriptions for brightness and volume percentage ()
* Improve tool descriptions for brightness and volume percentage

* Address lint errors

* Update intent.py to revert of a light

* Create explicit types to make intent slots more future proof

* Remove comments about slot type

---------

Co-authored-by: Franck Nijhof <git@frenck.dev>
2025-03-08 22:28:35 -05:00

49 lines
1.6 KiB
Python

"""Intents for the light integration."""
from __future__ import annotations
import logging
import voluptuous as vol
from homeassistant.const import SERVICE_TURN_ON
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, intent
from homeassistant.util import color as color_util
from . import ATTR_BRIGHTNESS_PCT, ATTR_COLOR_TEMP_KELVIN, ATTR_RGB_COLOR
from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
INTENT_SET = "HassLightSet"
async def async_setup_intents(hass: HomeAssistant) -> None:
"""Set up the light intents."""
intent.async_register(
hass,
intent.ServiceIntentHandler(
INTENT_SET,
DOMAIN,
SERVICE_TURN_ON,
optional_slots={
"color": intent.IntentSlotInfo(
service_data_name=ATTR_RGB_COLOR,
value_schema=color_util.color_name_to_rgb,
),
"temperature": intent.IntentSlotInfo(
service_data_name=ATTR_COLOR_TEMP_KELVIN,
value_schema=cv.positive_int,
),
"brightness": intent.IntentSlotInfo(
service_data_name=ATTR_BRIGHTNESS_PCT,
description="The brightness percentage of the light between 0 and 100, where 0 is off and 100 is fully lit",
value_schema=vol.All(vol.Coerce(int), vol.Range(0, 100)),
),
},
description="Sets the brightness percentage or color of a light",
platforms={DOMAIN},
),
)