-
Notifications
You must be signed in to change notification settings - Fork 497
Sort EPs before get device type and add unit test #2216
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
base: main
Are you sure you want to change the base?
Sort EPs before get device type and add unit test #2216
Conversation
Invitation URL: |
Test Results 68 files 444 suites 0s ⏱️ Results for commit 25255d0. ♻️ This comment has been updated with latest results. |
Minimum allowed coverage is Generated by 🐒 cobertura-action against 25255d0 |
@@ -534,7 +534,14 @@ local function get_endpoints_for_dt(device, device_type) | |||
end | |||
|
|||
local function get_device_type(device) |
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.
I think a slightly more generic version of this function could be:
local function get_device_type(device)
local device_type_found = {}
for _, ep in ipairs(device.endpoints) do
if ep.device_types ~= nil then
for _, dt in ipairs(ep.device_types) do
device_type_found[dt.device_type_id] = true
end
end
end
for _, id in ipairs({
RAC_DEVICE_TYPE_ID,
AP_DEVICE_TYPE_ID,
THERMOSTAT_DEVICE_TYPE_ID,
FAN_DEVICE_TYPE_ID,
WATER_HEATER_DEVICE_TYPE_ID,
HEAT_PUMP_DEVICE_TYPE_ID
}) do if device_type_found[id] then return id end end
return false
end
This ensures that we're not just basing the logic on which device type we see first, but rather the order of "precedence" that we give the device types in the drivers. I tested this and confirmed it works with your test case. Thanks
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.
We also think this is a more generic version and updated PR.
We tested with real device, it works fine, thank you.
Check all that apply
Type of Change
Checklist
Description of Change
We find
device.endpoints
sometimes is disordered, like “ep0, ep5, ep1, ep3, ep4, ep2“. So we plan to sort device endpoints in ASC before judging the device type of equipment,Summary of Completed Tests
We added Unit Test and tested with real device.