2019-12-01 22:12:57 +00:00
|
|
|
"""Intents for the light integration."""
|
2024-03-08 14:01:29 +00:00
|
|
|
|
2022-12-13 22:46:40 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2023-01-19 23:15:01 +00:00
|
|
|
import logging
|
|
|
|
|
2019-12-01 22:12:57 +00:00
|
|
|
import voluptuous as vol
|
|
|
|
|
2024-05-08 02:01:03 +00:00
|
|
|
from homeassistant.const import SERVICE_TURN_ON
|
2023-01-19 23:15:01 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2024-05-28 18:53:49 +00:00
|
|
|
from homeassistant.helpers import config_validation as cv, intent
|
2019-12-08 17:16:23 +00:00
|
|
|
import homeassistant.util.color as color_util
|
2019-12-01 22:12:57 +00:00
|
|
|
|
2024-05-28 18:53:49 +00:00
|
|
|
from . import ATTR_BRIGHTNESS_PCT, ATTR_COLOR_TEMP_KELVIN, ATTR_RGB_COLOR, DOMAIN
|
2019-12-01 22:12:57 +00:00
|
|
|
|
2023-01-19 23:15:01 +00:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2019-12-01 22:12:57 +00:00
|
|
|
INTENT_SET = "HassLightSet"
|
|
|
|
|
|
|
|
|
|
|
|
async def async_setup_intents(hass: HomeAssistant) -> None:
|
|
|
|
"""Set up the light intents."""
|
2024-05-08 02:01:03 +00:00
|
|
|
intent.async_register(
|
|
|
|
hass,
|
|
|
|
intent.ServiceIntentHandler(
|
|
|
|
INTENT_SET,
|
|
|
|
DOMAIN,
|
|
|
|
SERVICE_TURN_ON,
|
|
|
|
optional_slots={
|
|
|
|
("color", ATTR_RGB_COLOR): color_util.color_name_to_rgb,
|
2024-05-28 18:53:49 +00:00
|
|
|
("temperature", ATTR_COLOR_TEMP_KELVIN): cv.positive_int,
|
2024-05-08 02:01:03 +00:00
|
|
|
("brightness", ATTR_BRIGHTNESS_PCT): vol.All(
|
|
|
|
vol.Coerce(int), vol.Range(0, 100)
|
|
|
|
),
|
|
|
|
},
|
2024-05-21 16:54:34 +00:00
|
|
|
description="Sets the brightness or color of a light",
|
2024-05-28 20:46:08 +00:00
|
|
|
platforms={DOMAIN},
|
2024-05-08 02:01:03 +00:00
|
|
|
),
|
|
|
|
)
|