Skip to content

Simplified Device Attributes Update Event#206

Merged
ccrisan merged 5 commits into
mainfrom
feature/simplified-device-attrs-update
May 18, 2026
Merged

Simplified Device Attributes Update Event#206
ccrisan merged 5 commits into
mainfrom
feature/simplified-device-attrs-update

Conversation

@ccrisan
Copy link
Copy Markdown
Contributor

@ccrisan ccrisan commented May 18, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the device attribute update mechanism away from a frontend polling loop and a backend network-config watcher toward a single periodic backend "heartbeat" that emits device-update events. The frontend code path that periodically polled the main/slave device via HTTP and emitted synthetic device-polling-update / slave-device-polling-update events is removed entirely, along with its UI plumbing. On the backend, _attrs_watch_loop (which only fired when WiFi/IP config changed) is replaced with _attrs_update_loop, which invalidates the attr cache and fires device_events.trigger_update() every ATTRS_UPDATE_INTERVAL (5s) unconditionally.

Changes:

  • Backend: replace conditional network-attr watch loop with unconditional periodic device-update event emission.
  • Frontend: remove polledDeviceName cache state, the pollDevice timer, and the device-polling-update / slave-device-polling-update event handlers across cache.js, settings/devices sections and forms, and reboot-device-mixin.js.
  • Tests: add an integration test asserting the new update loop triggers device_events.trigger_update repeatedly.

Reviewed changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
qtoggleserver/core/device/attrs.py Replaces network-attr watch loop with a periodic loop that always invalidates attrs and triggers device-update.
qtoggleserver/frontend/js/cache.js Removes polled-device state, pollDevice/setInterval, and the polling-update event cases.
qtoggleserver/frontend/js/settings/settings-section.js Drops handler for the now-defunct device-polling-update event.
qtoggleserver/frontend/js/settings/settings-form.js Removes onBecomeCurrent/onLeaveCurrent polling toggles.
qtoggleserver/frontend/js/devices/devices-section.js Drops handler for slave-device-polling-update.
qtoggleserver/frontend/js/devices/device-form.js Removes setPolledDeviceName calls; leaves empty lifecycle overrides.
qtoggleserver/frontend/js/common/reboot-device-mixin.js Removes save/restore of polled device name around reboot flow.
tests/integration/core/device/test_attrs.py New integration test verifying the periodic update loop fires trigger_update.
tests/integration/core/device/init.py, tests/integration/core/init.py New empty package markers for the integration test path.
Comments suppressed due to low confidence (2)

qtoggleserver/frontend/js/devices/device-form.js:138

  • onLeaveCurrent() is now an empty method that only calls super implicitly (it doesn't even do that). If there's no behaviour to add, remove the override entirely so the parent class implementation is used; otherwise this dead override will mask any future base-class behaviour silently.
            throw new AssertionError(`Device with name ${this.getDeviceName()} not found in cache`)
        }

qtoggleserver/frontend/js/devices/device-form.js:135

  • After removing the body of onBecomeCurrent, the method body in device-form.js now ends with a stray empty if (this._deviceRemoved) { return } guard that no longer protects any code. If nothing else is being added here, consider removing the now-empty onBecomeCurrent override entirely (matching the suggestion below for onLeaveCurrent).

This issue also appears on line 137 of the same file.

     * Update the entire form (fields & values) from the corresponding device.
     */
    updateUI(fieldChangeWarnings = true) {
        let device = Cache.getSlaveDevice(this.getDeviceName())

Comment thread qtoggleserver/core/device/attrs.py
Comment thread qtoggleserver/core/device/attrs.py Outdated
Comment thread qtoggleserver/frontend/js/cache.js Outdated
@ccrisan ccrisan merged commit c5f435b into main May 18, 2026
3 checks passed
@ccrisan ccrisan deleted the feature/simplified-device-attrs-update branch May 18, 2026 21:43
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