Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
lisongjun12 authored Sep 14, 2023
2 parents 540d576 + 7049568 commit 2cd05d7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion drivers/SmartThings/philips-hue/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ local function emit_light_status_events(light_device, light)
)
)
else
light_device:emit_event(capabilities.colorControl.hue(adjusted_sat))
light_device:emit_event(capabilities.colorControl.saturation(adjusted_sat))
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion drivers/SmartThings/sonos/src/api/sonos_connection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ end
function SonosConnection:is_running()
local self_running = self:self_running()
local coord_running = self:coordinator_running()
log.debug(string.format("%s all connections running? %s", self.device.label, {coordinator = self_running, mine = self_running}))
log.debug(string.format("%s all connections running? %s", self.device.label, st_utils.stringify_table({coordinator = self_running, mine = self_running})))
return self_running and coord_running
end

Expand Down
20 changes: 14 additions & 6 deletions drivers/SmartThings/sonos/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,17 @@ local function find_player_for_device(driver, device, should_continue)
end

local function update_fields_from_ssdp_scan(driver, device, fields)
local current_player_id = device:get_field(PlayerFields.PLAYER_ID)
local current_url = device:get_field(PlayerFields.WSS_URL)
local current_household_id = device:get_field(PlayerFields.HOUSEHOULD_ID)
local sonos_conn = device:get_field(PlayerFields.CONNECTION) --- @type SonosConnection|nil
device.log.debug("Updating fields from SSDP scan")
local is_initialized = device:get_field(PlayerFields._IS_INIT)

local current_player_id, current_url, current_household_id, sonos_conn

if is_initialized then
current_player_id =device:get_field(PlayerFields.PLAYER_ID)
current_url = device:get_field(PlayerFields.WSS_URL)
current_household_id = device:get_field(PlayerFields.HOUSEHOULD_ID)
sonos_conn = device:get_field(PlayerFields.CONNECTION)
end

local already_connected = sonos_conn ~= nil
local refresh = false
Expand Down Expand Up @@ -170,6 +177,7 @@ local function _initialize_device(driver, device)
driver.datastore.dni_to_device_id[device.device_network_id] = device.id
end
if not device:get_field(PlayerFields._IS_SCANNING) then
device.log.debug("Starting Scan in _initialize_device for %s", device.label)
device:set_field(PlayerFields._IS_SCANNING, true)
cosock.spawn(
function()
Expand All @@ -181,7 +189,7 @@ local function _initialize_device(driver, device)
driver._field_cache[device.device_network_id]

if not is_already_found then
log.debug("Rescanning for player with DNI " .. device.device_network_id)
device.log.debug(string.format("Rescanning for player with DNI %s", device.device_network_id))
device:offline()
local success = false

Expand All @@ -198,7 +206,7 @@ local function _initialize_device(driver, device)
end
end

log.trace("Setting persistent fields")
device.log.trace("Setting persistent fields")
local fields = driver._field_cache[device.device_network_id]
update_fields_from_ssdp_scan(driver, device, fields)

Expand Down

0 comments on commit 2cd05d7

Please sign in to comment.