Fix IntesisBox local (WMP) path: CR terminator, tolerant init, ack returns, keepalive and reconnect - #87
Merged
Conversation
…turns, keepalive and reconnect Verified against an INWMPMHI001R000 (MH-RC-WMP-1, WMP v1.3.3) on a Mitsubishi Heavy FDUM71VH ducted unit. Fixes jnimmo#86: - Append the \r terminator the WMP protocol requires to every command; only SET carried one, so ID/LIMITS/GET were never parsed by the device and connecting always failed with a timeout. - Send the LIMITS:* init queries without blocking on a reply: a unit without a feature never answers that feature's LIMITS query (e.g. a ducted unit is silent on LIMITS:VANELR), which used to close the socket mid-init. - Return a bool from _send_command and the IntesisBox set_* methods, matching the cloud classes' contract; they returned None, which consumers such as hass-intesishome treat as an unacknowledged command. - Start the existing _send_keepalive loop from connect(); it was never scheduled, leaving the socket idle and letting it die undetected. - Reconnect with capped exponential backoff after an unexpected socket loss via the _handle_disconnect hook, guarded by a stopped flag so an intentional stop() stays stopped. Adds IntesisBox coverage to the test suite through a fake WMP TCP device, replacing the NotImplementedError placeholder callback.
Owner
|
Thanks very much @i6media |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #86.
This makes the IntesisBox (WMP local protocol) path work end-to-end. All five issues from #86 are addressed, each verified against real hardware: an INWMPMHI001R000 (
MH-RC-WMP-1, WMP firmware v1.3.3) on a Mitsubishi Heavy FDUM71VH ducted unit, driven through hass-intesishome. With this branch the device connects, initialises, polls, accepts commands and survives socket loss.Changes
IntesisBoxnow overrides_send_commandto guarantee the\rthe WMP protocol requires. Previously onlySETcarried one, soID/LIMITS/GETwere never parsed by the device and connecting always ended incannot_connect.LIMITS:*discovery queries are sent withwait_for_response=False. A unit without a feature never answers that feature's LIMITS query (the ducted unit is completely silent onLIMITS:VANELR, noERR), which used to trip the 5s timeout and close the socket mid-init.IntesisBase._send_commandnow returns a bool (written + response frame arrived in time), and the IntesisBoxset_*methods return it, matching the cloud classes' documented contract. They returnedNone, which consumers like hass-intesishome treat as an unacknowledged command — every service call raised after the ONOFF byte had already gone out, aborting the mode/setpoint steps that follow.set_modealso returnsFalsefor a mode the map doesn't know instead of silently doing nothing.connect()now schedules the existing_send_keepaliveloop, which was never created anywhere. Besides keeping the otherwise idle socket alive, its blocking wait doubles as a dead-socket detector (a missed reply closes the writer within ~35s instead of "whenever the user next sends a command").IntesisBoximplements the_handle_disconnecthook with a capped exponential backoff loop (15s → 300s), guarded by a stopped flag so an intentionalstop()stays stopped.Tests
Adds IntesisBox coverage via a fake WMP TCP device (
FakeWMPServerintests/__init__.py, replacing theNotImplementedErrorplaceholder callback), mirroring the real device's behaviour including the silentLIMITS:VANELR. New tests cover: init with an unanswered LIMITS query, the CR-terminated command stream, keepalive task creation, bool returns for acknowledged / unanswered / invalid commands, reconnect after connection loss, and stop() suppressing the reconnect loop.pytest(94 passed) andpylint(10.00/10) both clean.