Skip to content

Conversation

@hcarter-775
Copy link
Contributor

@hcarter-775 hcarter-775 commented Dec 29, 2025

Description of Change

Update scroll profile to support knob capability. Include unique event handlers for knob and initial press.

This breaks apart the work found in #2669 so that the knob capability support can be reviewed as an isolated unit.

Summary of Completed Tests

Unit test included. Tested on-device.

@github-actions
Copy link

Duplicate profile check: Passed - no duplicate profiles detected.

@github-actions
Copy link

@github-actions
Copy link

github-actions bot commented Dec 29, 2025

Test Results

   71 files    482 suites   0s ⏱️
2 492 tests 2 492 ✅ 0 💤 0 ❌
4 277 runs  4 277 ✅ 0 💤 0 ❌

Results for commit d3b8761.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Dec 29, 2025

File Coverage
All files 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/embedded_cluster_utils.lua 38%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/device_configuration.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/utils.lua 91%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_handlers/capability_handlers.lua 89%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_handlers/attribute_handlers.lua 85%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_handlers/event_handlers.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/third_reality_mk1/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_handlers/attribute_handlers.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_handlers/capability_handlers.lua 78%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/eve_energy/init.lua 91%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_utils/device_configuration.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_utils/utils.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/aqara_cube/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/ikea_scroll/can_handle.lua 75%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against d3b8761

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.

I left a comment about some confusion I had, but the rest all looks good from my perspective. As long as this has been testing on device and everything's working, I don't see any reason to hold up any of these changes. Nice work!

if switch_utils.tbl_contains(scroll_fields.ENDPOINTS_PUSH, ib.endpoint_id) then
generic_event_handlers.initial_press_handler(driver, device, ib, response)
else
device:set_field(scroll_fields.LATEST_NUMBER_OF_PRESSES_COUNTED, 1)
Copy link

Choose a reason for hiding this comment

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

I think the "ticks" calculations are incorrect for the events sent by Bilresa.
For example, when fast scrolling the wheel for 14 "ticks", the messages sent by the Bilresa are as follows:

  • InitialPress(1)
  • InitialPress(1)
  • MultiPressOngoing(1, 11)
  • InitialPress(1)
  • MultiPressOngoing(1, 14)

which means that instead of 14 "ticks", this event handler will count 28 "ticks" (1 + 1 + 11 + 1 + 14) because LATEST_NUMBER_OF_PRESSES_COUNTED is reset to 1 after each InitialPress event.

I think it would be better to use the MultiPressComplete event to "reset" the ticks counter, while also adding a time-based safeguard in case the MultiPressComplete is lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @perexis, thanks for the investigation on your part. That is interesting that the MultiPressComplete event is not always being sent during fast scrolling. I will look into this further, though on first glance it seems unclear whether InitialPress or MultiPressComplete should be considered the "final say" for how these scroll events are interpreted.

Copy link

@perexis perexis Jan 28, 2026

Choose a reason for hiding this comment

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

Hi @hcarter-775
I'm not saying that MultiPressComplete is not generated when fast scrolling. It is not generated because the driver does not subscribe to this event as it was not needed.
I am saying that it is not possible to correctly handle the rotate sequence without subscribing to this event. The fast scrolling was just an example to show the huge error in the calculations.

When the driver subscribes to the MultiPressComplete, the sequence changes to:

  • InitialPress(1)
  • InitialPress(1)
  • MultiPressOngoing(1, 11)
  • InitialPress(1)
  • MultiPressOngoing(1, 14)
  • MultiPressComplete(1, 14)

I modified a little your code and successfully tested it - the full 360 degrees rotation generates knob event with rotateAmount=100 in total. Please take a look at my suggestion and feel free to integrate it into your code it if you think it's worth applying.

Subscribe also to MultiPressComplete:

IkeaScrollFields.switch_scroll_subscribed_events = {
  clusters.Switch.events.InitialPress.ID,
  clusters.Switch.events.MultiPressOngoing.ID,
  clusters.Switch.events.MultiPressComplete.ID,
}

Attach handler for the MultiPressComplete event:

matter_handlers = {
    event = {
      [clusters.Switch.ID] = {
        [clusters.Switch.events.InitialPress.ID] = event_handlers.initial_press_handler,
        [clusters.Switch.events.MultiPressOngoing.ID] = event_handlers.multi_press_ongoing_handler,
        [clusters.Switch.events.MultiPressComplete.ID] = event_handlers.multi_press_complete_handler,
      }
    }
  },

Handle the MultiPressComplete event:

IkeaScrollFields.SCROLL_STARTED = "__scroll_started"
function IkeaScrollEventHandlers.initial_press_handler(driver, device, ib, response)
  -- use the generic handler logic for the push endpoints. Else, use custom logic.
  if switch_utils.tbl_contains(scroll_fields.ENDPOINTS_PUSH, ib.endpoint_id) then
    generic_event_handlers.initial_press_handler(driver, device, ib, response)
  else
    -- prevent multiple executions in the same scroll sequence
    if not device:get_field(scroll_fields.SCROLL_STARTED) then
        device:set_field(scroll_fields.LATEST_NUMBER_OF_PRESSES_COUNTED, 1)
        rotate_amount_event_helper(device, ib.endpoint_id, 1)
        device:set_field(scroll_fields.SCROLL_STARTED, 1)
    end
  end
end
function IkeaScrollEventHandlers.multi_press_complete_handler(driver, device, ib, response)
  if switch_utils.tbl_contains(scroll_fields.ENDPOINTS_PUSH, ib.endpoint_id) then
    generic_event_handlers.multi_press_complete_handler(driver, device, ib, response)
  else
    -- end the scroll sequence
    device:set_field(scroll_fields.SCROLL_STARTED, nil)
  end
end

Copy link
Contributor Author

@hcarter-775 hcarter-775 Jan 29, 2026

Choose a reason for hiding this comment

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

Hi @perexis, thank you for reporting this. I did some investigation and saw the same behavior. In the current implementation, I have chosen to ignore the InitialPress notification altogether in favor of MultiPressComplete, and in the interest of simplicity, to otherwise keep the logic the same as before.

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.

4 participants