-
Notifications
You must be signed in to change notification settings - Fork 466
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
fix: Don't emit events for bulbs known offline #931
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,13 +56,19 @@ local function emit_light_status_events(light_device, light) | |
if light.status == "connected" then | ||
light_device.log.info_with({hub_logs=true}, "Light status event, marking device online") | ||
light_device:online() | ||
light_device:set_field(Fields.IS_ONLINE, true) | ||
elseif light.status == "connectivity_issue" then | ||
light_device.log.info_with({hub_logs=true}, "Light status event, marking device offline") | ||
light_device:set_field(Fields.IS_ONLINE, false) | ||
light_device:offline() | ||
return | ||
end | ||
end | ||
|
||
if light_device:get_field(Fields.IS_ONLINE) ~= true then | ||
return | ||
end | ||
|
||
if light.mode then | ||
light_device:emit_event(hueSyncMode.mode(light.mode)) | ||
end | ||
|
@@ -707,7 +713,9 @@ local function do_bridge_network_init(driver, device, bridge_url, api_key) | |
local bridge_api = device:get_field(Fields.BRIDGE_API) | ||
cosock.spawn(function() | ||
local child_device_map = {} | ||
for _, device_record in ipairs(device:get_child_list()) do | ||
local children = device:get_child_list() | ||
device.log.debug(string.format("Scanning connectivity of %s child devices", #children)) | ||
for _, device_record in ipairs(children) do | ||
local hue_device_id = device_record:get_field(Fields.HUE_DEVICE_ID) | ||
if hue_device_id ~= nil then | ||
child_device_map[hue_device_id] = device_record | ||
|
@@ -750,10 +758,12 @@ local function do_bridge_network_init(driver, device, bridge_url, api_key) | |
local child_device = child_device_map[hue_device_id] | ||
if child_device then | ||
if status.status == "connected" then | ||
child_device.log.trace("Marking Online after SSE Reconnect") | ||
child_device.log.info_with({hub_logs=true}, "Marking Online after SSE Reconnect") | ||
child_device:online() | ||
child_device:set_field(Fields.IS_ONLINE, true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This runs every time the SSE stream opens, so will run at driver start |
||
elseif status.status == "connectivity_issue" then | ||
child_device.log.trace("Marking Offline after SSE Reconnect") | ||
child_device.log.info_with({hub_logs=true}, "Marking Offline after SSE Reconnect") | ||
child_device:set_field(Fields.IS_ONLINE, false) | ||
child_device:offline() | ||
end | ||
end | ||
|
@@ -767,6 +777,7 @@ local function do_bridge_network_init(driver, device, bridge_url, api_key) | |
log.error_with({ hub_logs = true }, string.format("Hue Bridge \"%s\" Event Source Error", device.label)) | ||
|
||
for _, device_record in ipairs(device:get_child_list()) do | ||
device_record:set_field(Fields.IS_ONLINE, false) | ||
device_record:offline() | ||
end | ||
|
||
|
@@ -822,6 +833,7 @@ local function do_bridge_network_init(driver, device, bridge_url, api_key) | |
(device.label or device.device_network_id or device.id or "unknown bridge") | ||
) | ||
) | ||
light_device:set_field(Fields.IS_ONLINE, false) | ||
light_device:offline() | ||
end | ||
end | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where the SSE event gets processed.