Skip to content

List an unsupported device found by IP in the dbus inventory - #35

Open
drHouse-gif wants to merge 1 commit into
victronenergy:masterfrom
drHouse-gif:fix/unsupported-device-not-listed
Open

drHouse-gif wants to merge 1 commit into
victronenergy:masterfrom
drHouse-gif:fix/unsupported-device-not-listed

Conversation

@drHouse-gif

Copy link
Copy Markdown
Collaborator

One commit on master (d8cb65d, v2.21). discovery.py +6, mock/mock_shelly_server.py +16/-2, one new test file.

The problem

When a probe finds a reachable device that exposes no component the driver handles, the
UNSUPPORTED branch stores its details with an explicit comment saying why:

ep_state.deviceInfo = result.info  # Store device info so we can list the unsupported device details

Those details then never reach dbus. The inventory is keyed by serial, and promote_serial is
set only on the REACHABLE path, so an endpoint entered as a bare IP still has serial = None
when the probe comes back UNSUPPORTED. There is no key to register it under, _add_device is
never reached, and the device is not listed at all - even though its mac is sitting right there
in result.info.

Devices discovered over mDNS are unaffected: the serial is parsed from the hostname, so they
are already promoted and do get listed with /Supported = 0.

The visible effect is that a user who types in the IP of a device the driver cannot use gets
nothing back - no entry, no model, no indication the address was even reached. On a GX the
reason is not in the log either: v2.21 moved "Failed to get device info" from logger.error
to logger.debug.

The change

Six lines. Promote on the UNSUPPORTED path too, which is all it takes for the details stored
immediately above to reach dbus as /Devices/<serial>/... with /Supported = 0:

if ep_state.endpoint.serial is None and result.info is not None:
    promote_serial = True

Nothing else changes: stop_connect() still ends the retries, supported is still set False.

Tests

tests/test_probe_status.py, 7 tests, pinning the outcomes a mock can produce so a later
change cannot silently reclassify a device:

  • a reachable device is listed and supported
  • an unsupported one is listed, with /Supported = 0, and keeps its model
  • an unreachable one gets /Reachable = 0 and recovers
  • a merely slow device is not reclassified as unsupported, which matters because
    UNSUPPORTED stops the retries for good
  • the transitions both ways via /Refresh
  • a device reporting no usable mac is never registered under a placeholder key - this one
    guards the change itself, since promoting on the UNSUPPORTED path means the promotion now
    runs for a device the driver could not use
With the change Change reverted
tests/test_probe_status.py 7 passed 3 failed, 4 passed

The three that fail are the unsupported-device test and the two transition tests that depend on
the device being listed at all.

The mock gains --extra-components, to emulate a device that answers RPC but exposes only
components the driver has no handler for, and --break-mac for the no-identity case. Neither
was expressible before.

Full suite: 82 passed, 4 xfailed, 1 failed on aioshelly 12.0.0, against a pristine v2.21
baseline of 75 passed, 4 xfailed, 1 failed. The one failure,
test_timeouts.py::test_freeze_longer_than_reconnect_loop, is pre-existing: it fails on
unmodified v2.21 with aioshelly 12.0.0, the version the Venus OS recipe pins and a GX actually
runs, and it passes on 14.1.0, which CI installs unpinned.

Interaction with the other proposed change

#34 adds a neighbouring branch to the same if/elif chain. discovery.py merges cleanly
between the two. They overlap by one line in
mock/mock_shelly_server.py, where both add a constructor argument at the end of the same
parameter list; keep both lines. Neither change depends on the other.

A probe that finds a reachable device with no component the driver handles returns
ProbeStatus.UNSUPPORTED, and the handler stores the device info with the comment
"so we can list the unsupported device details". The device is then never listed.

The inventory is keyed by serial, and promote_serial is only set on the REACHABLE
path. An endpoint added as a bare IP still has serial None when the probe comes
back UNSUPPORTED, so there is no key to register it under and _add_device is
never reached, even though the mac is right there in result.info.

Set promote_serial on the UNSUPPORTED path too, which is all it takes for the
stored details to reach dbus as /Devices/<serial>/... with /Supported = 0.

Devices discovered over mDNS already have a serial parsed from the hostname and
were unaffected.

tests/test_probe_status.py pins the classification outcomes that are reachable
from the outside: a reachable device is listed and supported; an unsupported one
is listed with /Supported = 0 and keeps its model; an unreachable one gets
/Reachable = 0 and recovers; a frozen device is not reclassified as unsupported,
which matters because UNSUPPORTED stops the retries for good; the transitions
both ways via /Refresh; and that a device without a usable mac is never
registered as /Devices/unknown.

The mock gains --extra-components, to emulate a device that answers RPC but
exposes only components the driver has no handler for, and --break-mac for the
no-identity case. Neither was expressible before.
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