1 """Support for the Philips Hue system."""
3 from aiohue.util
import normalize_bridge_id
10 from .bridge
import HueBridge
11 from .const
import DOMAIN, SERVICE_HUE_ACTIVATE_SCENE
12 from .migration
import check_migration
13 from .services
import async_register_services
17 """Set up a bridge from a config entry."""
23 if not await bridge.async_initialize_bridge():
32 unique_id = normalize_bridge_id(api.config.bridge_id)
33 if entry.unique_id
is None:
34 hass.config_entries.async_update_entry(entry, unique_id=unique_id)
38 elif entry.unique_id != unique_id:
43 for entry
in hass.config_entries.async_entries(DOMAIN)
44 if entry.unique_id == unique_id
48 if other_entry
is None:
50 hass.config_entries.async_update_entry(entry, unique_id=unique_id)
52 elif other_entry.source == SOURCE_IGNORE:
54 hass.async_create_task(
55 hass.config_entries.async_remove(other_entry.entry_id)
57 hass.config_entries.async_update_entry(entry, unique_id=unique_id)
60 hass.async_create_task(hass.config_entries.async_remove(entry.entry_id))
64 device_registry = dr.async_get(hass)
65 if bridge.api_version == 1:
66 device_registry.async_get_or_create(
67 config_entry_id=entry.entry_id,
68 connections={(dr.CONNECTION_NETWORK_MAC, api.config.mac_address)},
69 identifiers={(DOMAIN, api.config.bridge_id)},
70 manufacturer=
"Signify",
72 model=api.config.model_id,
73 sw_version=api.config.software_version,
77 api.config.model_id ==
"BSB002"
78 and api.config.software_version <
"1935144040"
80 persistent_notification.async_create(
83 "Your Hue hub has a known security vulnerability ([CVE-2020-6007] "
84 "(https://cve.circl.lu/cve/CVE-2020-6007)). "
85 "Go to the Hue app and check for software updates."
91 device_registry.async_get_or_create(
92 config_entry_id=entry.entry_id,
93 connections={(dr.CONNECTION_NETWORK_MAC, api.config.mac_address)},
95 (DOMAIN, api.config.bridge_id),
96 (DOMAIN, api.config.bridge_device.id),
98 manufacturer=api.config.bridge_device.product_data.manufacturer_name,
100 model=api.config.model_id,
101 sw_version=api.config.software_version,
108 """Unload a config entry."""
109 unload_success = await hass.data[DOMAIN][entry.entry_id].async_reset()
110 if len(hass.data[DOMAIN]) == 0:
111 hass.data.pop(DOMAIN)
112 hass.services.async_remove(DOMAIN, SERVICE_HUE_ACTIVATE_SCENE)
113 return unload_success
None async_register_services(HomeAssistant hass)
None check_migration(core.HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)