-
Notifications
You must be signed in to change notification settings - Fork 463
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
update aeotec smart switch 7 for ST energy #1432
base: main
Are you sure you want to change the base?
update aeotec smart switch 7 for ST energy #1432
Conversation
AEOTEC_SMART_SWITCH_US = { | ||
MATCHING_MATRIX = { | ||
mfrs = 0x0371, | ||
product_types = 0x0103, |
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.
nit: spacing
Duplicate profile check: Passed - no duplicate profiles detected. |
Invitation URL: |
local ENERGY_UNIT_KWH = "kWh" | ||
|
||
local FINGERPRINTS = { | ||
{ mfr = 0x0086, prod = 0x0003, model = 0x00AF, deviceProfile = 'aeotec-smart-switch-7-eu' }, -- EU |
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 deviceProfile
field seems unused
{mfr = 0x0086, prodId = 0x0060}, | ||
{mfr = 0x0371, prodId = 0x00AF}, | ||
{mfr = 0x0371, prodId = 0x0017} | ||
{mfr = 0x0086, prodId = 0x0060} |
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.
You could leave these here and omit the handling of on/off commands in your new sub-driver and it would work fine.
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.
Alternatively, you could restructure this so you create a sub-driver of this driver that does special power/energy handling for these two specific models instead of adding a new top-level subdriver.
Test Results 64 files 402 suites 0s ⏱️ Results for commit 38545bf. ♻️ This comment has been updated with latest results. |
Minimum allowed coverage is Generated by 🐒 cobertura-action against 38545bf |
@@ -0,0 +1,122 @@ | |||
-- Copyright 2023 SmartThings |
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.
date
|
||
local function can_handle(opts, driver, device, ...) | ||
for _, fingerprint in ipairs(FINGERPRINTS) do | ||
if device:id_match(fingerprint.mfr, nil, fingerprint.prodId) then |
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 is the reason the tests are all failing now
your FINGERPRINTS
map has entries with mfr
, prod
, and model
, which do not match what you've used here.
Please include some tests of the new functionality. And I think this should be moved to a sub-driver of the existing smart switch driver, rather than being added at the top level. That way it can simply inherit the on/off behavior without redefining it. |
supported_capabilities = { | ||
capabilities.switch, | ||
capabilities.energyMeter, | ||
capabilities.powerMeter, | ||
capabilities.powerConsumptionReport, | ||
capabilities.colorControl | ||
}, |
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 doesn't do anything in sub-drivers
local function set_color(driver, device, command) | ||
local r, g, b = utils.hsl_to_rgb(command.args.color.hue, command.args.color.saturation, command.args.color.lightness) | ||
|
||
local set = SwitchColor:Set({ | ||
color_components = { | ||
{ color_component_id=SwitchColor.color_component_id.RED, value=r }, | ||
{ color_component_id=SwitchColor.color_component_id.GREEN, value=g }, | ||
{ color_component_id=SwitchColor.color_component_id.BLUE, value=b }, | ||
} | ||
}) | ||
device:send(set) | ||
|
||
local query_color = function() | ||
device:send( | ||
SwitchColor:Get({ color_component_id=SwitchColor.color_component_id.RED }), | ||
command.component | ||
) | ||
end | ||
|
||
device.thread:call_with_delay(constants.DEFAULT_GET_STATUS_DELAY, query_color) | ||
end |
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.
can I ask why this was redefined over the defaults?
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 added the handler because if it's not set, the color setting for the LED doesn't work.
How can I set the default handler for colorControl in the sub driver?
Or does it inherit from the parent driver? But if it inherits from the parent driver, why doesn't it work?
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.
it should be inherited from the parent driver, but the default uses the warm_white and cold_white params (set to 0). Perhaps that's why it doesn't work with your 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.
Okay, so can I leave my set_color handler in the sub-driver?
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.
Sure, though I think the Z-Wave spec says unexpected extra fields should just be ignored, rather than cause the command to fail, so worth keeping that in mind.
|
HI @greens , Are there any additional changes needed from Aeotec for this PR? |
|
||
local FINGERPRINTS = { | ||
{mfr = 0x0086, prodId = 0x0060}, |
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.
tests are failing because you removed this fingerprint
AEOTEC_SMART_SWITCH_US = { | ||
MATCHING_MATRIX = { | ||
mfrs = 0x0371, | ||
product_types = 0x0103, |
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.
tabs
No description provided.