Compare commits
6 Commits
27247a5192
...
1c4d7a60bb
Author | SHA1 | Date |
---|---|---|
github-actions[bot] | 1c4d7a60bb | |
David Friedland | f1538a7ed0 | |
github-actions[bot] | e88f1468cb | |
Jesse Hills | 397c64f3e3 | |
github-actions[bot] | 0257210087 | |
Jesse Hills | b935707ceb |
|
@ -48,6 +48,7 @@ service APIConnection {
|
|||
rpc media_player_command (MediaPlayerCommandRequest) returns (void) {}
|
||||
rpc date_command (DateCommandRequest) returns (void) {}
|
||||
rpc time_command (TimeCommandRequest) returns (void) {}
|
||||
rpc datetime_command (DateTimeCommandRequest) returns (void) {}
|
||||
|
||||
rpc subscribe_bluetooth_le_advertisements (SubscribeBluetoothLEAdvertisementsRequest) returns (void) {}
|
||||
rpc bluetooth_device_request(BluetoothDeviceRequest) returns (void) {}
|
||||
|
@ -1720,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;
|
||||
|
@ -1768,3 +1796,40 @@ message ValveCommandRequest {
|
|||
float position = 3;
|
||||
bool stop = 4;
|
||||
}
|
||||
|
||||
// ==================== DATETIME DATETIME ====================
|
||||
message ListEntitiesDateTimeResponse {
|
||||
option (id) = 112;
|
||||
option (source) = SOURCE_SERVER;
|
||||
option (ifdef) = "USE_DATETIME_DATETIME";
|
||||
|
||||
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;
|
||||
}
|
||||
message DateTimeStateResponse {
|
||||
option (id) = 113;
|
||||
option (source) = SOURCE_SERVER;
|
||||
option (ifdef) = "USE_DATETIME_DATETIME";
|
||||
option (no_delay) = true;
|
||||
|
||||
fixed32 key = 1;
|
||||
// If the datetime does not have a valid state yet.
|
||||
// Equivalent to `!obj->has_state()` - inverse logic to make state packets smaller
|
||||
bool missing_state = 2;
|
||||
fixed32 epoch_seconds = 3;
|
||||
}
|
||||
message DateTimeCommandRequest {
|
||||
option (id) = 114;
|
||||
option (source) = SOURCE_CLIENT;
|
||||
option (ifdef) = "USE_DATETIME_DATETIME";
|
||||
option (no_delay) = true;
|
||||
|
||||
fixed32 key = 1;
|
||||
fixed32 epoch_seconds = 2;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -38,6 +38,7 @@ from .api_pb2 import ( # type: ignore
|
|||
ClimateCommandRequest,
|
||||
CoverCommandRequest,
|
||||
DateCommandRequest,
|
||||
DateTimeCommandRequest,
|
||||
DeviceInfoRequest,
|
||||
DeviceInfoResponse,
|
||||
ExecuteServiceArgument,
|
||||
|
@ -1118,6 +1119,18 @@ class APIClient:
|
|||
TimeCommandRequest(key=key, hour=hour, minute=minute, second=second)
|
||||
)
|
||||
|
||||
def datetime_command(
|
||||
self,
|
||||
key: int,
|
||||
epoch_seconds: int,
|
||||
) -> None:
|
||||
self._get_connection().send_message(
|
||||
DateTimeCommandRequest(
|
||||
key=key,
|
||||
epoch_seconds=epoch_seconds,
|
||||
)
|
||||
)
|
||||
|
||||
def select_command(self, key: int, state: str) -> None:
|
||||
self._get_connection().send_message(SelectCommandRequest(key=key, state=state))
|
||||
|
||||
|
|
|
@ -40,10 +40,13 @@ from .api_pb2 import ( # type: ignore
|
|||
CoverStateResponse,
|
||||
DateCommandRequest,
|
||||
DateStateResponse,
|
||||
DateTimeCommandRequest,
|
||||
DateTimeStateResponse,
|
||||
DeviceInfoRequest,
|
||||
DeviceInfoResponse,
|
||||
DisconnectRequest,
|
||||
DisconnectResponse,
|
||||
EventResponse,
|
||||
ExecuteServiceRequest,
|
||||
FanCommandRequest,
|
||||
FanStateResponse,
|
||||
|
@ -62,7 +65,9 @@ from .api_pb2 import ( # type: ignore
|
|||
ListEntitiesClimateResponse,
|
||||
ListEntitiesCoverResponse,
|
||||
ListEntitiesDateResponse,
|
||||
ListEntitiesDateTimeResponse,
|
||||
ListEntitiesDoneResponse,
|
||||
ListEntitiesEventResponse,
|
||||
ListEntitiesFanResponse,
|
||||
ListEntitiesLightResponse,
|
||||
ListEntitiesLockResponse,
|
||||
|
@ -371,7 +376,12 @@ MESSAGE_TYPE_TO_PROTO = {
|
|||
104: TimeStateResponse,
|
||||
105: TimeCommandRequest,
|
||||
106: VoiceAssistantAudio,
|
||||
107: ListEntitiesEventResponse,
|
||||
108: EventResponse,
|
||||
109: ListEntitiesValveResponse,
|
||||
110: ValveStateResponse,
|
||||
111: ValveCommandRequest,
|
||||
112: ListEntitiesDateTimeResponse,
|
||||
113: DateTimeStateResponse,
|
||||
114: DateTimeCommandRequest,
|
||||
}
|
||||
|
|
|
@ -262,6 +262,18 @@ class CoverState(EntityState):
|
|||
return self.position == 0.0
|
||||
|
||||
|
||||
# ==================== EVENT ==================
|
||||
@_frozen_dataclass_decorator
|
||||
class EventInfo(EntityInfo):
|
||||
device_class: str = ""
|
||||
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):
|
||||
|
@ -690,6 +702,18 @@ class TimeState(EntityState):
|
|||
second: int = 0
|
||||
|
||||
|
||||
# ==================== DATETIME DATETIME ====================
|
||||
@_frozen_dataclass_decorator
|
||||
class DateTimeInfo(EntityInfo):
|
||||
pass
|
||||
|
||||
|
||||
@_frozen_dataclass_decorator
|
||||
class DateTimeState(EntityState):
|
||||
missing_state: bool = False
|
||||
epoch_seconds: int = 0
|
||||
|
||||
|
||||
# ==================== SELECT ====================
|
||||
@_frozen_dataclass_decorator
|
||||
class SelectInfo(EntityInfo):
|
||||
|
@ -885,6 +909,7 @@ COMPONENT_TYPE_TO_INFO: dict[str, type[EntityInfo]] = {
|
|||
"climate": ClimateInfo,
|
||||
"number": NumberInfo,
|
||||
"date": DateInfo,
|
||||
"datetime": DateTimeInfo,
|
||||
"select": SelectInfo,
|
||||
"siren": SirenInfo,
|
||||
"button": ButtonInfo,
|
||||
|
@ -894,6 +919,7 @@ COMPONENT_TYPE_TO_INFO: dict[str, type[EntityInfo]] = {
|
|||
"text": TextInfo,
|
||||
"time": TimeInfo,
|
||||
"valve": ValveInfo,
|
||||
"event": EventInfo,
|
||||
}
|
||||
|
||||
|
||||
|
@ -1242,6 +1268,7 @@ _TYPE_TO_NAME = {
|
|||
LightInfo: "light",
|
||||
NumberInfo: "number",
|
||||
DateInfo: "date",
|
||||
DateTimeInfo: "datetime",
|
||||
SelectInfo: "select",
|
||||
SensorInfo: "sensor",
|
||||
SirenInfo: "siren",
|
||||
|
@ -1255,6 +1282,7 @@ _TYPE_TO_NAME = {
|
|||
TextInfo: "text_info",
|
||||
TimeInfo: "time",
|
||||
ValveInfo: "valve",
|
||||
EventInfo: "event",
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ from .api_pb2 import ( # type: ignore
|
|||
ClimateStateResponse,
|
||||
CoverStateResponse,
|
||||
DateStateResponse,
|
||||
DateTimeStateResponse,
|
||||
EventResponse,
|
||||
FanStateResponse,
|
||||
LightStateResponse,
|
||||
ListEntitiesAlarmControlPanelResponse,
|
||||
|
@ -17,6 +19,8 @@ from .api_pb2 import ( # type: ignore
|
|||
ListEntitiesClimateResponse,
|
||||
ListEntitiesCoverResponse,
|
||||
ListEntitiesDateResponse,
|
||||
ListEntitiesDateTimeResponse,
|
||||
ListEntitiesEventResponse,
|
||||
ListEntitiesFanResponse,
|
||||
ListEntitiesLightResponse,
|
||||
ListEntitiesLockResponse,
|
||||
|
@ -56,8 +60,12 @@ from .model import (
|
|||
CoverState,
|
||||
DateInfo,
|
||||
DateState,
|
||||
DateTimeInfo,
|
||||
DateTimeState,
|
||||
EntityInfo,
|
||||
EntityState,
|
||||
Event,
|
||||
EventInfo,
|
||||
FanInfo,
|
||||
FanState,
|
||||
LightInfo,
|
||||
|
@ -87,46 +95,50 @@ from .model import (
|
|||
)
|
||||
|
||||
SUBSCRIBE_STATES_RESPONSE_TYPES: dict[Any, type[EntityState]] = {
|
||||
AlarmControlPanelStateResponse: AlarmControlPanelEntityState,
|
||||
BinarySensorStateResponse: BinarySensorState,
|
||||
ClimateStateResponse: ClimateState,
|
||||
CoverStateResponse: CoverState,
|
||||
DateStateResponse: DateState,
|
||||
DateTimeStateResponse: DateTimeState,
|
||||
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,
|
||||
ValveStateResponse: ValveState,
|
||||
}
|
||||
|
||||
LIST_ENTITIES_SERVICES_RESPONSE_TYPES: dict[Any, type[EntityInfo] | None] = {
|
||||
ListEntitiesAlarmControlPanelResponse: AlarmControlPanelInfo,
|
||||
ListEntitiesBinarySensorResponse: BinarySensorInfo,
|
||||
ListEntitiesButtonResponse: ButtonInfo,
|
||||
ListEntitiesCameraResponse: CameraInfo,
|
||||
ListEntitiesClimateResponse: ClimateInfo,
|
||||
ListEntitiesCoverResponse: CoverInfo,
|
||||
ListEntitiesDateResponse: DateInfo,
|
||||
ListEntitiesDateTimeResponse: DateTimeInfo,
|
||||
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,
|
||||
ListEntitiesValveResponse: ValveInfo,
|
||||
}
|
||||
|
|
2
setup.py
2
setup.py
|
@ -11,7 +11,7 @@ with open(os.path.join(here, "README.rst"), encoding="utf-8") as readme_file:
|
|||
long_description = readme_file.read()
|
||||
|
||||
|
||||
VERSION = "24.1.1"
|
||||
VERSION = "24.3.0"
|
||||
PROJECT_NAME = "aioesphomeapi"
|
||||
PROJECT_PACKAGE_NAME = "aioesphomeapi"
|
||||
PROJECT_LICENSE = "MIT"
|
||||
|
|
|
@ -42,6 +42,7 @@ from aioesphomeapi.api_pb2 import (
|
|||
ClimateCommandRequest,
|
||||
CoverCommandRequest,
|
||||
DateCommandRequest,
|
||||
DateTimeCommandRequest,
|
||||
DeviceInfoResponse,
|
||||
DisconnectResponse,
|
||||
ExecuteServiceArgument,
|
||||
|
@ -668,6 +669,30 @@ async def test_time_command(
|
|||
send.assert_called_once_with(TimeCommandRequest(**req))
|
||||
|
||||
|
||||
# Test date_time command
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"cmd, req",
|
||||
[
|
||||
(
|
||||
dict(key=1, epoch_seconds=1735648230),
|
||||
dict(key=1, epoch_seconds=1735648230),
|
||||
),
|
||||
(
|
||||
dict(key=1, epoch_seconds=1735689600),
|
||||
dict(key=1, epoch_seconds=1735689600),
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_datetime_command(
|
||||
auth_client: APIClient, cmd: dict[str, Any], req: dict[str, Any]
|
||||
) -> None:
|
||||
send = patch_send(auth_client)
|
||||
|
||||
auth_client.datetime_command(**cmd)
|
||||
send.assert_called_once_with(DateTimeCommandRequest(**req))
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"cmd, req",
|
||||
|
|
|
@ -14,7 +14,9 @@ from aioesphomeapi.api_pb2 import (
|
|||
ClimateStateResponse,
|
||||
CoverStateResponse,
|
||||
DateStateResponse,
|
||||
DateTimeStateResponse,
|
||||
DeviceInfoResponse,
|
||||
EventResponse,
|
||||
FanStateResponse,
|
||||
HomeassistantServiceMap,
|
||||
HomeassistantServiceResponse,
|
||||
|
@ -25,6 +27,8 @@ from aioesphomeapi.api_pb2 import (
|
|||
ListEntitiesClimateResponse,
|
||||
ListEntitiesCoverResponse,
|
||||
ListEntitiesDateResponse,
|
||||
ListEntitiesDateTimeResponse,
|
||||
ListEntitiesEventResponse,
|
||||
ListEntitiesFanResponse,
|
||||
ListEntitiesLightResponse,
|
||||
ListEntitiesLockResponse,
|
||||
|
@ -77,7 +81,11 @@ from aioesphomeapi.model import (
|
|||
CoverState,
|
||||
DateInfo,
|
||||
DateState,
|
||||
DateTimeInfo,
|
||||
DateTimeState,
|
||||
DeviceInfo,
|
||||
Event,
|
||||
EventInfo,
|
||||
FanInfo,
|
||||
FanState,
|
||||
HomeassistantServiceCall,
|
||||
|
@ -274,6 +282,10 @@ def test_api_version_ord():
|
|||
(TextState, TextStateResponse),
|
||||
(TimeInfo, ListEntitiesTimeResponse),
|
||||
(TimeState, TimeStateResponse),
|
||||
(DateTimeInfo, ListEntitiesDateTimeResponse),
|
||||
(DateTimeState, DateTimeStateResponse),
|
||||
(EventInfo, ListEntitiesEventResponse),
|
||||
(Event, EventResponse),
|
||||
],
|
||||
)
|
||||
def test_basic_pb_conversions(model, pb):
|
||||
|
|
Loading…
Reference in New Issue