Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions drivers/SmartThings/zigbee-switch/fingerprints.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
zigbeeManufacturer:
- id: "_TZ3000_hurauima/TS0726"
deviceLabel: Zemismart KES606 4 Gang
manufacturer: _TZ3000_hurauima
model: TS0726
deviceProfileName: scene-switch-4-gang
#SMARTvill
- id: "SMARTvill/SLA06"
deviceLabel: "SMARTvill Switch 1"
Expand Down
73 changes: 73 additions & 0 deletions drivers/SmartThings/zigbee-switch/profiles/scene-switch-4-gang.yml
Comment thread
cjswedes marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: scene-switch-4-gang
components:
- id: main
capabilities:
- id: switch
version: 1
- id: button
version: 1
- id: refresh
version: 1
categories:
- name: RemoteController
preferences:
- title: Indicator Light
Comment thread
cjswedes marked this conversation as resolved.
Resolved
name: lightMode
required: false
preferenceType: enumeration
definition:
options:
none: Off
relay: Follow Relay
pos: Position Indicator
default: relay
- title: Global Power-on State
name: relayStatus
required: false
preferenceType: enumeration
definition:
options:
off: Off
on: On
memory: Memory
default: memory
- title: Gang 1 Power-on State
name: relayStatus1
required: false
preferenceType: enumeration
definition:
options:
off: Off
on: On
memory: Memory
default: memory
- title: Gang 2 Power-on State
name: relayStatus2
required: false
preferenceType: enumeration
definition:
options:
off: Off
on: On
memory: Memory
default: memory
- title: Gang 3 Power-on State
name: relayStatus3
required: false
preferenceType: enumeration
definition:
options:
off: Off
on: On
memory: Memory
default: memory
- title: Gang 4 Power-on State
name: relayStatus4
required: false
preferenceType: enumeration
definition:
options:
off: Off
on: On
memory: Memory
default: memory
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: scene-switch-child-scene
components:
- id: main
capabilities:
- id: button
version: 1
categories:
- name: RemoteController
preferences:
- preferenceId: stse.changeToWirelessSwitch
explicit: true
22 changes: 22 additions & 0 deletions drivers/SmartThings/zigbee-switch/profiles/scene-switch-child.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: scene-switch-child
components:
- id: main
capabilities:
- id: switch
version: 1
- id: refresh
version: 1
categories:
- name: Switch
preferences:
- preferenceId: stse.changeToWirelessSwitch
explicit: true
- title: Countdown Seconds
name: countdownSeconds
description: Set the relay countdown in seconds; 0 disables the countdown.
required: false
preferenceType: integer
definition:
minimum: 0
maximum: 43200
default: 0
100 changes: 100 additions & 0 deletions drivers/SmartThings/zigbee-switch/src/test/test_tuya_multi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
-- Licensed under the Apache License, Version 2.0

local test = require "integration_test"
local version = require "version"
local clusters = require "st.zigbee.zcl.clusters"
local BasicCluster = clusters.Basic
local OnOffCluster = clusters.OnOff
local t_utils = require "integration_test.utils"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"
local capabilities = require "st.capabilities"

local profile = t_utils.get_profile_definition("basic-switch.yml")

Expand All @@ -27,16 +29,114 @@ local mock_device = test.mock_device.build_test_zigbee_device({
},
fingerprinted_endpoint_id = 0x01
})
local mock_child = test.mock_device.build_test_child_device({
profile = profile,
parent_device_id = mock_device.id,
parent_assigned_child_key = "02",
label = "Generic Tuya second endpoint",
})

zigbee_test_utils.prepare_zigbee_env_info()

local function test_init()
mock_device:set_field("_configuration_version", 1, {persist = true})
test.mock_device.add_test_device(mock_device)
mock_child:set_field("_configuration_version", 1, {persist = true})
test.mock_device.add_test_device(mock_child)
end

test.set_test_init_function(test_init)

test.register_coroutine_test("Other Tuya switches retain their generic lifecycle handler", function()
local driver = test.driver_wrapper.driver_under_test
local tuya_name = version.api >= 16 and "tuya-multi" or require("tuya-multi").NAME
local dispatchers = driver.lifecycle_dispatcher:find_child_dispatchers(driver, mock_device, "doConfigure")
assert(#dispatchers == 1 and dispatchers[1].name == tuya_name)
assert(#dispatchers[1]:find_child_dispatchers(driver, mock_device, "doConfigure") == 0,
"Generic Tuya devices must not enter the KES606 sub-driver")
assert(not require("tuya-multi.zemismart-kes606.can_handle")({}, driver, mock_device))
end)

test.register_message_test("Other Tuya switches retain standard switch commands and reports", {
{ channel = "capability", direction = "receive", message = {
mock_device.id, { capability = "switch", component = "main", command = "on", args = {} }
} },
{ channel = "zigbee", direction = "send", message = {
mock_device.id, OnOffCluster.server.commands.On(mock_device)
} },
{ channel = "devices", direction = "send", message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "switch", capability_cmd_id = "on" }
} },
{ channel = "zigbee", direction = "receive", message = {
mock_device.id, OnOffCluster.attributes.OnOff:build_test_attr_report(mock_device, true)
} },
{ channel = "capability", direction = "send", message =
mock_device:generate_test_message("main", capabilities.switch.switch.on()) },
{ channel = "devices", direction = "send", message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_device.id, capability_id = "switch", capability_attr_id = "switch" }
} },
})

test.register_coroutine_test("Generic Tuya children configure through the root without the Tuya magic packet", function()
local driver = test.driver_wrapper.driver_under_test
assert(not require("tuya-multi.can_handle")({}, driver, mock_child))
assert(#driver.lifecycle_dispatcher:find_child_dispatchers(driver, mock_child, "doConfigure") == 0)
test.socket.zigbee:__expect_send({ mock_device.id,
OnOffCluster.attributes.OnOff:read(mock_device):to_endpoint(0x02) })
mock_child:expect_metadata_update({ provisioning_state = "PROVISIONED" })
test.socket.device_lifecycle:__queue_receive({ mock_child.id, "doConfigure" })
end)

test.register_coroutine_test("Generic Tuya children retain the root driver-switch decision", function()
local driver = test.driver_wrapper.driver_under_test
assert(#driver.lifecycle_dispatcher:find_child_dispatchers(driver, mock_child, "driverSwitched") == 0)
mock_child:expect_metadata_update({ provisioning_state = "NONFUNCTIONAL" })
test.socket.device_lifecycle:__queue_receive({ mock_child.id, "driverSwitched" })
end)

test.register_coroutine_test("Generic Tuya child commands and reports retain their own endpoint", function()
mock_child:expect_native_cmd_handler_registration("switch", "on")
test.socket.zigbee:__expect_send({ mock_device.id,
OnOffCluster.server.commands.On(mock_device):to_endpoint(0x02) })
test.socket.capability:__queue_receive({ mock_child.id,
{ capability = "switch", component = "main", command = "on", args = {} } })
test.wait_for_events()
mock_device:expect_native_attr_handler_registration("switch", "switch")
test.socket.capability:__expect_send(mock_child:generate_test_message("main", capabilities.switch.switch.on()))
test.socket.zigbee:__queue_receive({ mock_device.id,
OnOffCluster.attributes.OnOff:build_test_attr_report(mock_device, true):from_endpoint(0x02) })
end)

do
local sample = test.mock_device.build_test_zigbee_device({
profile = profile, fingerprinted_endpoint_id = 1,
zigbee_endpoints = {
[1] = { id = 1, manufacturer = "_TZ123fas", server_clusters = { 0x0006 } },
},
})
test.register_coroutine_test("Single-endpoint Tuya device retains root configuration without a magic packet", function()
local driver = test.driver_wrapper.driver_under_test
local actual = driver:get_device_info(sample.id)
assert(not require("tuya-multi.can_handle")({}, driver, actual))
test.socket.zigbee:__set_channel_ordering("relaxed")
test.socket.zigbee:__expect_send({ sample.id, OnOffCluster.attributes.OnOff:read(sample):to_endpoint(1) })
test.socket.zigbee:__expect_send({ sample.id,
OnOffCluster.attributes.OnOff:configure_reporting(sample, 0, 300):to_endpoint(1) })
test.socket.zigbee:__expect_send({ sample.id,
zigbee_test_utils.build_bind_request(sample, zigbee_test_utils.mock_hub_eui,
OnOffCluster.ID, 1):to_endpoint(1) })
sample:expect_metadata_update({ provisioning_state = "PROVISIONED" })
test.socket.device_lifecycle:__queue_receive({ sample.id, "doConfigure" })
end, {
test_init = function()
sample:set_field("_configuration_version", 1, {persist = true})
test.mock_device.add_test_device(sample)
end,
})
end

test.register_coroutine_test(
"lifecycle configure event should configure device",
function ()
Expand Down
Loading
Loading