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

Rolling up Main to Beta #1828

Merged
merged 9 commits into from
Dec 16, 2024
65 changes: 39 additions & 26 deletions drivers/Aqara/aqara-lock/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ local function device_init(self, device)
LockAlarm.supportedAlarmValues(SUPPORTED_ALARM_VALUES, { visibility = { displayed = false } })
)
end
device:emit_event(capabilities.lock.supportedUnlockDirections({"fromInside", "fromOutside"}, {visibility = {displayed = false}}))
device:emit_event(capabilities.battery.type("AA"))
device:emit_event(capabilities.battery.quantity(8))
end

local function device_added(self, device)
Expand Down Expand Up @@ -107,23 +110,33 @@ local function event_lock_handler(driver, device, evt_name, evt_value)
end
end

local function event_unlock_handler(driver, device, evt_name, evt_value)
local id, label
if evt_name == METHOD.RF447 then
evt_name = nil
id = nil
label = nil
elseif evt_name == METHOD.BLUETOOTH and evt_value == 2 then
evt_name = nil
id = nil
label = nil
elseif evt_value == 0x80020000 then -- one-time password
id = "OTP_STANDALONE"
label = nil
else
id, label = credential_utils.find_userLabel(driver, device, evt_value)
end
device:emit_event(Lock.lock.unlocked({ data = { method = evt_name, codeId = id, codeName = label } }))
local function event_unlock_indoor_handler(driver, device, evt_name, evt_value)
device:emit_event(Lock.lock.unlocked({ data = { method = evt_name, codeId = nil, codeName = nil, unlockDirection = "fromInside" } }))
device:emit_event(remoteControlStatus.remoteControlEnabled('false', { visibility = { displayed = false } }))
device:emit_event(LockAlarm.alarm.clear({ visibility = { displayed = false }}))
end

local function event_unlock_outdoor_handler(driver, device, evt_name, evt_value)
local id, label = credential_utils.find_userLabel(driver, device, evt_value)
device:emit_event(Lock.lock.unlocked({ data = { method = evt_name, codeId = id, codeName = label, unlockDirection = "fromOutside" } }))
device:emit_event(remoteControlStatus.remoteControlEnabled('false', { visibility = { displayed = false } }))
device:emit_event(LockAlarm.alarm.clear({ visibility = { displayed = false }}))
end

local function event_unlock_rf447_handler(driver, device, evt_name, evt_value)
device:emit_event(Lock.lock.unlocked({ data = { method = evt_name, codeId = nil, codeName = nil, unlockDirection = nil } }))
device:emit_event(remoteControlStatus.remoteControlEnabled('false', { visibility = { displayed = false } }))
device:emit_event(LockAlarm.alarm.clear({ visibility = { displayed = false }}))
end

local function event_unlock_remote_handler(driver, device, evt_name, evt_value)
device:emit_event(Lock.lock.unlocked({ data = { method = evt_name, codeId = nil, codeName = nil, unlockDirection = nil } }))
device:emit_event(remoteControlStatus.remoteControlEnabled('false', { visibility = { displayed = false } }))
device:emit_event(LockAlarm.alarm.clear({ visibility = { displayed = false }}))
end

local function event_unlock_otp_handler(driver, device, evt_name, evt_value)
device:emit_event(Lock.lock.unlocked({ data = { method = evt_name, codeId = "OTP_STANDALONE", codeName = nil, unlockDirection = "fromOutside" } }))
device:emit_event(remoteControlStatus.remoteControlEnabled('false', { visibility = { displayed = false } }))
device:emit_event(LockAlarm.alarm.clear({ visibility = { displayed = false }}))
end
Expand Down Expand Up @@ -163,16 +176,16 @@ end

