Feat/adapter revision - #10
Conversation
- Change authentication header from Bearer token to X-API-Key - Fix response parsing to extract results array from wrapped API responses - Remove group members lookup (API doesn't provide this field) - Update window_mapping.json with actual UUIDs from Halio API
…nconfirmed if entirely accurate)
…is set to include /api now
There was a problem hiding this comment.
Pull Request Overview
This PR fixes critical issues with the Halio API adapter discovered during initial trailer testing. The changes update authentication from Bearer tokens to X-API-Key headers, improve response handling for the wrapped API response format, and update configuration with actual Halio window UUIDs and local API endpoint.
Key Changes:
- Switched authentication from
Authorization: BearertoX-API-Keyheader - Added response wrapper handling to extract
resultsfield from API responses - Updated window mappings from placeholder UUIDs to actual production UUIDs
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| web/package-lock.json | Removed "peer": true flag from React dependency |
| svc/main.py | Added dotenv loading at module initialization to ensure environment variables are available |
| svc/data/window_mapping.json | Updated all panel-to-window UUID mappings with actual production values |
| svc/data/panels_config.json | Modified group assignments and renamed group from "G-1" to "G-2" |
| svc/data/exampleGroupsResp.json | Removed trailing whitespace/characters |
| svc/app/simulator.py | Removed duplicate create_group method definition |
| svc/app/service.py | Removed duplicate create_group method definition |
| svc/app/config.py | Changed default HALIO_API_URL to local trailer endpoint (192.168.2.200:8084) |
| svc/app/adapter.py | Updated authentication method, added response wrapper handling, improved error handling with 206 status code support, and added validation for API responses |
| README.md | Updated file structure documentation and license information |
Files not reviewed (1)
- web/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| return self._state_cache[window_id] | ||
| elif response.status_code == 206: | ||
| # No Tint Data - API returns: {"statusCode": 200, "message": "No Tint Data", "success": true} |
There was a problem hiding this comment.
The comment states the API returns "statusCode": 200 for the "No Tint Data" case, but the code is checking for response.status_code == 206. This is inconsistent. The comment should be updated to reflect the correct status code (206), or if the API documentation indicates 200, the code should be corrected.
| id=group_id, | ||
| name=hg.get("name", f"Group {group_id}"), | ||
| member_ids=member_panel_ids, | ||
| member_ids=[], # Groups API doesn't provide member windows |
There was a problem hiding this comment.
Setting member_ids=[] for all groups will break the set_group() method (lines 324-331, not shown in diff), which relies on iterating over g.member_ids to update state cache and return affected panels. When member_ids is always empty, set_group() will always return an empty list even when the group tint command is accepted, causing the service to incorrectly report "no panels updated due to dwell time".
If the Halio Groups API truly doesn't provide member information, consider:
- Fetching members from a separate API endpoint
- Maintaining a local group-to-members mapping
- Returning a success indicator without specific panel IDs when members are unknown
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
After our first trailer visit we realized that our adapter was not properly set up to interact with the Halio API. So wee have since adjusted how we handle the responses, and make sure we are calling the correct endpoints. Also we switched from authenticating with bearer tokens to x-api-key. This also includes some small updates to README.
Type
Testing
Tested Sim and real mode (without API access). No new behaviors, and tests still pass.
Risk and rollout
No risk, as it already wasn't functioning. If it still isn't, additional revision will be required.
Checklist