1 """Support for Hive light devices."""
3 from __future__
import annotations
5 from datetime
import timedelta
6 from typing
import TYPE_CHECKING, Any
20 from .
import refresh_system
21 from .const
import ATTR_MODE, DOMAIN
22 from .entity
import HiveEntity
25 from apyhiveapi
import Hive
32 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
34 """Set up Hive thermostat based on a config entry."""
36 hive: Hive = hass.data[DOMAIN][entry.entry_id]
37 devices = hive.session.deviceList.get(
"light")
44 """Hive Active Light Device."""
46 def __init__(self, hive: Hive, hive_device: dict[str, Any]) ->
None:
47 """Initialise hive light."""
49 if self.
devicedevicedevice[
"hiveType"] ==
"warmwhitelight":
52 elif self.
devicedevicedevice[
"hiveType"] ==
"tuneablelight":
55 elif self.
devicedevicedevice[
"hiveType"] ==
"colourtuneablelight":
64 """Instruct the light to turn on."""
68 if ATTR_BRIGHTNESS
in kwargs:
69 tmp_new_brightness = kwargs[ATTR_BRIGHTNESS]
70 percentage_brightness = (tmp_new_brightness / 255) * 100
71 new_brightness =
int(round(percentage_brightness / 5.0) * 5.0)
72 if new_brightness == 0:
74 if ATTR_COLOR_TEMP
in kwargs:
75 tmp_new_color_temp = kwargs[ATTR_COLOR_TEMP]
76 new_color_temp = round(1000000 / tmp_new_color_temp)
77 if ATTR_HS_COLOR
in kwargs:
78 get_new_color = kwargs[ATTR_HS_COLOR]
79 hue =
int(get_new_color[0])
80 saturation =
int(get_new_color[1])
81 new_color = (hue, saturation, 100)
83 await self.
hivehive.light.turnOn(
84 self.
devicedevicedevice, new_brightness, new_color_temp, new_color
89 """Instruct the light to turn off."""
93 """Update all Node data from Hive."""
98 ATTR_MODE: self.attributes.
get(ATTR_MODE),
104 if self.
devicedevicedevice[
"hiveType"] ==
"tuneablelight":
106 if self.
devicedevicedevice[
"hiveType"] ==
"colourtuneablelight":
107 if self.
devicedevicedevice[
"status"][
"mode"] ==
"COLOUR":
_attr_extra_state_attributes
_attr_supported_color_modes
None async_turn_off(self, **Any kwargs)
None __init__(self, Hive hive, dict[str, Any] hive_device)
None async_turn_on(self, **Any kwargs)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
IssData update(pyiss.ISS iss)