Support asking device to check for updates (#914)

This commit is contained in:
Jesse Hills 2024-08-05 14:30:13 +12:00 committed by GitHub
parent a0b87778b8
commit 79571d2b8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 92 additions and 68 deletions

View File

@ -1890,6 +1890,11 @@ message UpdateStateResponse {
string release_summary = 9;
string release_url = 10;
}
enum UpdateCommand {
UPDATE_COMMAND_NONE = 0;
UPDATE_COMMAND_UPDATE = 1;
UPDATE_COMMAND_CHECK = 2;
}
message UpdateCommandRequest {
option (id) = 118;
option (source) = SOURCE_CLIENT;
@ -1897,5 +1902,5 @@ message UpdateCommandRequest {
option (no_delay) = true;
fixed32 key = 1;
bool install = 2;
UpdateCommand command = 2;
}

File diff suppressed because one or more lines are too long

View File

@ -124,6 +124,7 @@ from .model import (
LockCommand,
LogLevel,
MediaPlayerCommand,
UpdateCommand,
UserService,
UserServiceArgType,
VoiceAssistantAudioData,
@ -1212,9 +1213,9 @@ class APIClient:
def text_command(self, key: int, state: str) -> None:
self._get_connection().send_message(TextCommandRequest(key=key, state=state))
def update_command(self, key: int, install: bool) -> None:
def update_command(self, key: int, command: UpdateCommand) -> None:
self._get_connection().send_message(
UpdateCommandRequest(key=key, install=install)
UpdateCommandRequest(key=key, command=command)
)
def execute_service(

View File

@ -900,6 +900,12 @@ class TextState(EntityState):
# ==================== UPDATE ====================
class UpdateCommand(APIIntEnum):
NONE = 0
INSTALL = 1
CHECK = 2
@_frozen_dataclass_decorator
class UpdateInfo(EntityInfo):
device_class: str = ""

View File

@ -89,9 +89,6 @@ from aioesphomeapi.model import (
BinarySensorInfo,
BinarySensorState,
BluetoothDeviceRequestType,
)
from aioesphomeapi.model import BluetoothGATTService as BluetoothGATTServiceModel
from aioesphomeapi.model import (
BluetoothLEAdvertisement,
BluetoothProxyFeature,
CameraState,
@ -107,10 +104,12 @@ from aioesphomeapi.model import (
LightColorCapability,
LockCommand,
MediaPlayerCommand,
UpdateCommand,
UserService,
UserServiceArg,
UserServiceArgType,
)
from aioesphomeapi.model import BluetoothGATTService as BluetoothGATTServiceModel
from aioesphomeapi.model import (
VoiceAssistantAudioSettings as VoiceAssistantAudioSettingsModel,
)
@ -1036,8 +1035,14 @@ async def test_text_command(
@pytest.mark.parametrize(
"cmd, req",
[
(dict(key=1, install=True), dict(key=1, install=True)),
(dict(key=1, install=False), dict(key=1, install=False)),
(
dict(key=1, command=UpdateCommand.INSTALL),
dict(key=1, command=UpdateCommand.INSTALL),
),
(
dict(key=1, command=UpdateCommand.CHECK),
dict(key=1, command=UpdateCommand.CHECK),
),
],
)
async def test_update_command(