Skip to content
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

Add Aqara Climate Sensor W100 #1843

Merged
merged 6 commits into from
Jan 23, 2025

Conversation

DongHoon-Ryu
Copy link
Contributor

This device has a Temperature Sensor(0x0302), a Humidity Sensor(0x0307), and 3 Generic Switchs(0x000F).

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

As the first type of device with buttons in the sensor device, button feature is added to the sensor EdgeDriver

Summary of Completed Tests

Successful test for Plugin UI and Dashboard update according to the change of sensor or button operation

Copy link

Duplicate profile check: Passed - no duplicate profiles detected.

Copy link

github-actions bot commented Dec 26, 2024

Channel deleted.

Copy link

github-actions bot commented Dec 26, 2024

Test Results

   64 files    406 suites   0s ⏱️
2 013 tests 2 013 ✅ 0 💤 0 ❌
3 489 runs  3 489 ✅ 0 💤 0 ❌

Results for commit 8f513e2.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Dec 26, 2024

File Coverage
All files 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/eve-energy/init.lua 91%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/embedded-cluster-utils.lua 38%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/aqara-cube/init.lua 96%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 8f513e2

@hcarter-775
Copy link
Contributor

Since the matter-switch driver is the most complete and vast of our drivers, I believe it would be more prudent to include new humidity and temperature support in matter-switch rather than including the whole array of switch logic in matter-sensor.

@DongHoon-Ryu
Copy link
Contributor Author

Since the matter-switch driver is the most complete and vast of our drivers, I believe it would be more prudent to include new humidity and temperature support in matter-switch rather than including the whole array of switch logic in matter-sensor.

Thanks, I modified to support w100 in matter-switch, not matter-sensor.

@@ -0,0 +1,99 @@
name: temperature-humidity-3-button-battery
Copy link
Contributor

Choose a reason for hiding this comment

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

can we change this name to 3-button-battery-temperature-humidity? This follows the unofficial naming conventions more closely.

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 changed temperature-humidity-3-button-battery to 3-button-battery-temperature-humidity.

Choose a reason for hiding this comment

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

@@ -0,0 +1,99 @@
+name: temperature-humidity-3-button-battery

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Apshakil Sorry, Please refer to my latest commit(8f513e2)

local main_endpoint = find_default_endpoint(device)
local main_endpoint
if device:supports_capability(capabilities.temperatureMeasurement) then
-- In case of Aqara Climate Sensor W100, in order to sequentially set the button name to button1, 2, 3
Copy link
Contributor

Choose a reason for hiding this comment

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

@nickolas-deboom out of curiosity, is this sequential ordering not the default handling? If not, seems like we should change that?

Copy link
Contributor

@nickolas-deboom nickolas-deboom Jan 7, 2025

Choose a reason for hiding this comment

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

I believe that what is happening is that since this device doesn't contain a 'switch' endpoint (aka an endpoint containing the OnOff cluster), find_default_endpoint is returning the first button endpoint as the main endpoint. That would cause the first button component name to be 'main' and the other two would be 'button2' and 'button3'. I think that find_default_endpoint should be updated rather than using the workaround here. Either it could be updated to check for an endpoint containing the TemperatureMeasurement (or RelativeHumidityMeasurement) cluster and return that as the default endpoint if one exists, or it could be updated to just return the first non-button endpoint if one exists (rather than checking for OnOff/TemperatureMeasurement/RelativeHumidityMeasurement clusters).

Copy link
Contributor

@hcarter-775 hcarter-775 Jan 7, 2025

Choose a reason for hiding this comment

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

Yes, +1 to this

Copy link
Contributor

Choose a reason for hiding this comment

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

@nickolas-deboom @DongHoon-Ryu not that this is a huge deal, but I think these changes that Nick suggested were missed in this PR.

local main_endpoint = find_default_endpoint(device)
local main_endpoint
if device:supports_capability(capabilities.temperatureMeasurement) then
-- In case of Aqara Climate Sensor W100, in order to sequentially set the button name to button1, 2, 3
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
-- In case of Aqara Climate Sensor W100, in order to sequentially set the button name to button1, 2, 3
-- In case of Aqara Climate Sensor W100, in order to sequentially set the button name to button 1, 2, 3

Copy link
Contributor Author

@DongHoon-Ryu DongHoon-Ryu Jan 22, 2025

Choose a reason for hiding this comment

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

