-
Notifications
You must be signed in to change notification settings - Fork 510
philips-hue: Split mapping of hue resource IDs by bridge #2389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,6 +345,7 @@ end | |
---@param driver HueDriver | ||
---@param device HueDevice | ||
---@param parent_device_id string? | ||
---@param quiet boolean? | ||
---@return HueBridgeDevice? bridge_device | ||
function utils.get_hue_bridge_for_device(driver, device, parent_device_id, quiet) | ||
local _ = quiet or | ||
|
@@ -371,6 +372,27 @@ function utils.get_hue_bridge_for_device(driver, device, parent_device_id, quiet | |
return utils.get_hue_bridge_for_device(driver, parent_device, nil, quiet) | ||
end | ||
|
||
--- Get the mapping of hue id to device table by associated bridge. The mapping is separated by bridge to account | ||
--- for devices migrated to a new hue bridge. | ||
---@param driver HueDriver | ||
---@param bridge_or_device HueDevice | ||
---@return table<string,HueChildDevice>? hue_id_to_device | ||
function utils.get_hue_id_to_device_table_by_bridge(driver, bridge_or_device) | ||
-- If bridge_or_device is a bridge this will just return itself | ||
local bridge = utils.get_hue_bridge_for_device(driver, bridge_or_device) | ||
if not bridge then | ||
log.warn(string.format("Failed to lookup bridge for device %s", bridge_or_device.label)) | ||
return nil | ||
end | ||
local bridge_id = bridge:get_field(Fields.BRIDGE_ID) | ||
if not bridge_id then | ||
log.warn(string.format("Failed to get bridge id for %s", bridge.label)) | ||
return nil | ||
end | ||
driver.hue_identifier_to_device_record_by_bridge[bridge_id] = driver.hue_identifier_to_device_record_by_bridge[bridge_id] or {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to log if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so since it would be expected the first time that we try to get a table for a certain bridge |
||
return driver.hue_identifier_to_device_record_by_bridge[bridge_id] | ||
end | ||
|
||
--- build a exponential backoff time value generator | ||
--- | ||
---@param max number the maximum wait interval (not including `rand factor`) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what is currently gating us from creating the devices, specifically the last part of the conditional