Repository navigation
fix(homeassistant): explain why an entity read failed - #58
Merged
Merged
Conversation
"cannot read entity" covered a rejected token, a missing helper, a server error and an unreachable host, so it named the symptom without narrowing the cause. The read now reports which one occurred: 401 and 403 point at the long-lived token, 404 says the entity does not exist and suggests creating the input_text helper, other statuses are reported verbatim, and transport errors include the URL and the underlying message. Failures when clearing the entity are reported too. Previously a failed clear was silent, which would leave a stale value that looks like a reply to the next request.
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.
Problem
With the token now resolving, the work laptop reaches Home Assistant but reports:
That one message covers four unrelated causes — rejected token, missing helper, server error, unreachable host — so it names the symptom without narrowing the cause. Same shortcoming as the earlier "config unavailable".
Changes
fetchHaEntityreturns the reason instead of collapsing everything toundefined:HTTP 401, the long-lived token was rejected by Home AssistantHTTP 404, entity input_text.… does not exist (create the input_text helper in Home Assistant)HTTP 500request to https://ha…/api failed (Unable to connect…)setHaEntitynow reports failures too. A failed clear was previously silent, leaving a stale value that the next request could mistake for a reply.Verification
Real opencode process against a mock HA returning 401:
All five read failures produce distinct messages (unit harness), and the healthy path still ends in
reply accepted (HTTP 200). Existing receiver, negative-path, config and lifecycle suites still pass.mise run typecheck,lint,buildall pass.Likely cause on the work laptop
The token resolves but Home Assistant rejects or cannot find the entity. Once this ships, the log will say which. The two candidates are a long-lived token that is expired or from a different HA instance, or a missing
input_text.opencode_permission_responsehelper.