Skip to content

Commit

Permalink
Replaced USN to MAC for Wemo Device Identifier (#433)
Browse files Browse the repository at this point in the history
* Replaced USN to MAC for Wemo Device Identifier

* [reverted to original ltn12 file]
  • Loading branch information
satyajitanand authored Dec 20, 2022
1 parent c9f35bb commit bf8a759
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions drivers/SmartThings/wemo/src/discovery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ local function fetch_device_metadata(url)

return {
name = tablefind(parsed_xml, "root.device.friendlyName"),
model = tablefind(parsed_xml, "root.device.modelName")
model = tablefind(parsed_xml, "root.device.modelName"),
mac = tablefind(parsed_xml, "root.device.macAddress")
}
end

Expand Down Expand Up @@ -103,7 +104,12 @@ local function find(deviceid, callback)
if val then
local headers = process_response(val)
local ip, port = headers["location"]:match("http://([^,/]+):([^/]+)")
local id = headers["usn"]
-- local id = headers["usn"] --instead of usn, we need to use mac as id (to handle migration scenario)
local meta = fetch_device_metadata(headers["location"])
if not meta then
meta = {}
end
local id = meta.mac

log.trace("discovery response from:", rip, headers["usn"])

Expand All @@ -114,11 +120,11 @@ local function find(deviceid, callback)
ids_found[id] = true
number_found = number_found + 1

local meta = fetch_device_metadata(headers["location"])
-- local meta = fetch_device_metadata(headers["location"])

if not meta then
meta = {}
end
-- if not meta then
-- meta = {}
-- end

-- the ID in the response is a substring of the search ID, check if they match (if search ID set)
local is_correct_responder = deviceid and string.find(deviceid, id, nil, "plaintext")
Expand Down

0 comments on commit bf8a759

Please sign in to comment.