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

update aeotec smart switch 7 for ST energy #1432

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

iot-holding
Copy link

No description provided.

AEOTEC_SMART_SWITCH_US = {
MATCHING_MATRIX = {
mfrs = 0x0371,
product_types = 0x0103,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: spacing

Copy link

Duplicate profile check: Passed - no duplicate profiles detected.

Copy link

local ENERGY_UNIT_KWH = "kWh"

local FINGERPRINTS = {
{ mfr = 0x0086, prod = 0x0003, model = 0x00AF, deviceProfile = 'aeotec-smart-switch-7-eu' }, -- EU
Copy link
Contributor

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}
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link

github-actions bot commented Jun 11, 2024

Test Results

   64 files    402 suites   0s ⏱️
1 999 tests 1 999 ✅ 0 💤 0 ❌
3 450 runs  3 450 ✅ 0 💤 0 ❌

Results for commit 38545bf.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jun 11, 2024

File Coverage
All files 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/multi-metering-switch/init.lua 93%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/inovelli-LED/init.lua 93%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/qubino-switches/qubino-relays/qubino-flush-1d-relay/init.lua 83%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/aeotec-smart-switch/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/qubino-switches/qubino-relays/init.lua 84%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/preferences.lua 99%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/configurations.lua 99%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/inovelli-2-channel-smart-plug/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/fibaro-wall-plug-us/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/qubino-switches/init.lua 85%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/zwave-dual-switch/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/aeotec-heavy-duty/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/zooz-power-strip/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/eaton-5-scene-keypad/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-switch/src/qubino-switches/qubino-relays/qubino-flush-2-relay/init.lua 97%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 38545bf

@@ -0,0 +1,122 @@
-- Copyright 2023 SmartThings
Copy link
Contributor

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
Copy link
Contributor

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.

@greens
Copy link
Contributor

greens commented Jun 11, 2024

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.

@greens greens closed this Jun 11, 2024
@greens greens reopened this Jun 11, 2024
Comment on lines 131 to 137
supported_capabilities = {
capabilities.switch,
capabilities.energyMeter,
capabilities.powerMeter,
capabilities.powerConsumptionReport,
capabilities.colorControl
},
Copy link
Contributor

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

Comment on lines +107 to +127
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
Copy link
Contributor

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?

Copy link
Contributor

@mh-zwave mh-zwave Aug 22, 2024

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?

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor

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.

@greens
Copy link
Contributor

greens commented Jul 16, 2024

Checking drivers/SmartThings/zwave-switch/src/aeotec-smart-switch/init.lua 1 error

    drivers/SmartThings/zwave-switch/src/aeotec-smart-switch/init.lua:34:3: (E011) expected '}' (to close '{' on line 32) near '{'

@Brianj94
Copy link
Contributor

HI @greens , Are there any additional changes needed from Aeotec for this PR?


local FINGERPRINTS = {
{mfr = 0x0086, prodId = 0x0060},
Copy link
Contributor

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,
Copy link
Contributor

Choose a reason for hiding this comment

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

tabs

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