@hcarter-775 I modified as below. I deleted the fingerprint of the Aqara Climate Sensor W100 device and modified it as follows because device:supports_capability is not available at the init stage if there is no fingerprint of the device. The reason for deleting fingerprint is added to the review opinion below.

  local temperature_eps = device:get_endpoints(clusters.TemperatureMeasurement.ID)
  local humidity_eps = device:get_endpoints(clusters.RelativeHumidityMeasurement.ID)
  if #temperature_eps > 0 and #humidity_eps > 0 then
    -- In case of Aqara Climate Sensor W100, in order to sequentially set the button name to button 1, 2, 3
    main_endpoint = device.MATTER_DEFAULT_ENDPOINT
  else
    main_endpoint = find_default_endpoint(device)
  end

Copy link
Contributor

Choose a reason for hiding this comment

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

@DongHoon-Ryu thank you for making this update, it addresses the comment I made above as well.

Comment on lines 599 to 632
if device:supports_capability(capabilities.temperatureMeasurement) then
-- to call configure_buttons, keep the profile_name as nil.
device.log.debug("So far, it means Aqara Climate Sensor W100.")
elseif battery_support then
profile_name = string.format("%d-button-battery", #button_eps)
else
profile_name = string.format("%d-button", #button_eps)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if device:supports_capability(capabilities.temperatureMeasurement) then
-- to call configure_buttons, keep the profile_name as nil.
device.log.debug("So far, it means Aqara Climate Sensor W100.")
elseif battery_support then
profile_name = string.format("%d-button-battery", #button_eps)
else
profile_name = string.format("%d-button", #button_eps)
if device:supports_capability(capabilities.temperatureMeasurement) and device:supports_capability(capabilities.relativeHumidityMeasurement) then
profile_name = "temperature-humidity"
end
if battery_support then
profile_name = string.format("%d-button-battery", #button_eps) .. profile_name
else
profile_name = string.format("%d-button", #button_eps) .. profile_name

@nickolas-deboom do you think we should support full dynamicism here (a device:get_endpoints() call) or is leaving this as a fingerprint specific handling ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

the .. profile_name assumes the profile name has been changed according to my previous comment

Copy link
Contributor

Choose a reason for hiding this comment

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

I am fine with it either way for now, especially since we'd just be re-profiling to the same profile it has already joined. If we start supporting more devices like this in the future then I'd definitely support making it more dynamic.

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed, that was my thinking as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nickolas-deboom @hcarter-775 If we use fingerprint of Aqara Climate Sensor W100 device, there is a problem that configure_buttons(device) is not called because a value is assigned to profile_name. So I modified to use the number of temperature_eps and humidity_eps obtained using device:get_endpoints to specify profile in the more dynamic way you mentioned.

    if #button_eps > 1 and tbl_contains(STATIC_BUTTON_PROFILE_SUPPORTED, #button_eps) then
      if #temperature_eps > 0 and #humidity_eps > 0 then
        device.log.debug("So far, it means Aqara Climate Sensor W100.")
        profile_name = "-temperature-humidity"
      end
      if battery_support then
        profile_name = string.format("%d-button-battery", #button_eps) .. profile_name
      else
        profile_name = string.format("%d-button", #button_eps) .. profile_name
      end
    elseif not battery_support then
      -- a battery-less button/remote
      profile_name = "button"
    end

    if profile_name ~= "" then
      device:try_update_metadata({profile = profile_name})
      device:set_field(DEFERRED_CONFIGURE, true)
      device:set_field(BUTTON_DEVICE_PROFILED, true)
    else
      configure_buttons(device)
    end

@hcarter-775 hcarter-775 mentioned this pull request Jan 7, 2025
12 tasks
@DongHoon-Ryu
Copy link
Contributor Author

DongHoon-Ryu commented Jan 22, 2025

@nickolas-deboom @hcarter-775 @Apshakil Thank you for your comments on many reviews all the time. Please review and if there is no problem, please approve.

@nickolas-deboom
Copy link
Contributor

@DongHoon-Ryu this looks good to me! Thank you for making the requested updates.

@HunsupJung HunsupJung merged commit 7171fd3 into SmartThingsCommunity:main Jan 23, 2025
12 checks passed
zhouchengyu-cell pushed a commit to zhouchengyu-cell/SmartThingsEdgeDrivers that referenced this pull request Jan 24, 2025
* Add Aqara Climate Sensor W100

This device has a Temperature Sensor(0x0302), a Humidity Sensor(0x0307), and 3 Generic Switchs(0x000F).

* It is modified to support w100 in Matter-switch, not Matter-sensor.

* Revert "It is modified to support w100 in Matter-switch, not Matter-sensor."

This reverts commit 511f361.

* It is modified to support w100 in matter-switch, not matter-sensor.

* It is modified to support w100 in matter-switch, not matter-sensor.

* Use device:get_endpoints to delete the device's fingerprint and modify it to operate more dynamically
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.

5 participants