Repository navigation
feat: add MQTT notify entity - #29
Conversation
ederjc
left a comment
There was a problem hiding this comment.
Reviewed the new Notify entity against HA's MQTT notify discovery schema and the existing Entity base pattern. cmd_t is always auto-derived via topic_for("command") rather than being overridable by the caller, but that's consistent with how every other entity in this codebase auto-generates its topics, so I don't consider it a bug — just noting it's intentional by design. tests/test_notify.py (13/13). LGTM (note: could not formally "Approve" since GitHub blocks self-approval of your own PR).
e7d3a45 to
e78215a
Compare
e2f5e56 to
6319123
Compare
ederjc
left a comment
There was a problem hiding this comment.
Re-review after rebase onto master (all 6 CI checks now run)
This branch was rebased onto the latest master (includes #36's race-condition fix). Initial run after rebase failed MicroPython unix port — root-caused to tests/test_notify.py using pathlib (unavailable under the real MicroPython unix-port test env), plus self.assertNotIn(...), which MicroPython-lib's unittest port doesn't implement (only assertIn exists). Fixed the imports here and added a reusable assertNotIn shim to tests/test_uhome.py in #37 (merged to master); rebased again on top.
CI results (latest run):
| Check | Result |
|---|---|
| Python 3.11 | ✅ pass |
| Python 3.13 | ✅ pass |
| Ruff lint and format check | ✅ pass |
| Compile MicroPython sources | ✅ pass |
| MicroPython unix port | ✅ pass |
| MQTT integration test | ✅ pass |
All 6 checks green. LGTM — marking copilot-approved.
Replace pathlib.Path/contextlib.redirect_stderr usage in the new entity test file with the same MicroPython-safe patterns already used by tests/test_uhome.py (os.path-based sys.path setup and the local _RedirectStderr helper), since neither pathlib nor contextlib is available under the CI's MicroPython unix-port + mip package set. Also fix a PLC0206 ruff finding (iterate kwargs/attributes via .items() instead of re-indexing the dict) where present. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
6319123 to
2db708d
Compare
Summary
Adds an MQTT
Notifyhelper that lets Home Assistant send notification messages to a MicroPython device.Changes
uhome.Notifywith MQTT notify discovery and a generatedcmd_tcommand topic.set_action()callback handling through_subscribe()so command subscriptions are restored after reconnects.Usage
Testing
python -m unittest discover -s tests -v— OK (13 tests)Notes
This PR is stacked on
fix/connection-robustness(#3). Trivial append-conflicts in uhome.py/README.md with sibling entity PRs are expected.