1 """Coordinator for Govee light local."""
4 from collections.abc
import Callable
7 from govee_local_api
import GoveeController, GoveeDevice
14 CONF_DISCOVERY_INTERVAL_DEFAULT,
15 CONF_LISTENING_PORT_DEFAULT,
16 CONF_MULTICAST_ADDRESS_DEFAULT,
17 CONF_TARGET_PORT_DEFAULT,
21 _LOGGER = logging.getLogger(__name__)
23 type GoveeLocalConfigEntry = ConfigEntry[GoveeLocalApiCoordinator]
27 """Govee light local coordinator."""
29 def __init__(self, hass: HomeAssistant) ->
None:
30 """Initialize my coordinator."""
34 name=
"GoveeLightLocalApi",
35 update_interval=SCAN_INTERVAL,
41 broadcast_address=CONF_MULTICAST_ADDRESS_DEFAULT,
42 broadcast_port=CONF_TARGET_PORT_DEFAULT,
43 listening_port=CONF_LISTENING_PORT_DEFAULT,
44 discovery_enabled=
True,
45 discovery_interval=CONF_DISCOVERY_INTERVAL_DEFAULT,
46 discovered_callback=
None,
51 """Start the Govee coordinator."""
56 self, callback: Callable[[GoveeDevice, bool], bool]
58 """Set discovery callback for automatic Govee light discovery."""
59 self.
_controller_controller.set_device_discovered_callback(callback)
62 """Stop and cleanup the cooridinator."""
65 async
def turn_on(self, device: GoveeDevice) ->
None:
66 """Turn on the light."""
67 await device.turn_on()
69 async
def turn_off(self, device: GoveeDevice) ->
None:
70 """Turn off the light."""
71 await device.turn_off()
73 async
def set_brightness(self, device: GoveeDevice, brightness: int) ->
None:
74 """Set light brightness."""
75 await device.set_brightness(brightness)
78 self, device: GoveeDevice, red: int, green: int, blue: int
80 """Set light RGB color."""
81 await device.set_rgb_color(red, green, blue)
84 """Set light color in kelvin."""
85 await device.set_temperature(temperature)
89 """Return a list of discovered Govee devices."""
None set_discovery_callback(self, Callable[[GoveeDevice, bool], bool] callback)
None set_brightness(self, GoveeDevice device, int brightness)
None set_temperature(self, GoveeDevice device, int temperature)
list[GoveeDevice] devices(self)
None __init__(self, HomeAssistant hass)
None turn_off(self, GoveeDevice device)
list[GoveeDevice] _async_update_data(self)
None set_rgb_color(self, GoveeDevice device, int red, int green, int blue)
None turn_on(self, GoveeDevice device)
asyncio.Event cleanup(self)