Add web portal command fallback when the socket cannot be opened - #88
Open
diasalvatore wants to merge 1 commit into
Open
Add web portal command fallback when the socket cannot be opened#88diasalvatore wants to merge 1 commit into
diasalvatore wants to merge 1 commit into
Conversation
Since 2026-08-15 the cloud command socket (212.92.41.143:5210) has been unreachable while the HTTPS API stayed up, leaving cloud controllers read-only: state polls fine, every SET fails. The accloud.intesis.com web portal kept delivering commands the whole time, over plain HTTPS. IntesisHome._set_value now falls back to the portal flow when _ensure_socket fails: form login (CSRF token from the login page, userId scraped from the post-login panel, which doubles as the login success check), then POST /device/setVal with the same uid/value datapoints the socket protocol uses. The portal session lives in its own aiohttp session so login cookies never touch a caller-supplied shared session, is created lazily on first use, retries once with a fresh login on session expiry, and is closed by stop(). Normal socket operation resumes automatically once the socket can be opened again. Opening the socket is also now capped at SOCKET_CONNECT_TIMEOUT (5s): a filtered port takes a full kernel TCP timeout (~130s) to fail, and every SET paid it before discovering the socket was unusable. Only DEVICE_INTESISHOME has a PORTAL_URL entry for now; the flow is verified against the live portal. The other brands' portals can be added once someone confirms them. Requested in hass-intesishome#68. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyfNsFiyuDhKT5pTiq42oa
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.
Requested in jnimmo/hass-intesishome#68.
Since Aug 15 the cloud command socket has been unreachable while the HTTPS API stays up, leaving cloud controllers read-only: state polls fine, every SET fails. The accloud.intesis.com web portal kept delivering commands the whole time, over plain HTTPS.
What this does
IntesisHome._set_valuenow falls back to the portal flow when_ensure_socketfails: form login (CSRF token from the login page, userId scraped from the post-login panel, which doubles as the login success check), thenPOST /device/setValwith the same uid/value datapoints the socket protocol uses. The portal session lives in its ownaiohttpsession so login cookies never touch a caller-supplied shared session. It is created lazily on first use, retries once with a fresh login on session expiry, never raises into the caller, and is closed bystop(). Normal socket operation resumes automatically once the socket can be opened again.Opening the socket is also now capped at
SOCKET_CONNECT_TIMEOUT(5s). A filtered port takes a full kernel TCP timeout (~130s) to fail, and every SET paid it before discovering the socket was unusable.Only
DEVICE_INTESISHOMEhas aPORTAL_URLentry for now, verified against the live portal. The other brands can be added once someone confirms their portals expose the same flow.Testing
Two new tests (fallback happy path and portal failure returning False instead of raising), full suite passes (96/96), pylint 4.0.5 at 10/10. Running in my HA instance since yesterday: commands go through in about 6 seconds while the socket is down.
Caveat: this scrapes the portal's HTML, so it breaks if HMS reworks the portal. It only ever runs when the socket is unavailable, so the blast radius is limited to an already broken path.