Compare commits
25 Commits
Author | SHA1 | Date |
---|---|---|
github-actions[bot] | 6a23cca5d3 | |
dependabot[bot] | 44dafb9f06 | |
github-actions[bot] | 8cd85de0af | |
Jesse Hills | 0eede84ead | |
dependabot[bot] | 3bae70e462 | |
github-actions[bot] | 2ae6ff8338 | |
dependabot[bot] | 24652a226d | |
dependabot[bot] | e8d27e514e | |
github-actions[bot] | d62d67f585 | |
Mischa Siekmann | 8778ad485c | |
dependabot[bot] | 8e6717c197 | |
dependabot[bot] | adcd5b1a13 | |
dependabot[bot] | 6e2d5d4fde | |
dependabot[bot] | 8dd044e89d | |
github-actions[bot] | e97a716d44 | |
dependabot[bot] | ab390acf93 | |
github-actions[bot] | 1c4d7a60bb | |
David Friedland | f1538a7ed0 | |
github-actions[bot] | e88f1468cb | |
Jesse Hills | 397c64f3e3 | |
github-actions[bot] | 0257210087 | |
Jesse Hills | b935707ceb | |
dependabot[bot] | 27247a5192 | |
github-actions[bot] | 01eaee25c0 | |
J. Nick Koston | 4cff8555d2 |
|
@ -28,13 +28,13 @@ jobs:
|
|||
uses: actions/checkout@v4
|
||||
-
|
||||
name: Log in to docker hub
|
||||
uses: docker/login-action@v3.1.0
|
||||
uses: docker/login-action@v3.2.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USER }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
-
|
||||
name: Log in to the GitHub container registry
|
||||
uses: docker/login-action@v3.1.0
|
||||
uses: docker/login-action@v3.2.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
|
|
|
@ -25,7 +25,7 @@ jobs:
|
|||
platforms: arm64
|
||||
|
||||
- name: Build wheels
|
||||
uses: pypa/cibuildwheel@v2.17.0
|
||||
uses: pypa/cibuildwheel@v2.18.1
|
||||
env:
|
||||
CIBW_SKIP: cp36-* cp37-* cp38-* cp39-* cp310-* pp* *musllinux*
|
||||
CIBW_BEFORE_ALL_LINUX: apt-get install -y gcc || yum install -y gcc || apk add gcc
|
||||
|
|
|
@ -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) {}
|
||||
|
@ -1174,6 +1175,9 @@ message MediaPlayerCommandRequest {
|
|||
|
||||
bool has_media_url = 6;
|
||||
string media_url = 7;
|
||||
|
||||
bool has_announcement = 8;
|
||||
bool announcement = 9;
|
||||
}
|
||||
|
||||
// ==================== BLUETOOTH ====================
|
||||
|
@ -1532,6 +1536,26 @@ message VoiceAssistantAudio {
|
|||
bool end = 2;
|
||||
}
|
||||
|
||||
enum VoiceAssistantTimerEvent {
|
||||
VOICE_ASSISTANT_TIMER_STARTED = 0;
|
||||
VOICE_ASSISTANT_TIMER_UPDATED = 1;
|
||||
VOICE_ASSISTANT_TIMER_CANCELLED = 2;
|
||||
VOICE_ASSISTANT_TIMER_FINISHED = 3;
|
||||
}
|
||||
|
||||
message VoiceAssistantTimerEventResponse {
|
||||
option (id) = 115;
|
||||
option (source) = SOURCE_CLIENT;
|
||||
option (ifdef) = "USE_VOICE_ASSISTANT";
|
||||
|
||||
VoiceAssistantTimerEvent event_type = 1;
|
||||
string timer_id = 2;
|
||||
string name = 3;
|
||||
uint32 total_seconds = 4;
|
||||
uint32 seconds_left = 5;
|
||||
bool is_active = 6;
|
||||
}
|
||||
|
||||
// ==================== ALARM CONTROL PANEL ====================
|
||||
enum AlarmControlPanelState {
|
||||
ALARM_STATE_DISARMED = 0;
|
||||
|
@ -1720,6 +1744,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 +1819,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,
|
||||
|
@ -73,6 +74,7 @@ from .api_pb2 import ( # type: ignore
|
|||
VoiceAssistantEventResponse,
|
||||
VoiceAssistantRequest,
|
||||
VoiceAssistantResponse,
|
||||
VoiceAssistantTimerEventResponse,
|
||||
)
|
||||
from .client_callbacks import (
|
||||
on_bluetooth_connections_free_response,
|
||||
|
@ -130,6 +132,7 @@ from .model import (
|
|||
VoiceAssistantCommand,
|
||||
VoiceAssistantEventType,
|
||||
VoiceAssistantSubscriptionFlag,
|
||||
VoiceAssistantTimerEventType,
|
||||
message_types_to_names,
|
||||
)
|
||||
from .model_conversions import (
|
||||
|
@ -1118,6 +1121,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))
|
||||
|
||||
|
@ -1179,6 +1194,7 @@ class APIClient:
|
|||
command: MediaPlayerCommand | None = None,
|
||||
volume: float | None = None,
|
||||
media_url: str | None = None,
|
||||
announcement: bool | None = None,
|
||||
) -> None:
|
||||
req = MediaPlayerCommandRequest(key=key)
|
||||
if command is not None:
|
||||
|
@ -1190,6 +1206,9 @@ class APIClient:
|
|||
if media_url is not None:
|
||||
req.media_url = media_url
|
||||
req.has_media_url = True
|
||||
if announcement is not None:
|
||||
req.announcement = announcement
|
||||
req.has_announcement = True
|
||||
self._get_connection().send_message(req)
|
||||
|
||||
def text_command(self, key: int, state: str) -> None:
|
||||
|
@ -1369,6 +1388,25 @@ class APIClient:
|
|||
req = VoiceAssistantAudio(data=data)
|
||||
self._get_connection().send_message(req)
|
||||
|
||||
def send_voice_assistant_timer_event(
|
||||
self,
|
||||
event_type: VoiceAssistantTimerEventType,
|
||||
timer_id: str,
|
||||
name: str | None,
|
||||
total_seconds: int,
|
||||
seconds_left: int,
|
||||
is_active: bool,
|
||||
) -> None:
|
||||
req = VoiceAssistantTimerEventResponse(
|
||||
event_type=event_type,
|
||||
timer_id=timer_id,
|
||||
name=name,
|
||||
total_seconds=total_seconds,
|
||||
seconds_left=seconds_left,
|
||||
is_active=is_active,
|
||||
)
|
||||
self._get_connection().send_message(req)
|
||||
|
||||
def alarm_control_panel_command(
|
||||
self,
|
||||
key: int,
|
||||
|
|
|
@ -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,
|
||||
|
@ -114,6 +119,7 @@ from .api_pb2 import ( # type: ignore
|
|||
VoiceAssistantEventResponse,
|
||||
VoiceAssistantRequest,
|
||||
VoiceAssistantResponse,
|
||||
VoiceAssistantTimerEventResponse,
|
||||
)
|
||||
|
||||
TWO_CHAR = re.compile(r".{2}")
|
||||
|
@ -371,7 +377,13 @@ 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,
|
||||
115: VoiceAssistantTimerEventResponse,
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ class VoiceAssistantFeature(enum.IntFlag):
|
|||
VOICE_ASSISTANT = 1 << 0
|
||||
SPEAKER = 1 << 1
|
||||
API_AUDIO = 1 << 2
|
||||
TIMERS = 1 << 3
|
||||
|
||||
|
||||
class VoiceAssistantSubscriptionFlag(enum.IntFlag):
|
||||
|
@ -262,6 +263,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 +703,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 +910,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 +920,7 @@ COMPONENT_TYPE_TO_INFO: dict[str, type[EntityInfo]] = {
|
|||
"text": TextInfo,
|
||||
"time": TimeInfo,
|
||||
"valve": ValveInfo,
|
||||
"event": EventInfo,
|
||||
}
|
||||
|
||||
|
||||
|
@ -1234,6 +1261,13 @@ class VoiceAssistantEventType(APIIntEnum):
|
|||
VOICE_ASSISTANT_TTS_STREAM_END = 99
|
||||
|
||||
|
||||
class VoiceAssistantTimerEventType(APIIntEnum):
|
||||
VOICE_ASSISTANT_TIMER_STARTED = 0
|
||||
VOICE_ASSISTANT_TIMER_UPDATED = 1
|
||||
VOICE_ASSISTANT_TIMER_CANCELLED = 2
|
||||
VOICE_ASSISTANT_TIMER_FINISHED = 3
|
||||
|
||||
|
||||
_TYPE_TO_NAME = {
|
||||
BinarySensorInfo: "binary_sensor",
|
||||
ButtonInfo: "button",
|
||||
|
@ -1242,6 +1276,7 @@ _TYPE_TO_NAME = {
|
|||
LightInfo: "light",
|
||||
NumberInfo: "number",
|
||||
DateInfo: "date",
|
||||
DateTimeInfo: "datetime",
|
||||
SelectInfo: "select",
|
||||
SensorInfo: "sensor",
|
||||
SirenInfo: "siren",
|
||||
|
@ -1255,6 +1290,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,
|
||||
}
|
||||
|
|
|
@ -413,16 +413,11 @@ class ReconnectLogic(zeroconf.RecordUpdateListener):
|
|||
self._cli.log_name,
|
||||
record_update.new,
|
||||
)
|
||||
# We can't stop the zeroconf listener here because we are in the middle of
|
||||
# a zeroconf callback which is iterating the listeners.
|
||||
#
|
||||
# So we schedule a stop for the next event loop iteration as well as the
|
||||
# connect attempt.
|
||||
#
|
||||
# If we scheduled the connect attempt immediately, the listener could fire
|
||||
# again before the connect attempt and we cancel and reschedule the connect
|
||||
# attempt again.
|
||||
#
|
||||
self.loop.call_soon(self._connect_from_zeroconf)
|
||||
self._connect_from_zeroconf()
|
||||
self._accept_zeroconf_records = False
|
||||
return
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
aiohappyeyeballs>=2.3.0
|
||||
async-interrupt>=1.1.1
|
||||
protobuf>=3.19.0
|
||||
zeroconf>=0.128.4,<1.0
|
||||
zeroconf>=0.132.2,<1.0
|
||||
chacha20poly1305-reuseable>=0.12.1
|
||||
cryptography>=42.0.2
|
||||
noiseprotocol>=0.3.1,<1.0
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
pylint==3.1.0
|
||||
black==24.4.0
|
||||
pylint==3.2.2
|
||||
black==24.4.2
|
||||
flake8==7.0.0
|
||||
isort==5.13.2
|
||||
mypy==1.9.0
|
||||
types-protobuf==4.25.0.20240410
|
||||
mypy==1.10.0
|
||||
types-protobuf==5.26.0.20240422
|
||||
pytest>=6.2.4,<9
|
||||
pytest-asyncio==0.23.6
|
||||
pytest-asyncio==0.23.7
|
||||
mock>=4.0.3,<6
|
||||
pytest-cov>=4.1.0
|
||||
|
|
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.0"
|
||||
VERSION = "24.5.1"
|
||||
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,
|
||||
|
@ -71,6 +72,7 @@ from aioesphomeapi.api_pb2 import (
|
|||
VoiceAssistantEventResponse,
|
||||
VoiceAssistantRequest,
|
||||
VoiceAssistantResponse,
|
||||
VoiceAssistantTimerEventResponse,
|
||||
)
|
||||
from aioesphomeapi.client import APIClient, BluetoothConnectionDroppedError
|
||||
from aioesphomeapi.connection import APIConnection
|
||||
|
@ -112,6 +114,9 @@ from aioesphomeapi.model import (
|
|||
VoiceAssistantAudioSettings as VoiceAssistantAudioSettingsModel,
|
||||
)
|
||||
from aioesphomeapi.model import VoiceAssistantEventType as VoiceAssistantEventModelType
|
||||
from aioesphomeapi.model import (
|
||||
VoiceAssistantTimerEventType as VoiceAssistantTimerEventModelType,
|
||||
)
|
||||
from aioesphomeapi.reconnect_logic import ReconnectLogic, ReconnectLogicState
|
||||
|
||||
from .common import (
|
||||
|
@ -668,6 +673,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",
|
||||
|
@ -769,6 +798,16 @@ async def test_select_command(
|
|||
dict(key=1, media_url="http://example.com"),
|
||||
dict(key=1, has_media_url=True, media_url="http://example.com"),
|
||||
),
|
||||
(
|
||||
dict(key=1, media_url="http://example.com", announcement=True),
|
||||
dict(
|
||||
key=1,
|
||||
has_media_url=True,
|
||||
media_url="http://example.com",
|
||||
has_announcement=True,
|
||||
announcement=True,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_media_player_command(
|
||||
|
@ -2450,6 +2489,31 @@ async def test_subscribe_voice_assistant_api_audio(
|
|||
assert len(send.mock_calls) == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_voice_assistant_timer_event(auth_client: APIClient) -> None:
|
||||
send = patch_send(auth_client)
|
||||
|
||||
auth_client.send_voice_assistant_timer_event(
|
||||
VoiceAssistantTimerEventModelType.VOICE_ASSISTANT_TIMER_STARTED,
|
||||
timer_id="test",
|
||||
name="test",
|
||||
total_seconds=99,
|
||||
seconds_left=45,
|
||||
is_active=True,
|
||||
)
|
||||
|
||||
send.assert_called_once_with(
|
||||
VoiceAssistantTimerEventResponse(
|
||||
event_type=VoiceAssistantTimerEventModelType.VOICE_ASSISTANT_TIMER_STARTED,
|
||||
timer_id="test",
|
||||
name="test",
|
||||
total_seconds=99,
|
||||
seconds_left=45,
|
||||
is_active=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_api_version_after_connection_closed(
|
||||
api_client: tuple[
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -441,8 +441,6 @@ async def test_reconnect_zeroconf(
|
|||
"Triggering connect because of received mDNS record" in caplog.text
|
||||
) is should_trigger_zeroconf
|
||||
assert rl._accept_zeroconf_records is not should_trigger_zeroconf
|
||||
assert rl._zc_listening is True # should change after one iteration of the loop
|
||||
await asyncio.sleep(0)
|
||||
assert rl._zc_listening is not should_trigger_zeroconf
|
||||
|
||||
# The reconnect is scheduled to run in the next loop iteration
|
||||
|
|
Loading…
Reference in New Issue