local resource_id = {
["13.31.85"] = { event_name = METHOD.LOCKED, event_handler = event_lock_handler },
["13.48.85"] = { event_name = METHOD.MANUAL, event_handler = event_unlock_indoor_handler },
["13.51.85"] = { event_name = METHOD.MANUAL, event_handler = event_unlock_indoor_handler },
["13.42.85"] = { event_name = METHOD.FINGERPRINT, event_handler = event_unlock_outdoor_handler },
["13.43.85"] = { event_name = METHOD.KEYPAD, event_handler = event_unlock_outdoor_handler },
["13.44.85"] = { event_name = METHOD.RFID, event_handler = event_unlock_outdoor_handler },
["13.151.85"] = { event_name = METHOD.RF447, event_handler = event_unlock_rf447_handler },
["13.45.85"] = { event_name = METHOD.BLUETOOTH, event_handler = event_unlock_remote_handler },
["13.90.85"] = { event_name = METHOD.COMMAND, event_handler = event_unlock_remote_handler },
["13.46.85"] = { event_name = METHOD.KEYPAD, event_handler = event_unlock_otp_handler },
["13.17.85"] = { event_name = METHOD.NO_USE, event_handler = event_door_handler },
["13.48.85"] = { event_name = METHOD.MANUAL, event_handler = event_unlock_handler },
["13.51.85"] = { event_name = METHOD.MANUAL, event_handler = event_unlock_handler },
["13.42.85"] = { event_name = METHOD.FINGERPRINT, event_handler = event_unlock_handler },
["13.43.85"] = { event_name = METHOD.KEYPAD, event_handler = event_unlock_handler },
["13.44.85"] = { event_name = METHOD.RFID, event_handler = event_unlock_handler },
["13.151.85"] = { event_name = METHOD.RF447, event_handler = event_unlock_handler },
["13.45.85"] = { event_name = METHOD.BLUETOOTH, event_handler = event_unlock_handler },
["13.90.85"] = { event_name = METHOD.COMMAND, event_handler = event_unlock_handler },
["13.46.85"] = { event_name = METHOD.KEYPAD, event_handler = event_unlock_handler },
["13.56.85"] = { event_name = METHOD.NO_USE, event_handler = event_battery_handler },
["13.32.85"] = { event_name = METHOD.NO_USE, event_handler = event_abnormal_status_handler },
["13.33.85"] = { event_name = METHOD.NO_USE, event_handler = event_anti_lock_handler },
Expand Down
4 changes: 4 additions & 0 deletions drivers/Aqara/aqara-lock/src/test/test_aqara_lock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ local function test_init()
"highTemperature", "attemptsExceeded" }
test.socket.capability:__expect_send(mock_device:generate_test_message("main",
lockAlarm.supportedAlarmValues(SUPPORTED_ALARM_VALUES, { visibility = { displayed = false } })))
test.socket.capability:__expect_send(mock_device:generate_test_message("main",
Lock.supportedUnlockDirections({"fromInside", "fromOutside"}, { visibility = { displayed = false } })))
test.socket.capability:__expect_send(mock_device:generate_test_message("main", Battery.type("AA")))
test.socket.capability:__expect_send(mock_device:generate_test_message("main", Battery.quantity(8)))
test.mock_device.add_test_device(mock_device)
end
test.set_test_init_function(test_init)
Expand Down
11 changes: 11 additions & 0 deletions drivers/SmartThings/matter-sensor/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ matterManufacturer:
vendorId: 0x1021
productId: 0x0001
deviceProfileName: motion-contact-battery
# Neo
- id: "4991/1122"
deviceLabel: Door Sensor
vendorId: 0x137F
productId: 0x0462
deviceProfileName: contact-battery
- id: "4991/1123"
deviceLabel: Motion Sensor
vendorId: 0x137F
productId: 0x0463
deviceProfileName: motion-battery
#Tuo
- id: "5150/3"
deviceLabel: "TUO Temperature Sensor"
Expand Down
11 changes: 11 additions & 0 deletions drivers/SmartThings/matter-switch/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ matterManufacturer:
vendorId: 0x115A
productId: 0x004B
deviceProfileName: light-color-level-2700K-6500K
#Neo
- id: "4991/635"
deviceLabel: Power Plug
vendorId: 0x137F
productId: 0x027B
deviceProfileName: plug-binary
#SONOFF
- id: "SONOFF MINIR4M"
deviceLabel: Smart Plug-in Unit
Expand Down Expand Up @@ -553,6 +559,11 @@ matterManufacturer:
vendorId: 0x147F
productId: 0x0004
deviceProfileName: switch-binary
- id: "5247/2"
deviceLabel: UTEC Smart Matter Light Bulb
vendorId: 0x147F
productId: 0x0002
deviceProfileName: light-color-level-2700K-6500K
#WiZ
- id: "WiZ A19"
deviceLabel: WiZ A19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,6 @@ test.register_message_test(
{ capability = "switch", component = "main", command = "on", args = { } }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_device.id, capability_id = "switch", capability_cmd_id = "on" }
}
},
{
channel = "matter",
direction = "send",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,9 @@ end

local function test_init_water_valve()
test.mock_device.add_test_device(mock_device_water_valve)
test.socket.device_lifecycle:__queue_receive({ mock_device_water_valve.id, "doConfigure" })
mock_device_water_valve:expect_metadata_update({ profile = "water-valve-level" })
mock_device_water_valve:expect_metadata_update({ provisioning_state = "PROVISIONED" })
end

local function test_init_parent_child_different_types()
Expand Down Expand Up @@ -394,6 +396,7 @@ local function test_init_parent_child_unsupported_device_type()
})
end


