Skip to content

Show online dashboard options for devices on non-Wi-Fi interfaces#723

Draft
kbx81 wants to merge 2 commits into
mainfrom
network-state-dashboard
Draft

Show online dashboard options for devices on non-Wi-Fi interfaces#723
kbx81 wants to merge 2 commits into
mainfrom
network-state-dashboard

Conversation

@kbx81

@kbx81 kbx81 commented Jul 18, 2026

Copy link
Copy Markdown
Member

What

First feature step of splitting up #721, starting where discussion there suggested: query network state and adjust the main menu when the device is online via another interface.

  • While the dashboard is shown, poll the device's network state (Improv 0x07, improv-wifi-serial-sdk 2.8.0+) every 2.5s with a small (500ms) per-request timeout, so opening the dialog is never delayed and the menu converges when the device comes online (e.g. an Ethernet cable is plugged in). Polling starts/stops from updated() based on the current page, mirroring _syncScanning, and the interval is cleared on dialog close.
  • Visit Device now also shows for a device that reports a URL in its network state (online via Ethernet) rather than only via nextUrl (Wi-Fi provisioning), and Add to Home Assistant shows whenever the device is online, not only when Wi-Fi is PROVISIONED.
  • Devices that don't implement the command answer UNKNOWN_RPC_COMMAND; polling stops for them and everything behaves as before. A failed poll keeps the last-known state and restores the client's previous error so it can't surface as a spurious device error elsewhere.

No changes to the Wi-Fi menu item or the provisioning flow yet — those follow in later PRs.

Dependencies

Based on #722 (improv-wifi-serial-sdk 2.8.1 bump); will retarget to main once that merges.

Testing

  • npm ci && script/build && prettier --check src pass.
  • Hardware pass still to do (legacy Wi-Fi device, Wi-Fi-only device, dual Wi-Fi+Ethernet) before marking ready for review.

Base automatically changed from install-dialog-fixes to main July 18, 2026 06:10
… interfaces

Poll the Improv network state command (0x07) while the dashboard is shown so
Visit Device and Add to Home Assistant appear for a device that is online via
a non-Wi-Fi interface (e.g. Ethernet), and the menu converges when a link
comes up. Devices that don't support the command keep the existing behavior.
@kbx81
kbx81 force-pushed the network-state-dashboard branch from 9fa229e to a71008d Compare July 18, 2026 06:33
Comment thread src/install-dialog.ts Outdated
this.logger.debug(`Failed to fetch network state: ${err}`);
// Keep the last-known state; a failed poll must not leave its error
// behind on the client (the provision form renders `client.error`).
client.error = error;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird. Nothing should use the error at this point anyway. And we should clear it before going into provisioning

Comment thread src/install-dialog.ts Outdated
} catch (err) {
if (client.error === ImprovSerialErrorState.UNKNOWN_RPC_COMMAND) {
// The device predates the command; stop asking.
this._networkState = null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will the poll interval be cleared ? Should that be here? I think it would make sense to just inline this method tied to the polling method, so you can have that side effect here

Comment thread src/install-dialog.ts Outdated
// Poll network state while (and only while) the dashboard is shown, so the
// menu converges when the device comes online (e.g. Ethernet link up).
// Driven from `updated()`, like `_syncScanning`.
private _syncNetworkStatePolling() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not just sync, it's setup right. Sync feels like a one time thing.

Comment thread src/install-dialog.ts Outdated

private async _handleClose() {
clearInterval(this._networkStatePollInterval);
this._networkStatePollInterval = undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're closing and throwing away this object. This is not needed

Comment thread src/install-dialog.ts

const client = new ImprovSerial(this.port!, this.logger);
// Don't carry network state over from a previous client (e.g. pre-install).
this._networkState = undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This made me realize that how the SDK works today is weird. We store wifi provisioning state and error on client but not network state.

Even the polling could better live there too? (Opt-in enabled)

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.

2 participants