1 """Support for the LiteJet lighting system."""
12 from .const
import DOMAIN, PLATFORMS
14 _LOGGER = logging.getLogger(__name__)
18 """Set up LiteJet via a config entry."""
19 port = entry.data[CONF_PORT]
22 system = await pylitejet.open(port)
23 except pylitejet.LiteJetError
as exc:
24 raise ConfigEntryNotReady
from exc
26 def handle_connected_changed(connected: bool, reason: str) ->
None:
28 _LOGGER.debug(
"Connected")
30 _LOGGER.warning(
"Disconnected %s", reason)
32 system.on_connected_changed(handle_connected_changed)
34 async
def handle_stop(event: Event) ->
None:
37 entry.async_on_unload(
38 hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, handle_stop)
41 hass.data[DOMAIN] = system
43 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
49 """Unload a LiteJet config entry."""
50 unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
53 await hass.data[DOMAIN].close()
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)