Skip to content

Detect a channel whose own component disappeared on reconnect - #40

Closed
drHouse-gif wants to merge 1 commit into
victronenergy:masterfrom
drHouse-gif:fix/channel-count-change-reinit-v221
Closed

drHouse-gif wants to merge 1 commit into
victronenergy:masterfrom
drHouse-gif:fix/channel-count-change-reinit-v221

Conversation

@drHouse-gif

Copy link
Copy Markdown
Collaborator

_reinit_channel_and_handlers compared only capability names, so a device that comes back with fewer instances of the same component went unnoticed: two switches becoming one leaves the capability set as {switch}, and both the "capability removed" and "capability added" checks see nothing to do.

The orphaned channel therefore kept its dbus service and was refreshed against a component that no longer answers, so Switch.GetStatus for the missing id returned None and the handler's refresh raised
TypeError: 'NoneType' object is not subscriptable.

Also compare the channel's own component ids against the freshly enumerated ones and take the existing "capabilities changed" route when none of them is left. An aggregated channel (several ids on one service) survives as long as one of its ids remains.

As with any capability change this disables every channel of the device and lets discovery re-inventory it, rather than tearing down just the orphan; a more surgical teardown would mean reworking the channel bookkeeping in discovery.py.

Removes the xfail marker on test_channel_count_change_within_reconnect_loop and extends it to check that the device recovers: the remaining component is re-inventoried, can be enabled again and still switches. The test fails on the unpatched driver.

_reinit_channel_and_handlers compared only capability names, so a device that
comes back with fewer instances of the same component went unnoticed: two
switches becoming one leaves the capability set as {switch}, and both the
"capability removed" and "capability added" checks see nothing to do.

The orphaned channel therefore kept its dbus service and was refreshed against a
component that no longer answers, so Switch.GetStatus for the missing id returned
None and the handler's refresh raised
TypeError: 'NoneType' object is not subscriptable.

Also compare the channel's own component ids against the freshly enumerated ones
and take the existing "capabilities changed" route when none of them is left. An
aggregated channel (several ids on one service) survives as long as one of its
ids remains.

As with any capability change this disables every channel of the device and lets
discovery re-inventory it, rather than tearing down just the orphan; a more
surgical teardown would mean reworking the channel bookkeeping in discovery.py.

Removes the xfail marker on test_channel_count_change_within_reconnect_loop and
extends it to check that the device recovers: the remaining component is
re-inventoried, can be enabled again and still switches. The test fails on the
unpatched driver.
@drHouse-gif

Copy link
Copy Markdown
Collaborator Author

Closing as a duplicate. #30 carries the same change and already merges cleanly onto master, so this adds nothing. Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant