Skip to content

Add web portal command fallback when the socket cannot be opened - #88

Open
diasalvatore wants to merge 1 commit into
jnimmo:masterfrom
diasalvatore:portal-command-fallback
Open

Add web portal command fallback when the socket cannot be opened#88
diasalvatore wants to merge 1 commit into
jnimmo:masterfrom
diasalvatore:portal-command-fallback

Conversation

@diasalvatore

Copy link
Copy Markdown

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_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. It is created lazily on first use, retries once with a fresh login on session expiry, never raises into the caller, 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, 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.

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
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.

1 participant