Skip to content

Conversation

NoahCornell
Copy link
Contributor

Check all that apply

Type of Change

  • WWST Certification Request
    • If this is your first time contributing code:
      • I have reviewed the README.md file
      • I have reviewed the CODE_OF_CONDUCT.md file
      • I have signed the CLA
    • I plan on entering a WWST Certification Request or have entered a request through the WWST Certification console at developer.smartthings.com
  • Bug fix
  • New feature
  • Refactor

Checklist

  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have verified my changes by testing with a device or have communicated a plan for testing
  • I am adding new behavior, such as adding a sub-driver, and have added and run new unit tests to cover the new behavior

Description of Change

This change is to help facilitate the migration of an old hue bridge to the pro hue bridge. Currently, the driver holds a mapping of hue resource IDs to smartthings devices records. This becomes a problem when adding the new pro to smartthings because the children of the pro will have the same resource ids as they did when on the old bridge. Child creation is gated by if we already have a record of that hue resource ID. The driver also makes assumptions throughout that the hue resource ID is unique.

By splitting up the mapping by hue bridge, we shouldn't run into any issues with collusions and should be able to re-create the devices on the new pro bridge.

Summary of Completed Tests

By hue setup is currently offline so I haven't had a chance to test this yet.

Copy link

github-actions bot commented Sep 10, 2025

Channel deleted.

Copy link

Test Results

   69 files  ±0    450 suites  ±0   0s ⏱️ ±0s
2 343 tests ±0  2 343 ✅ ±0  0 💤 ±0  0 ❌ ±0 
3 938 runs  ±0  3 938 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 856f35f. ± Comparison against base commit ad066d6.

Copy link

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 856f35f

return
end
local v2_resource_id = svc_info.rid or ""
if driver:get_device_by_dni(v1_dni) or driver.hue_identifier_to_device_record[v2_resource_id] then return end
Copy link
Contributor Author

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

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 {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to log if driver.hue_identifier_to_device_record_by_bridge[bridge_id] is nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor

@nickolas-deboom nickolas-deboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good from my perspective contingent on how testing goes. I'm curious to see if things will behave nicely with duplicated resource ids. Although, from my testing the old hub should go offline anyways after the migration to the new one.

@NoahCornell
Copy link
Contributor Author

Tested on my setup and things are looking good. Batch commands and offline/online tracking via zigbee connectivity status are working correctly.

This just needs testing with the migration path to make sure the new devices are created.

@nickolas-deboom
Copy link
Contributor

I tested the migration path and things are looking good on that front as well. The presence of the old hub and devices no longer prevents the creation of bridged devices on the new hub.

@NoahCornell NoahCornell merged commit 754f2a7 into main Sep 22, 2025
11 checks passed
@NoahCornell NoahCornell deleted the bugfix/hue_pro_migration_device_create branch September 22, 2025 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants