Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to create HAEntity on getting sensor history #71

Open
Nerkyator opened this issue Dec 17, 2024 · 0 comments
Open

Failing to create HAEntity on getting sensor history #71

Nerkyator opened this issue Dec 17, 2024 · 0 comments

Comments

@Nerkyator
Copy link
Contributor

Nerkyator commented Dec 17, 2024

It appears that HAKit fails to create an HAEntity when processing data from the sensor history REST API. In some array elements returned by Home Assistant, the context key seems to be missing. As a result, the following initializer:

public init(data: HAData) throws {
    let entityId: String = try data.decode("entity_id")

    try self.init(
        entityId: entityId,
        domain: HAEntity.domain(from: entityId),
        state: data.decode("state"),
        lastChanged: data.decode("last_changed"),
        lastUpdated: data.decode("last_updated"),
        attributes: data.decode("attributes"),
        context: data.decode("context")
    )
}

throws an error when attempting to decode the context field.

HAKit version: 0.4.4
Home Assistant version: 2024.12.0

PS: HAKit never encountered this issue with Home Assistant 2024.4.x. I updated Home Assistant to the latest version a few days ago, and the bug appeared. This might be related to changes in how Home Assistant now generates the history array—but that’s just a guess.

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

No branches or pull requests

1 participant