Support for Event entity messages

This commit is contained in:
David Friedland 2024-03-30 09:53:46 -07:00 committed by Jesse Hills
parent 397c64f3e3
commit 4b6df1bf0e
No known key found for this signature in database
GPG Key ID: BEAAE804EFD8E83A
5 changed files with 143 additions and 69 deletions

View File

@ -1721,6 +1721,33 @@ message TimeCommandRequest {
uint32 second = 4;
}
// ==================== EVENT ====================
message ListEntitiesEventResponse {
option (id) = 107;
option (source) = SOURCE_SERVER;
option (ifdef) = "USE_EVENT";
string object_id = 1;
fixed32 key = 2;
string name = 3;
string unique_id = 4;
string icon = 5;
bool disabled_by_default = 6;
EntityCategory entity_category = 7;
string device_class = 8;
repeated string event_types = 9;
}
message EventResponse {
option (id) = 108;
option (source) = SOURCE_SERVER;
option (ifdef) = "USE_EVENT";
fixed32 key = 1;
string event_type = 2;
}
// ==================== VALVE ====================
message ListEntitiesValveResponse {
option (id) = 109;

File diff suppressed because one or more lines are too long

View File

@ -46,6 +46,7 @@ from .api_pb2 import ( # type: ignore
DeviceInfoResponse,
DisconnectRequest,
DisconnectResponse,
EventResponse,
ExecuteServiceRequest,
FanCommandRequest,
FanStateResponse,
@ -66,6 +67,7 @@ from .api_pb2 import ( # type: ignore
ListEntitiesDateResponse,
ListEntitiesDateTimeResponse,
ListEntitiesDoneResponse,
ListEntitiesEventResponse,
ListEntitiesFanResponse,
ListEntitiesLightResponse,
ListEntitiesLockResponse,
@ -374,6 +376,8 @@ MESSAGE_TYPE_TO_PROTO = {
104: TimeStateResponse,
105: TimeCommandRequest,
106: VoiceAssistantAudio,
107: ListEntitiesEventResponse,
108: EventResponse,
109: ListEntitiesValveResponse,
110: ValveStateResponse,
111: ValveCommandRequest,

View File

@ -262,6 +262,17 @@ class CoverState(EntityState):
return self.position == 0.0
# ==================== EVENT ==================
@_frozen_dataclass_decorator
class EventInfo(EntityInfo):
event_types: list[str] = converter_field(default_factory=list, converter=list)
@_frozen_dataclass_decorator
class Event(EntityState):
event_type: str = ""
# ==================== FAN ====================
@_frozen_dataclass_decorator
class FanInfo(EntityInfo):
@ -907,6 +918,7 @@ COMPONENT_TYPE_TO_INFO: dict[str, type[EntityInfo]] = {
"text": TextInfo,
"time": TimeInfo,
"valve": ValveInfo,
"event": EventInfo,
}
@ -1269,6 +1281,7 @@ _TYPE_TO_NAME = {
TextInfo: "text_info",
TimeInfo: "time",
ValveInfo: "valve",
EventInfo: "event",
}

View File

@ -9,6 +9,7 @@ from .api_pb2 import ( # type: ignore
CoverStateResponse,
DateStateResponse,
DateTimeStateResponse,
EventResponse,
FanStateResponse,
LightStateResponse,
ListEntitiesAlarmControlPanelResponse,
@ -19,6 +20,7 @@ from .api_pb2 import ( # type: ignore
ListEntitiesCoverResponse,
ListEntitiesDateResponse,
ListEntitiesDateTimeResponse,
ListEntitiesEventResponse,
ListEntitiesFanResponse,
ListEntitiesLightResponse,
ListEntitiesLockResponse,
@ -62,6 +64,8 @@ from .model import (
DateTimeState,
EntityInfo,
EntityState,
EventInfo,
Event,
FanInfo,
FanState,
LightInfo,
@ -97,6 +101,7 @@ SUBSCRIBE_STATES_RESPONSE_TYPES: dict[Any, type[EntityState]] = {
CoverStateResponse: CoverState,
DateStateResponse: DateState,
DateTimeStateResponse: DateTimeState,
EventResponse: Event,
FanStateResponse: FanState,
LightStateResponse: LightState,
LockStateResponse: LockEntityState,
@ -121,6 +126,7 @@ LIST_ENTITIES_SERVICES_RESPONSE_TYPES: dict[Any, type[EntityInfo] | None] = {
ListEntitiesCoverResponse: CoverInfo,
ListEntitiesDateResponse: DateInfo,
ListEntitiesDateTimeResponse: DateTimeInfo,
ListEntitiesEventResponse: EventInfo,
ListEntitiesFanResponse: FanInfo,
ListEntitiesLightResponse: LightInfo,
ListEntitiesLockResponse: LockInfo,