1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-25 03:09:52 +01:00

Add event entity (#96797)

This commit is contained in:
Franck Nijhof
2023-07-21 12:16:35 +02:00
committed by GitHub
parent 4916351d9a
commit 747f4d4a73
18 changed files with 779 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
"""Provide a mock event platform.
Call init before using it in your tests to ensure clean test data.
"""
from homeassistant.components.event import EventEntity
from tests.common import MockEntity
ENTITIES = []
class MockEventEntity(MockEntity, EventEntity):
"""Mock EventEntity class."""
@property
def event_types(self) -> list[str]:
"""Return a list of possible events."""
return self._handle("event_types")
def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
ENTITIES = (
[]
if empty
else [
MockEventEntity(
name="doorbell",
unique_id="unique_doorbell",
event_types=["short_press", "long_press"],
),
]
)
async def async_setup_platform(
hass, config, async_add_entities_callback, discovery_info=None
):
"""Return mock entities."""
async_add_entities_callback(ENTITIES)