test.register_coroutine_test(
"Test profile change on init for onoff parent cluster as server",
function()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ test.register_coroutine_test(
function()
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "colorControl", component = "main", command = "setColor", args = { { hue = 50, saturation = 50 } } } })
mock_device:expect_native_cmd_handler_registration("colorControl", "setColor")
test.socket.zigbee:__expect_send(
{
mock_device.id,
Expand Down Expand Up @@ -382,6 +383,7 @@ test.register_coroutine_test(
function()
test.socket.zigbee:__set_channel_ordering("relaxed")
test.socket.capability:__queue_receive({mock_device.id, { capability = "colorTemperature", component = "main", command = "setColorTemperature", args = {1800}}})
mock_device:expect_native_cmd_handler_registration("colorTemperature", "setColorTemperature")
test.socket.zigbee:__expect_send({mock_device.id, ColorControl.server.commands.MoveToColorTemperature(mock_device, 556, 0x0000)})
test.socket.zigbee:__expect_send({mock_device.id, OnOff.server.commands.On(mock_device)})
test.wait_for_events()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ test.register_coroutine_test(
test.socket.capability:__queue_receive({ mock_device.id,
{ capability = "colorTemperature", component = "main", command = "setColorTemperature", args = { 200 } } })

mock_device:expect_native_cmd_handler_registration("colorTemperature", "setColorTemperature")
local temp_in_mired = math.floor(1000000 / 200)
test.socket.zigbee:__expect_send(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ test.register_coroutine_test(
test.socket.capability:__queue_receive({ mock_device.id,
{ capability = "colorTemperature", component = "main", command = "setColorTemperature", args = { 200 } } })

mock_device:expect_native_cmd_handler_registration("colorTemperature", "setColorTemperature")
local temp_in_mired = math.floor(1000000 / 200)
test.socket.zigbee:__expect_send(
{
Expand Down
3 changes: 3 additions & 0 deletions drivers/SmartThings/zigbee-switch/src/test/test_rgb_bulb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ test.register_coroutine_test(
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "colorControl", component = "main", command = "setHue", args = { 50 } } })

mock_device:expect_native_cmd_handler_registration("colorControl", "setHue")
test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device) })

local hue = math.floor((50 * 0xFE) / 100.0 + 0.5)
Expand All @@ -154,6 +155,7 @@ test.register_coroutine_test(
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "colorControl", component = "main", command = "setSaturation", args = { 50 } } })

mock_device:expect_native_cmd_handler_registration("colorControl", "setSaturation")
test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device) })

local saturation = math.floor((50 * 0xFE) / 100.0 + 0.5)
Expand All @@ -176,6 +178,7 @@ test.register_coroutine_test(
function()
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "colorControl", component = "main", command = "setColor", args = { { hue = 50, saturation = 50 } } } })
mock_device:expect_native_cmd_handler_registration("colorControl", "setColor")
test.socket.zigbee:__expect_send(
{
mock_device.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ test.register_coroutine_test(
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "colorControl", component = "main", command = "setHue", args = { 50 } } })

mock_device:expect_native_cmd_handler_registration("colorControl", "setHue")
test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device) })

local hue = math.floor((50 * 0xFE) / 100.0 + 0.5)
Expand All @@ -185,6 +186,7 @@ test.register_coroutine_test(
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "colorControl", component = "main", command = "setSaturation", args = { 50 } } })

mock_device:expect_native_cmd_handler_registration("colorControl", "setSaturation")
test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device) })

local saturation = math.floor((50 * 0xFE) / 100.0 + 0.5)
Expand All @@ -208,6 +210,7 @@ test.register_coroutine_test(
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "colorControl", component = "main", command = "setColor", args = { { hue = 50, saturation = 50 } } } })

mock_device:expect_native_cmd_handler_registration("colorControl", "setColor")
test.socket.zigbee:__expect_send({ mock_device.id, OnOff.server.commands.On(mock_device) })

