Skip to content

Method Entity.exists doesn't work under an async method #2539

@jrhillery

Description

@jrhillery

What happened?

Entity.exists() seems to always return True when called under an async def method. It would be great if it worked either (async or synchronous) way like ADAPI.entity_exists does.

Version

App version: 0.18.1

Installation type

Home Assistant add-on

Relevant log output

2026-02-16 14:31:16.360340 ERROR Error:     AssertionError: Thinks it exists: entity delete_me_1f8b8f1a-431f-4d19-b732-cc88b5bd377a

Relevant code in the app or config file that caused the issue

# test code created to show Entity.exists doesn't work under an async method
import uuid

from appdaemon import Hass

class ExistsDefect(Hass):

    async def initialize(self) -> None:
        entity_id = f"delete_me_{uuid.uuid4()}"
        new_entity = self.get_entity(entity_id, check_existence=False)

        assert await self.entity_exists(entity_id) is False, f"self.entity_exists says entity {entity_id} exists"
        assert new_entity.exists() is False, f"Thinks it exists: entity {entity_id}"
        self.log("All asserts passed")

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    issueSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions