-
Notifications
You must be signed in to change notification settings - Fork 484
Philips-hue batched command handling support #2075
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Channel deleted. |
Test Results 67 files 426 suites 0s ⏱️ Results for commit 90da94a. ♻️ This comment has been updated with latest results. |
Minimum allowed coverage is Generated by 🐒 cobertura-action against 90da94a |
3307b88
to
7f479e2
Compare
if not grouped_light_id then | ||
log.error(string.format("Couldn't find grouped light id for group %s", | ||
group.id or "unknown group id")) | ||
return |
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.
if we fail this call does it fall back to unicast commands?
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.
Not right now, but it could be added. In the case of grouped_light_id
being nil
, this shouldn't be possible because we clear out the device table if it isn't on the group response. This is a remnant of when I was iterating through the services in the commands and wasn't saving the service off on group intake.
5a2e335
to
677455e
Compare
drivers/SmartThings/philips-hue/src/utils/batched_command_utils.lua
Outdated
Show resolved
Hide resolved
@@ -4,6 +4,7 @@ local HueDeviceTypes = { | |||
BUTTON = "button", | |||
CONTACT = "contact", | |||
DEVICE_POWER = "device_power", | |||
GROUPED_LIGHT = "grouped_light", |
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.
Does this make anything go wonky during disco? I can't remember how smart the checks around this table actually are 😬
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 that is based off PrimaryDeviceTypes
below on line 22 but I will take a closer look
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.
Oh this could be an issue with is_valid_device_type
so I think I will remove it just to be safe.
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.
Code looks good, I'll try to test this on my home setup tomorrow morning.
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.
LGTM, but we definitely need the confidence of some manual testing.
Sorry just updated description with my testing. We are also working with thinktank to get some early testing. |
677455e
to
0bb54a6
Compare
if queue == nil then | ||
local tx, rx = cosock.channel.new() | ||
-- Set timeout to 30 seconds to allow for other queued scans to come in. | ||
rx:settimeout(30) |
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 seems like an odd way to achieve this from my perspective. I would probably just use https://github.ecodesamsung.com/iot-hub/scripting-engine/blob/main/lua_libs/st/driver.lua#L112 and store the timer in the GROUPS_SCAN_QUEUE
field, then cancel and restart the timer if it's not nil when this is called. I don't think this approach is wrong, so you don't need to change it, I just think it's a bit counter intuitive to set a timeout and depend on it being hit on receive.
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.
Yeah that makes sense. I forgot about that function to be honest. One slight benefit here is that we don't have to recreate the closure and new timer each time this is called which could add up with if we receive a lot of added events but I doubt it matters all that much.
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.
Yeah, I agree there are some benefits of doing it this way, and given that you've built and tested it I don't see a need to change at this point.
This was quite verbose when handling batched commands. https://smartthings.atlassian.net/browse/CHAD-15166
2f3a52c
to
90da94a
Compare
ThinkTank testings results: https://smartthings.atlassian.net/wiki/spaces/HUBPLT/pages/3890250154/2025-04-16+Hue+Jiffy+Pop+Testing+Results I did a few more onboarding and general testing this morning and feeling good so I am going to merge this. |
Check all that apply
Type of Change
Checklist
Description of Change
This is adding batched command handling support for the philips-hue driver by taking advantage of hue's rooms and zones. The group is interacted with via the
grouped_light
service which supports all of the same APIs that we use to control devices via thelight
service.The batched commands are ingested into the driver by overriding the top level capability handler in the driver. This is overridden if the hub has support for the
receive_batch
function on the capability channel socket. Commands that are handled individually are sent to the default handler while commands that are determined to be a match for a group are sent via the new grouped light command handlers.Commit by commit:
GROUPS
on the bridge device. As CUD events flow through the SSE stream, the driver will handle these and update the bridge device groups accordingly. Groups are augmented with a list of device records and thegrouped_light
resource ID when ingested so that time can be saved when processing a command batch. The groups are ordered by most to least device records when added to the list of groups.get_hue_bridge_for_device
which was very verbose when processing the batched command.Summary of Completed Tests
Tested on my hue setup with 1 bridge and 10 bulbs. 3 of which are full color, 1 color temperature, and the other 6 plain dimmable white.
I have 1 room with all the bulbs, a zone for the color bulbs, a zone for the color temp (color + 1) bulbs, and a zone for the rest minus 1.
I have 2 rules for each capability to change states: on/off, level 10%/100%, color red/blue, temp warm/cold where only the relevant devices are in those rules.
I also have a rule for 9 of the 10 to run which covers the 4 color temp supported bulbs and 5 of the white bulbs to testing going to multiple zones in one batch
This is mainly what I have been using for testing but I have been trying other random permutations as well.