local hue = math.floor((50 * 0xFE) / 100.0 + 0.5)
Expand All @@ -228,7 +231,7 @@ test.register_coroutine_test(
)

test.register_coroutine_test(
"Set Saturation command test",
"Set ColorTemperature command test",
function()
test.timer.__create_and_queue_test_time_advance_timer(1, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "colorTemperature", component = "main", command = "setColorTemperature", args = { 200 } } })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ test.register_coroutine_test(
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "colorControl", component = "main", command = "setHue", args = { 50 } } })

mock_device:expect_native_cmd_handler_registration("colorControl", "setHue")
test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device) })

local hue = math.floor((50 * 0xFE) / 100.0 + 0.5)
Expand All @@ -221,6 +222,7 @@ test.register_coroutine_test(
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "colorControl", component = "main", command = "setSaturation", args = { 50 } } })

mock_device:expect_native_cmd_handler_registration("colorControl", "setSaturation")
test.socket.zigbee:__expect_send({ mock_device.id, OnOff.commands.On(mock_device) })

local saturation = math.floor((50 * 0xFE) / 100.0 + 0.5)
Expand All @@ -245,6 +247,7 @@ test.register_coroutine_test(
test.timer.__create_and_queue_test_time_advance_timer(2, "oneshot")
test.socket.capability:__queue_receive({mock_device.id, { capability = "colorControl", component = "main", command = "setColor", args = { { hue = 50, saturation = 50 } } } })

mock_device:expect_native_cmd_handler_registration("colorControl", "setColor")
test.socket.zigbee:__expect_send({ mock_device.id, OnOff.server.commands.On(mock_device) })

local hue = math.floor((50 * 0xFE) / 100.0 + 0.5)
Expand Down
1 change: 1 addition & 0 deletions drivers/SmartThings/zigbee-thermostat/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ local zigbee_thermostat_driver = {
require("resideo_korea"),
require("aqara")
},
health_check = false,
}

defaults.register_for_default_handlers(zigbee_thermostat_driver, zigbee_thermostat_driver.supported_capabilities)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ test.register_coroutine_test(
mock_parent.id,
{ capability = "switch", component = "main", command = "on", args = {} }
})
mock_parent:expect_native_cmd_handler_registration("switch", "on")

test.socket.zwave:__expect_send(
zw_test_utils.zwave_test_build_send_command(
Expand Down Expand Up @@ -505,7 +504,6 @@ test.register_coroutine_test(
mock_parent.id,
{ capability = "switch", component = "main", command = "off", args = {} }
})
mock_parent:expect_native_cmd_handler_registration("switch", "off")

test.socket.zwave:__expect_send(
zw_test_utils.zwave_test_build_send_command(
Expand Down Expand Up @@ -572,7 +570,6 @@ test.register_coroutine_test(
mock_child.id,
{ capability = "switch", component = "main", command = "on", args = {} }
})
mock_child:expect_native_cmd_handler_registration("switch", "on")

test.socket.zwave:__expect_send(
zw_test_utils.zwave_test_build_send_command(
Expand Down Expand Up @@ -637,7 +634,6 @@ test.register_coroutine_test(
mock_child.id,
{ capability = "switch", component = "main", command = "off", args = {} }
})
mock_child:expect_native_cmd_handler_registration("switch", "off")

test.socket.zwave:__expect_send(
zw_test_utils.zwave_test_build_send_command(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,6 @@ test.register_message_test(
{ capability = "switch", command = "on", component = "switch1", args = {} }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_parent.id, capability_id = "switch", capability_cmd_id = "on" }
}
},
{
channel = "zwave",
direction = "send",
Expand All @@ -223,14 +215,6 @@ test.register_message_test(
{ capability = "switch", command = "off", component = "main", args = {} }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_parent.id, capability_id = "switch", capability_cmd_id = "off" }
}
},
{
channel = "zwave",
direction = "send",
Expand All @@ -256,14 +240,6 @@ test.register_message_test(
{ capability = "switch", command = "on", component = "switch1", args = {} }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_child.id, capability_id = "switch", capability_cmd_id = "on" }
}
},
{
channel = "zwave",
direction = "send",
Expand All @@ -288,14 +264,6 @@ test.register_message_test(
{ capability = "switch", command = "off", component = "main", args = {} }
}
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_cmd_handler",
{ device_uuid = mock_child.id, capability_id = "switch", capability_cmd_id = "off" }
}
},
{
channel = "zwave",
direction = "send",
Expand Down
Loading