Skip to content

Commit 4bce0f3

Browse files
authored
Merge pull request #2533 from SmartThingsCommunity/fix/hue-multi-button-inconsistencies
2 parents a4e2a02 + 3fc413e commit 4bce0f3

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

drivers/SmartThings/philips-hue/src/handlers/lifecycle_handlers/button.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,25 @@ function ButtonLifecycleHandlers.init(driver, device)
119119
if not hue_id_to_device[device_button_resource_id] then
120120
hue_id_to_device[device_button_resource_id] = device
121121
end
122+
123+
local maybe_idx_map = device:get_field(Fields.BUTTON_INDEX_MAP)
124+
local svc_rids_for_device = driver.services_for_device_rid[hue_device_id] or {}
125+
126+
if not svc_rids_for_device[device_button_resource_id] then
127+
svc_rids_for_device[device_button_resource_id] = HueDeviceTypes.BUTTON
128+
end
129+
130+
for resource_id, _ in pairs(maybe_idx_map or {}) do
131+
if not hue_id_to_device[resource_id] then
132+
hue_id_to_device[resource_id] = device
133+
end
134+
135+
if not svc_rids_for_device[resource_id] then
136+
svc_rids_for_device[resource_id] = HueDeviceTypes.BUTTON
137+
end
138+
end
139+
driver.services_for_device_rid[hue_device_id] = svc_rids_for_device
140+
122141
local button_info, err
123142
button_info = Discovery.device_state_disco_cache[device_button_resource_id]
124143
if not button_info then

drivers/SmartThings/philips-hue/src/hue/api.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function PhilipsHueApi.new_bridge_manager(base_url, api_key, socket_builder)
132132
true
133133
))
134134
local control_tx, control_rx = channel.new()
135-
control_rx:settimeout(30)
135+
control_rx:settimeout(45)
136136
local self = setmetatable(
137137
{
138138
headers = { [APPLICATION_KEY_HEADER] = api_key or "" },
@@ -217,7 +217,7 @@ end
217217
---@return ...
218218
local function do_get(instance, path)
219219
local reply_tx, reply_rx = channel.new()
220-
reply_rx:settimeout(10)
220+
reply_rx:settimeout(45)
221221
local msg = ControlMessageBuilders.Get(path, reply_tx);
222222
try_send(instance, msg)
223223
local recv, err = reply_rx:receive()
@@ -236,7 +236,7 @@ end
236236
---@return ...
237237
local function do_put(instance, path, payload)
238238
local reply_tx, reply_rx = channel.new()
239-
reply_rx:settimeout(10)
239+
reply_rx:settimeout(45)
240240
local msg = ControlMessageBuilders.Put(path, payload, reply_tx);
241241
try_send(instance, msg)
242242
local recv, err = reply_rx:receive()
@@ -255,7 +255,7 @@ end
255255
---@return ...
256256
function PhilipsHueApi.get_bridge_info(bridge_ip, socket_builder)
257257
local tx, rx = channel.new()
258-
rx:settimeout(10)
258+
rx:settimeout(45)
259259
cosock.spawn(
260260
function()
261261
tx:send(table.pack(process_rest_response(RestClient.one_shot_get("https://" .. bridge_ip .. "/api/config", nil,
@@ -278,7 +278,7 @@ end
278278
---@return ...
279279
function PhilipsHueApi.request_api_key(bridge_ip, socket_builder)
280280
local tx, rx = channel.new()
281-
rx:settimeout(10)
281+
rx:settimeout(45)
282282
cosock.spawn(
283283
function()
284284
local body = json.encode { devicetype = "smartthings_edge_driver#" .. bridge_ip, generateclientkey = true }

drivers/SmartThings/philips-hue/src/utils/grouped_utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ function grouped_utils.queue_group_scan(driver, bridge_device)
287287
if queue == nil then
288288
local tx, rx = cosock.channel.new()
289289
-- Set timeout to 30 seconds to allow for other queued scans to come in.
290-
rx:settimeout(30)
290+
rx:settimeout(45)
291291
cosock.spawn(function()
292292
while true do
293293
-- The goal here is to timeout on the receive. If we receive a message then another request

0 commit comments

Comments
 (0)