Skip to content

Commit

Permalink
Merge branch 'main' into add-batterLevel-to-matter-drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
nickolas-deboom authored Dec 10, 2024
2 parents b058cde + 1b84fa9 commit afbeba3
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 39 deletions.
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
5 changes: 5 additions & 0 deletions drivers/SmartThings/matter-switch/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,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
18 changes: 18 additions & 0 deletions drivers/SmartThings/matter-switch/profiles/plug-button.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: plug-button
components:
- id: main
capabilities:
- id: switch
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
categories:
- name: SmartPlug
- id: button
capabilities:
- id: button
version: 1
categories:
- name: RemoteController
3 changes: 3 additions & 0 deletions drivers/SmartThings/matter-thermostat/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@ end

local function temp_event_handler(attribute)
return function(driver, device, ib, response)
if ib.data.value == nil then
return
end
local unit = "C"

-- Only emit the capability for RPC version >= 5, since unit conversion for
Expand Down
4 changes: 2 additions & 2 deletions drivers/SmartThings/zigbee-lock/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,11 @@ local lock_state_handler = function(driver, device, value, zb_rx)
local delay = device:get_field(DELAY_LOCK_EVENT) or 100
if (delay < MAX_DELAY) then
device.thread:call_with_delay(delay+.5, function ()
device:emit_event_for_endpoint(zb_rx.address_header.src_endpoint.value, LOCK_STATE[value.value])
device:emit_event_for_endpoint(zb_rx.address_header.src_endpoint.value, LOCK_STATE[value.value] or attr.unknown())
end)
else
device:set_field(DELAY_LOCK_EVENT, socket.gettime())
device:emit_event_for_endpoint(zb_rx.address_header.src_endpoint.value, LOCK_STATE[value.value])
device:emit_event_for_endpoint(zb_rx.address_header.src_endpoint.value, LOCK_STATE[value.value] or attr.unknown())
end
end

Expand Down
2 changes: 1 addition & 1 deletion drivers/SmartThings/zigbee-switch/src/preferences.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ preferences.update_preferences = function(driver, device, args)
local prefs = preferences.get_device_parameters(device)
if prefs ~= nil then
for id, value in pairs(device.preferences) do
if not (args and args.old_st_store) or (args.old_st_store.preferences[id] ~= value and prefs and prefs[id]) then
if not (args and args.old_st_store and args.old_st_store.preferences) or (args.old_st_store.preferences[id] ~= value and prefs and prefs[id]) then
local message = prefs[id](device, value)
device:send(message)
end
Expand Down
2 changes: 1 addition & 1 deletion drivers/SmartThings/zwave-sensor/src/preferences.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ preferences.update_preferences = function(driver, device, args)
local prefs = preferences.get_device_parameters(device)
if prefs ~= nil then
for id, value in pairs(device.preferences) do
if not (args and args.old_st_store) or (args.old_st_store.preferences[id] ~= value and prefs and prefs[id]) then
if not (args and args.old_st_store and args.old_st_store.preferences) or (args.old_st_store.preferences[id] ~= value and prefs and prefs[id]) then
local new_parameter_value = preferences.to_numeric_value(device.preferences[id])
device:send(Configuration:Set({parameter_number = prefs[id].parameter_number, size = prefs[id].size, configuration_value = new_parameter_value}))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ local fibaro_smoke_sensor = {
},
NAME = "fibaro smoke sensor",
can_handle = can_handle_fibaro_smoke_sensor,
health_check = false,
}

return fibaro_smoke_sensor
2 changes: 1 addition & 1 deletion drivers/SmartThings/zwave-smoke-alarm/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ local preferencesMap = require "preferences"
local function update_preferences(self, device, args)
local preferences = preferencesMap.get_device_parameters(device)
for id, value in pairs(device.preferences) do
if not (args and args.old_st_store) or (args.old_st_store.preferences[id] ~= value and preferences and preferences[id]) then
if not (args and args.old_st_store and args.old_st_store.preferences) or (args.old_st_store.preferences[id] ~= value and preferences and preferences[id]) then
local new_parameter_value = preferencesMap.to_numeric_value(device.preferences[id])
device:send(Configuration:Set({parameter_number = preferences[id].parameter_number, size = preferences[id].size, configuration_value = new_parameter_value}))
end
Expand Down
13 changes: 7 additions & 6 deletions tools/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@
with open(localization_file) as csvfile:
reader = csv.reader(csvfile)
for row in reader:
print("en: "+row[0]+" "+LOCALE+": "+row[1])
subprocess.run(
"find . -name 'fingerprints.yml' | xargs sed -i -E 's/deviceLabel ?: \"?"+row[0].translate(slash_escape)+"\"?/deviceLabel: "+row[1].translate(slash_escape)+"/g'",
shell=True,
cwd=os.path.dirname(current_path)
)
if len(row) > 1:
print("en: "+row[0]+" "+LOCALE+": "+row[1])
subprocess.run(
"find . -name 'fingerprints.yml' | xargs sed -i -E 's/deviceLabel ?: \"?"+row[0].translate(slash_escape)+"\"?/deviceLabel: "+row[1].translate(slash_escape)+"/g'",
shell=True,
cwd=os.path.dirname(current_path)
)

subprocess.run("git status", shell=True)

Expand Down
3 changes: 1 addition & 2 deletions tools/localizations/cn.csv
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,4 @@ Aqara Wireless Mini Switch T1,Aqara 无线开关 T1
"WallHero Outlet",智能墙面五孔插座
"WallHero Remote Control (4-Inch)",语音场景(4寸)面板
"Zemismart ZM02 Smart Curtain",Zemismart ZM02 智能窗帘
"Zemismart ZM25C Smart Curtain",Zemismart ZM25C 智能窗帘

"Zemismart ZM25C Smart Curtain",Zemismart ZM25C 智能窗帘

0 comments on commit afbeba3

Please sign in to comment.