Compare commits

...

2 Commits

Author SHA1 Message Date
Jesse Hills 156762bca9
Sort import 2024-04-09 04:40:44 +00:00
David Friedland 26d8e616bb
Support for Event entity messages 2024-04-09 04:37:30 +00:00
5 changed files with 141 additions and 68 deletions

View File

@ -1718,3 +1718,29 @@ message TimeCommandRequest {
uint32 minute = 3;
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;
}

File diff suppressed because one or more lines are too long

View File

@ -44,6 +44,7 @@ from .api_pb2 import ( # type: ignore
DeviceInfoResponse,
DisconnectRequest,
DisconnectResponse,
EventResponse,
ExecuteServiceRequest,
FanCommandRequest,
FanStateResponse,
@ -63,6 +64,7 @@ from .api_pb2 import ( # type: ignore
ListEntitiesCoverResponse,
ListEntitiesDateResponse,
ListEntitiesDoneResponse,
ListEntitiesEventResponse,
ListEntitiesFanResponse,
ListEntitiesLightResponse,
ListEntitiesLockResponse,
@ -368,4 +370,6 @@ MESSAGE_TYPE_TO_PROTO = {
104: TimeStateResponse,
105: TimeCommandRequest,
106: VoiceAssistantAudio,
107: ListEntitiesEventResponse,
108: EventResponse,
}

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):
@ -868,6 +879,7 @@ COMPONENT_TYPE_TO_INFO: dict[str, type[EntityInfo]] = {
"alarm_control_panel": AlarmControlPanelInfo,
"text": TextInfo,
"time": TimeInfo,
"event": EventInfo,
}
@ -1228,6 +1240,7 @@ _TYPE_TO_NAME = {
AlarmControlPanelInfo: "alarm_control_panel",
TextInfo: "text_info",
TimeInfo: "time",
EventInfo: "event",
}

View File

@ -8,6 +8,7 @@ from .api_pb2 import ( # type: ignore
ClimateStateResponse,
CoverStateResponse,
DateStateResponse,
EventResponse,
FanStateResponse,
LightStateResponse,
ListEntitiesAlarmControlPanelResponse,
@ -17,6 +18,7 @@ from .api_pb2 import ( # type: ignore
ListEntitiesClimateResponse,
ListEntitiesCoverResponse,
ListEntitiesDateResponse,
ListEntitiesEventResponse,
ListEntitiesFanResponse,
ListEntitiesLightResponse,
ListEntitiesLockResponse,
@ -56,6 +58,8 @@ from .model import (
DateState,
EntityInfo,
EntityState,
Event,
EventInfo,
FanInfo,
FanState,
LightInfo,
@ -83,44 +87,46 @@ from .model import (
)
SUBSCRIBE_STATES_RESPONSE_TYPES: dict[Any, type[EntityState]] = {
AlarmControlPanelStateResponse: AlarmControlPanelEntityState,
BinarySensorStateResponse: BinarySensorState,
ClimateStateResponse: ClimateState,
CoverStateResponse: CoverState,
DateStateResponse: DateState,
EventResponse: Event,
FanStateResponse: FanState,
LightStateResponse: LightState,
LockStateResponse: LockEntityState,
MediaPlayerStateResponse: MediaPlayerEntityState,
NumberStateResponse: NumberState,
DateStateResponse: DateState,
SelectStateResponse: SelectState,
SensorStateResponse: SensorState,
SirenStateResponse: SirenState,
SwitchStateResponse: SwitchState,
TextStateResponse: TextState,
TextSensorStateResponse: TextSensorState,
ClimateStateResponse: ClimateState,
LockStateResponse: LockEntityState,
MediaPlayerStateResponse: MediaPlayerEntityState,
AlarmControlPanelStateResponse: AlarmControlPanelEntityState,
TextStateResponse: TextState,
TimeStateResponse: TimeState,
}
LIST_ENTITIES_SERVICES_RESPONSE_TYPES: dict[Any, type[EntityInfo] | None] = {
ListEntitiesAlarmControlPanelResponse: AlarmControlPanelInfo,
ListEntitiesBinarySensorResponse: BinarySensorInfo,
ListEntitiesButtonResponse: ButtonInfo,
ListEntitiesCameraResponse: CameraInfo,
ListEntitiesClimateResponse: ClimateInfo,
ListEntitiesCoverResponse: CoverInfo,
ListEntitiesDateResponse: DateInfo,
ListEntitiesEventResponse: EventInfo,
ListEntitiesFanResponse: FanInfo,
ListEntitiesLightResponse: LightInfo,
ListEntitiesLockResponse: LockInfo,
ListEntitiesMediaPlayerResponse: MediaPlayerInfo,
ListEntitiesNumberResponse: NumberInfo,
ListEntitiesDateResponse: DateInfo,
ListEntitiesSelectResponse: SelectInfo,
ListEntitiesSensorResponse: SensorInfo,
ListEntitiesServicesResponse: None,
ListEntitiesSirenResponse: SirenInfo,
ListEntitiesSwitchResponse: SwitchInfo,
ListEntitiesTextResponse: TextInfo,
ListEntitiesTextSensorResponse: TextSensorInfo,
ListEntitiesServicesResponse: None,
ListEntitiesCameraResponse: CameraInfo,
ListEntitiesClimateResponse: ClimateInfo,
ListEntitiesLockResponse: LockInfo,
ListEntitiesMediaPlayerResponse: MediaPlayerInfo,
ListEntitiesAlarmControlPanelResponse: AlarmControlPanelInfo,
ListEntitiesTimeResponse: TimeInfo,
}