Compare commits

...

9 Commits

Author SHA1 Message Date
dependabot[bot] 01e84c8b59
Merge 88a8191545 into 0257210087 2024-04-22 15:59:32 +12:00
github-actions[bot] 0257210087 Bump version to 24.2.0 2024-04-22 03:58:30 +00:00
Jesse Hills b935707ceb
Add Datetime entities (#859) 2024-04-22 15:58:16 +12:00
dependabot[bot] 27247a5192
Bump types-protobuf from 4.25.0.20240410 to 4.25.0.20240417 (#863)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-18 17:25:28 +12:00
github-actions[bot] 01eaee25c0 Bump version to 24.1.1 2024-04-17 21:18:54 +00:00
J. Nick Koston 4cff8555d2
Remove zeroconf listener removal workaround (#860) 2024-04-17 16:18:36 -05:00
github-actions[bot] 56369fb332 Bump version to 24.1.0 2024-04-17 01:50:05 +00:00
Keith Burzinski 0ed69bbb30
Add valve component (#852)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2024-04-17 13:45:33 +12:00
dependabot[bot] 88a8191545
Bump codecov/codecov-action from 3 to 4
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3 to 4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-01 10:05:33 +00:00
14 changed files with 403 additions and 67 deletions

View File

@ -89,7 +89,7 @@ jobs:
- run: pytest -vv --cov=aioesphomeapi --cov-report=xml --tb=native tests - run: pytest -vv --cov=aioesphomeapi --cov-report=xml --tb=native tests
name: Run tests with pytest name: Run tests with pytest
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v4
- run: | - run: |
docker run \ docker run \
-v "$PWD":/aioesphomeapi \ -v "$PWD":/aioesphomeapi \

View File

@ -44,9 +44,11 @@ service APIConnection {
rpc siren_command (SirenCommandRequest) returns (void) {} rpc siren_command (SirenCommandRequest) returns (void) {}
rpc button_command (ButtonCommandRequest) returns (void) {} rpc button_command (ButtonCommandRequest) returns (void) {}
rpc lock_command (LockCommandRequest) returns (void) {} rpc lock_command (LockCommandRequest) returns (void) {}
rpc valve_command (ValveCommandRequest) returns (void) {}
rpc media_player_command (MediaPlayerCommandRequest) returns (void) {} rpc media_player_command (MediaPlayerCommandRequest) returns (void) {}
rpc date_command (DateCommandRequest) returns (void) {} rpc date_command (DateCommandRequest) returns (void) {}
rpc time_command (TimeCommandRequest) returns (void) {} rpc time_command (TimeCommandRequest) returns (void) {}
rpc datetime_command (DateTimeCommandRequest) returns (void) {}
rpc subscribe_bluetooth_le_advertisements (SubscribeBluetoothLEAdvertisementsRequest) returns (void) {} rpc subscribe_bluetooth_le_advertisements (SubscribeBluetoothLEAdvertisementsRequest) returns (void) {}
rpc bluetooth_device_request(BluetoothDeviceRequest) returns (void) {} rpc bluetooth_device_request(BluetoothDeviceRequest) returns (void) {}
@ -1718,3 +1720,89 @@ message TimeCommandRequest {
uint32 minute = 3; uint32 minute = 3;
uint32 second = 4; uint32 second = 4;
} }
// ==================== VALVE ====================
message ListEntitiesValveResponse {
option (id) = 109;
option (source) = SOURCE_SERVER;
option (ifdef) = "USE_VALVE";
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;
bool assumed_state = 9;
bool supports_position = 10;
bool supports_stop = 11;
}
enum ValveOperation {
VALVE_OPERATION_IDLE = 0;
VALVE_OPERATION_IS_OPENING = 1;
VALVE_OPERATION_IS_CLOSING = 2;
}
message ValveStateResponse {
option (id) = 110;
option (source) = SOURCE_SERVER;
option (ifdef) = "USE_VALVE";
option (no_delay) = true;
fixed32 key = 1;
float position = 2;
ValveOperation current_operation = 3;
}
message ValveCommandRequest {
option (id) = 111;
option (source) = SOURCE_CLIENT;
option (ifdef) = "USE_VALVE";
option (no_delay) = true;
fixed32 key = 1;
bool has_position = 2;
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

View File

@ -38,6 +38,7 @@ from .api_pb2 import ( # type: ignore
ClimateCommandRequest, ClimateCommandRequest,
CoverCommandRequest, CoverCommandRequest,
DateCommandRequest, DateCommandRequest,
DateTimeCommandRequest,
DeviceInfoRequest, DeviceInfoRequest,
DeviceInfoResponse, DeviceInfoResponse,
ExecuteServiceArgument, ExecuteServiceArgument,
@ -67,6 +68,7 @@ from .api_pb2 import ( # type: ignore
TextCommandRequest, TextCommandRequest,
TimeCommandRequest, TimeCommandRequest,
UnsubscribeBluetoothLEAdvertisementsRequest, UnsubscribeBluetoothLEAdvertisementsRequest,
ValveCommandRequest,
VoiceAssistantAudio, VoiceAssistantAudio,
VoiceAssistantEventData, VoiceAssistantEventData,
VoiceAssistantEventResponse, VoiceAssistantEventResponse,
@ -1117,6 +1119,18 @@ class APIClient:
TimeCommandRequest(key=key, hour=hour, minute=minute, second=second) 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: def select_command(self, key: int, state: str) -> None:
self._get_connection().send_message(SelectCommandRequest(key=key, state=state)) self._get_connection().send_message(SelectCommandRequest(key=key, state=state))
@ -1157,6 +1171,20 @@ class APIClient:
req.code = code req.code = code
self._get_connection().send_message(req) self._get_connection().send_message(req)
def valve_command(
self,
key: int,
position: float | None = None,
stop: bool = False,
) -> None:
req = ValveCommandRequest(key=key)
if position is not None:
req.has_position = True
req.position = position
if stop:
req.stop = stop
self._get_connection().send_message(req)
def media_player_command( def media_player_command(
self, self,
key: int, key: int,

View File

@ -40,6 +40,8 @@ from .api_pb2 import ( # type: ignore
CoverStateResponse, CoverStateResponse,
DateCommandRequest, DateCommandRequest,
DateStateResponse, DateStateResponse,
DateTimeCommandRequest,
DateTimeStateResponse,
DeviceInfoRequest, DeviceInfoRequest,
DeviceInfoResponse, DeviceInfoResponse,
DisconnectRequest, DisconnectRequest,
@ -62,6 +64,7 @@ from .api_pb2 import ( # type: ignore
ListEntitiesClimateResponse, ListEntitiesClimateResponse,
ListEntitiesCoverResponse, ListEntitiesCoverResponse,
ListEntitiesDateResponse, ListEntitiesDateResponse,
ListEntitiesDateTimeResponse,
ListEntitiesDoneResponse, ListEntitiesDoneResponse,
ListEntitiesFanResponse, ListEntitiesFanResponse,
ListEntitiesLightResponse, ListEntitiesLightResponse,
@ -77,6 +80,7 @@ from .api_pb2 import ( # type: ignore
ListEntitiesTextResponse, ListEntitiesTextResponse,
ListEntitiesTextSensorResponse, ListEntitiesTextSensorResponse,
ListEntitiesTimeResponse, ListEntitiesTimeResponse,
ListEntitiesValveResponse,
LockCommandRequest, LockCommandRequest,
LockStateResponse, LockStateResponse,
MediaPlayerCommandRequest, MediaPlayerCommandRequest,
@ -107,6 +111,8 @@ from .api_pb2 import ( # type: ignore
TimeCommandRequest, TimeCommandRequest,
TimeStateResponse, TimeStateResponse,
UnsubscribeBluetoothLEAdvertisementsRequest, UnsubscribeBluetoothLEAdvertisementsRequest,
ValveCommandRequest,
ValveStateResponse,
VoiceAssistantAudio, VoiceAssistantAudio,
VoiceAssistantEventResponse, VoiceAssistantEventResponse,
VoiceAssistantRequest, VoiceAssistantRequest,
@ -368,4 +374,10 @@ MESSAGE_TYPE_TO_PROTO = {
104: TimeStateResponse, 104: TimeStateResponse,
105: TimeCommandRequest, 105: TimeCommandRequest,
106: VoiceAssistantAudio, 106: VoiceAssistantAudio,
109: ListEntitiesValveResponse,
110: ValveStateResponse,
111: ValveCommandRequest,
112: ListEntitiesDateTimeResponse,
113: DateTimeStateResponse,
114: DateTimeCommandRequest,
} }

View File

@ -690,6 +690,18 @@ class TimeState(EntityState):
second: int = 0 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 ==================== # ==================== SELECT ====================
@_frozen_dataclass_decorator @_frozen_dataclass_decorator
class SelectInfo(EntityInfo): class SelectInfo(EntityInfo):
@ -753,6 +765,31 @@ class LockEntityState(EntityState):
) )
# ==================== VALVE ====================
@_frozen_dataclass_decorator
class ValveInfo(EntityInfo):
device_class: str = ""
assumed_state: bool = False
supports_stop: bool = False
supports_position: bool = False
class ValveOperation(APIIntEnum):
IDLE = 0
IS_OPENING = 1
IS_CLOSING = 2
@_frozen_dataclass_decorator
class ValveState(EntityState):
position: float = converter_field(
default=0.0, converter=fix_float_single_double_conversion
)
current_operation: ValveOperation | None = converter_field(
default=ValveOperation.IDLE, converter=ValveOperation.convert
)
# ==================== MEDIA PLAYER ==================== # ==================== MEDIA PLAYER ====================
class MediaPlayerState(APIIntEnum): class MediaPlayerState(APIIntEnum):
NONE = 0 NONE = 0
@ -860,6 +897,7 @@ COMPONENT_TYPE_TO_INFO: dict[str, type[EntityInfo]] = {
"climate": ClimateInfo, "climate": ClimateInfo,
"number": NumberInfo, "number": NumberInfo,
"date": DateInfo, "date": DateInfo,
"datetime": DateTimeInfo,
"select": SelectInfo, "select": SelectInfo,
"siren": SirenInfo, "siren": SirenInfo,
"button": ButtonInfo, "button": ButtonInfo,
@ -868,6 +906,7 @@ COMPONENT_TYPE_TO_INFO: dict[str, type[EntityInfo]] = {
"alarm_control_panel": AlarmControlPanelInfo, "alarm_control_panel": AlarmControlPanelInfo,
"text": TextInfo, "text": TextInfo,
"time": TimeInfo, "time": TimeInfo,
"valve": ValveInfo,
} }
@ -1216,6 +1255,7 @@ _TYPE_TO_NAME = {
LightInfo: "light", LightInfo: "light",
NumberInfo: "number", NumberInfo: "number",
DateInfo: "date", DateInfo: "date",
DateTimeInfo: "datetime",
SelectInfo: "select", SelectInfo: "select",
SensorInfo: "sensor", SensorInfo: "sensor",
SirenInfo: "siren", SirenInfo: "siren",
@ -1228,6 +1268,7 @@ _TYPE_TO_NAME = {
AlarmControlPanelInfo: "alarm_control_panel", AlarmControlPanelInfo: "alarm_control_panel",
TextInfo: "text_info", TextInfo: "text_info",
TimeInfo: "time", TimeInfo: "time",
ValveInfo: "valve",
} }

View File

@ -8,6 +8,7 @@ from .api_pb2 import ( # type: ignore
ClimateStateResponse, ClimateStateResponse,
CoverStateResponse, CoverStateResponse,
DateStateResponse, DateStateResponse,
DateTimeStateResponse,
FanStateResponse, FanStateResponse,
LightStateResponse, LightStateResponse,
ListEntitiesAlarmControlPanelResponse, ListEntitiesAlarmControlPanelResponse,
@ -17,6 +18,7 @@ from .api_pb2 import ( # type: ignore
ListEntitiesClimateResponse, ListEntitiesClimateResponse,
ListEntitiesCoverResponse, ListEntitiesCoverResponse,
ListEntitiesDateResponse, ListEntitiesDateResponse,
ListEntitiesDateTimeResponse,
ListEntitiesFanResponse, ListEntitiesFanResponse,
ListEntitiesLightResponse, ListEntitiesLightResponse,
ListEntitiesLockResponse, ListEntitiesLockResponse,
@ -30,6 +32,7 @@ from .api_pb2 import ( # type: ignore
ListEntitiesTextResponse, ListEntitiesTextResponse,
ListEntitiesTextSensorResponse, ListEntitiesTextSensorResponse,
ListEntitiesTimeResponse, ListEntitiesTimeResponse,
ListEntitiesValveResponse,
LockStateResponse, LockStateResponse,
MediaPlayerStateResponse, MediaPlayerStateResponse,
NumberStateResponse, NumberStateResponse,
@ -40,6 +43,7 @@ from .api_pb2 import ( # type: ignore
TextSensorStateResponse, TextSensorStateResponse,
TextStateResponse, TextStateResponse,
TimeStateResponse, TimeStateResponse,
ValveStateResponse,
) )
from .model import ( from .model import (
AlarmControlPanelEntityState, AlarmControlPanelEntityState,
@ -54,6 +58,8 @@ from .model import (
CoverState, CoverState,
DateInfo, DateInfo,
DateState, DateState,
DateTimeInfo,
DateTimeState,
EntityInfo, EntityInfo,
EntityState, EntityState,
FanInfo, FanInfo,
@ -80,6 +86,8 @@ from .model import (
TextState, TextState,
TimeInfo, TimeInfo,
TimeState, TimeState,
ValveInfo,
ValveState,
) )
SUBSCRIBE_STATES_RESPONSE_TYPES: dict[Any, type[EntityState]] = { SUBSCRIBE_STATES_RESPONSE_TYPES: dict[Any, type[EntityState]] = {
@ -89,6 +97,7 @@ SUBSCRIBE_STATES_RESPONSE_TYPES: dict[Any, type[EntityState]] = {
LightStateResponse: LightState, LightStateResponse: LightState,
NumberStateResponse: NumberState, NumberStateResponse: NumberState,
DateStateResponse: DateState, DateStateResponse: DateState,
DateTimeStateResponse: DateTimeState,
SelectStateResponse: SelectState, SelectStateResponse: SelectState,
SensorStateResponse: SensorState, SensorStateResponse: SensorState,
SirenStateResponse: SirenState, SirenStateResponse: SirenState,
@ -100,6 +109,7 @@ SUBSCRIBE_STATES_RESPONSE_TYPES: dict[Any, type[EntityState]] = {
MediaPlayerStateResponse: MediaPlayerEntityState, MediaPlayerStateResponse: MediaPlayerEntityState,
AlarmControlPanelStateResponse: AlarmControlPanelEntityState, AlarmControlPanelStateResponse: AlarmControlPanelEntityState,
TimeStateResponse: TimeState, TimeStateResponse: TimeState,
ValveStateResponse: ValveState,
} }
LIST_ENTITIES_SERVICES_RESPONSE_TYPES: dict[Any, type[EntityInfo] | None] = { LIST_ENTITIES_SERVICES_RESPONSE_TYPES: dict[Any, type[EntityInfo] | None] = {
@ -110,6 +120,7 @@ LIST_ENTITIES_SERVICES_RESPONSE_TYPES: dict[Any, type[EntityInfo] | None] = {
ListEntitiesLightResponse: LightInfo, ListEntitiesLightResponse: LightInfo,
ListEntitiesNumberResponse: NumberInfo, ListEntitiesNumberResponse: NumberInfo,
ListEntitiesDateResponse: DateInfo, ListEntitiesDateResponse: DateInfo,
ListEntitiesDateTimeResponse: DateTimeInfo,
ListEntitiesSelectResponse: SelectInfo, ListEntitiesSelectResponse: SelectInfo,
ListEntitiesSensorResponse: SensorInfo, ListEntitiesSensorResponse: SensorInfo,
ListEntitiesSirenResponse: SirenInfo, ListEntitiesSirenResponse: SirenInfo,
@ -123,4 +134,5 @@ LIST_ENTITIES_SERVICES_RESPONSE_TYPES: dict[Any, type[EntityInfo] | None] = {
ListEntitiesMediaPlayerResponse: MediaPlayerInfo, ListEntitiesMediaPlayerResponse: MediaPlayerInfo,
ListEntitiesAlarmControlPanelResponse: AlarmControlPanelInfo, ListEntitiesAlarmControlPanelResponse: AlarmControlPanelInfo,
ListEntitiesTimeResponse: TimeInfo, ListEntitiesTimeResponse: TimeInfo,
ListEntitiesValveResponse: ValveInfo,
} }

View File

@ -413,16 +413,11 @@ class ReconnectLogic(zeroconf.RecordUpdateListener):
self._cli.log_name, self._cli.log_name,
record_update.new, 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 # If we scheduled the connect attempt immediately, the listener could fire
# again before the connect attempt and we cancel and reschedule the connect # again before the connect attempt and we cancel and reschedule the connect
# attempt again. # attempt again.
# #
self.loop.call_soon(self._connect_from_zeroconf) self._connect_from_zeroconf()
self._accept_zeroconf_records = False self._accept_zeroconf_records = False
return return

View File

@ -1,7 +1,7 @@
aiohappyeyeballs>=2.3.0 aiohappyeyeballs>=2.3.0
async-interrupt>=1.1.1 async-interrupt>=1.1.1
protobuf>=3.19.0 protobuf>=3.19.0
zeroconf>=0.128.4,<1.0 zeroconf>=0.132.2,<1.0
chacha20poly1305-reuseable>=0.12.1 chacha20poly1305-reuseable>=0.12.1
cryptography>=42.0.2 cryptography>=42.0.2
noiseprotocol>=0.3.1,<1.0 noiseprotocol>=0.3.1,<1.0

View File

@ -3,7 +3,7 @@ black==24.4.0
flake8==7.0.0 flake8==7.0.0
isort==5.13.2 isort==5.13.2
mypy==1.9.0 mypy==1.9.0
types-protobuf==4.25.0.20240410 types-protobuf==4.25.0.20240417
pytest>=6.2.4,<9 pytest>=6.2.4,<9
pytest-asyncio==0.23.6 pytest-asyncio==0.23.6
mock>=4.0.3,<6 mock>=4.0.3,<6

View File

@ -11,7 +11,7 @@ with open(os.path.join(here, "README.rst"), encoding="utf-8") as readme_file:
long_description = readme_file.read() long_description = readme_file.read()
VERSION = "24.0.1" VERSION = "24.2.0"
PROJECT_NAME = "aioesphomeapi" PROJECT_NAME = "aioesphomeapi"
PROJECT_PACKAGE_NAME = "aioesphomeapi" PROJECT_PACKAGE_NAME = "aioesphomeapi"
PROJECT_LICENSE = "MIT" PROJECT_LICENSE = "MIT"

View File

@ -42,6 +42,7 @@ from aioesphomeapi.api_pb2 import (
ClimateCommandRequest, ClimateCommandRequest,
CoverCommandRequest, CoverCommandRequest,
DateCommandRequest, DateCommandRequest,
DateTimeCommandRequest,
DeviceInfoResponse, DeviceInfoResponse,
DisconnectResponse, DisconnectResponse,
ExecuteServiceArgument, ExecuteServiceArgument,
@ -64,6 +65,7 @@ from aioesphomeapi.api_pb2 import (
SwitchCommandRequest, SwitchCommandRequest,
TextCommandRequest, TextCommandRequest,
TimeCommandRequest, TimeCommandRequest,
ValveCommandRequest,
VoiceAssistantAudio, VoiceAssistantAudio,
VoiceAssistantAudioSettings, VoiceAssistantAudioSettings,
VoiceAssistantEventData, VoiceAssistantEventData,
@ -667,6 +669,30 @@ async def test_time_command(
send.assert_called_once_with(TimeCommandRequest(**req)) 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.asyncio
@pytest.mark.parametrize( @pytest.mark.parametrize(
"cmd, req", "cmd, req",
@ -692,6 +718,49 @@ async def test_lock_command(
send.assert_called_once_with(LockCommandRequest(**req)) send.assert_called_once_with(LockCommandRequest(**req))
@pytest.mark.asyncio
@pytest.mark.parametrize(
"cmd, req",
[
(dict(key=1), dict(key=1)),
(dict(key=1, position=1.0),),
(dict(key=1, position=0.0),),
(dict(key=1, stop=True),),
],
)
async def test_valve_command(
auth_client: APIClient, cmd: dict[str, Any], req: dict[str, Any]
) -> None:
send = patch_send(auth_client)
auth_client.valve_command(**cmd)
send.assert_called_once_with(ValveCommandRequest(**req))
@pytest.mark.asyncio
@pytest.mark.parametrize(
"cmd, req",
[
(dict(key=1), dict(key=1)),
(dict(key=1, position=0.5), dict(key=1, has_position=True, position=0.5)),
(dict(key=1, position=0.0), dict(key=1, has_position=True, position=0.0)),
(dict(key=1, stop=True), dict(key=1, stop=True)),
(
dict(key=1, position=1.0),
dict(key=1, has_position=True, position=1.0),
),
],
)
async def test_valve_command(
auth_client: APIClient, cmd: dict[str, Any], req: dict[str, Any]
) -> None:
send = patch_send(auth_client)
patch_api_version(auth_client, APIVersion(1, 1))
auth_client.valve_command(**cmd)
send.assert_called_once_with(ValveCommandRequest(**req))
@pytest.mark.asyncio @pytest.mark.asyncio
@pytest.mark.parametrize( @pytest.mark.parametrize(
"cmd, req", "cmd, req",
@ -2443,6 +2512,7 @@ async def test_calls_after_connection_closed(
client.cover_command, client.cover_command,
client.fan_command, client.fan_command,
client.light_command, client.light_command,
client.valve_command,
client.media_player_command, client.media_player_command,
client.siren_command, client.siren_command,
): ):

View File

@ -14,6 +14,7 @@ from aioesphomeapi.api_pb2 import (
ClimateStateResponse, ClimateStateResponse,
CoverStateResponse, CoverStateResponse,
DateStateResponse, DateStateResponse,
DateTimeStateResponse,
DeviceInfoResponse, DeviceInfoResponse,
FanStateResponse, FanStateResponse,
HomeassistantServiceMap, HomeassistantServiceMap,
@ -25,6 +26,7 @@ from aioesphomeapi.api_pb2 import (
ListEntitiesClimateResponse, ListEntitiesClimateResponse,
ListEntitiesCoverResponse, ListEntitiesCoverResponse,
ListEntitiesDateResponse, ListEntitiesDateResponse,
ListEntitiesDateTimeResponse,
ListEntitiesFanResponse, ListEntitiesFanResponse,
ListEntitiesLightResponse, ListEntitiesLightResponse,
ListEntitiesLockResponse, ListEntitiesLockResponse,
@ -37,6 +39,7 @@ from aioesphomeapi.api_pb2 import (
ListEntitiesSwitchResponse, ListEntitiesSwitchResponse,
ListEntitiesTextSensorResponse, ListEntitiesTextSensorResponse,
ListEntitiesTimeResponse, ListEntitiesTimeResponse,
ListEntitiesValveResponse,
LockStateResponse, LockStateResponse,
MediaPlayerStateResponse, MediaPlayerStateResponse,
NumberStateResponse, NumberStateResponse,
@ -47,6 +50,7 @@ from aioesphomeapi.api_pb2 import (
TextSensorStateResponse, TextSensorStateResponse,
TextStateResponse, TextStateResponse,
TimeStateResponse, TimeStateResponse,
ValveStateResponse,
) )
from aioesphomeapi.model import ( from aioesphomeapi.model import (
_TYPE_TO_NAME, _TYPE_TO_NAME,
@ -75,6 +79,8 @@ from aioesphomeapi.model import (
CoverState, CoverState,
DateInfo, DateInfo,
DateState, DateState,
DateTimeInfo,
DateTimeState,
DeviceInfo, DeviceInfo,
FanInfo, FanInfo,
FanState, FanState,
@ -105,6 +111,8 @@ from aioesphomeapi.model import (
UserService, UserService,
UserServiceArg, UserServiceArg,
UserServiceArgType, UserServiceArgType,
ValveInfo,
ValveState,
VoiceAssistantFeature, VoiceAssistantFeature,
build_unique_id, build_unique_id,
converter_field, converter_field,
@ -261,6 +269,8 @@ def test_api_version_ord():
(ButtonInfo, ListEntitiesButtonResponse), (ButtonInfo, ListEntitiesButtonResponse),
(LockInfo, ListEntitiesLockResponse), (LockInfo, ListEntitiesLockResponse),
(LockEntityState, LockStateResponse), (LockEntityState, LockStateResponse),
(ValveInfo, ListEntitiesValveResponse),
(ValveState, ValveStateResponse),
(MediaPlayerInfo, ListEntitiesMediaPlayerResponse), (MediaPlayerInfo, ListEntitiesMediaPlayerResponse),
(MediaPlayerEntityState, MediaPlayerStateResponse), (MediaPlayerEntityState, MediaPlayerStateResponse),
(AlarmControlPanelInfo, ListEntitiesAlarmControlPanelResponse), (AlarmControlPanelInfo, ListEntitiesAlarmControlPanelResponse),
@ -268,6 +278,8 @@ def test_api_version_ord():
(TextState, TextStateResponse), (TextState, TextStateResponse),
(TimeInfo, ListEntitiesTimeResponse), (TimeInfo, ListEntitiesTimeResponse),
(TimeState, TimeStateResponse), (TimeState, TimeStateResponse),
(DateTimeInfo, ListEntitiesDateTimeResponse),
(DateTimeState, DateTimeStateResponse),
], ],
) )
def test_basic_pb_conversions(model, pb): def test_basic_pb_conversions(model, pb):
@ -380,6 +392,7 @@ def test_user_service_conversion():
CameraInfo, CameraInfo,
ClimateInfo, ClimateInfo,
LockInfo, LockInfo,
ValveInfo,
MediaPlayerInfo, MediaPlayerInfo,
AlarmControlPanelInfo, AlarmControlPanelInfo,
TextInfo, TextInfo,

View File

@ -441,8 +441,6 @@ async def test_reconnect_zeroconf(
"Triggering connect because of received mDNS record" in caplog.text "Triggering connect because of received mDNS record" in caplog.text
) is should_trigger_zeroconf ) is should_trigger_zeroconf
assert rl._accept_zeroconf_records is not 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 assert rl._zc_listening is not should_trigger_zeroconf
# The reconnect is scheduled to run in the next loop iteration # The reconnect is scheduled to run in the next loop iteration