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_summary = 9;
string release_url = 10; string release_url = 10;
} }
enum UpdateCommand {
UPDATE_COMMAND_NONE = 0;
UPDATE_COMMAND_UPDATE = 1;
UPDATE_COMMAND_CHECK = 2;
}
message UpdateCommandRequest { message UpdateCommandRequest {
option (id) = 118; option (id) = 118;
option (source) = SOURCE_CLIENT; option (source) = SOURCE_CLIENT;
@ -1897,5 +1902,5 @@ message UpdateCommandRequest {
option (no_delay) = true; option (no_delay) = true;
fixed32 key = 1; 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, LockCommand,
LogLevel, LogLevel,
MediaPlayerCommand, MediaPlayerCommand,
UpdateCommand,
UserService, UserService,
UserServiceArgType, UserServiceArgType,
VoiceAssistantAudioData, VoiceAssistantAudioData,
@ -1212,9 +1213,9 @@ class APIClient:
def text_command(self, key: int, state: str) -> None: def text_command(self, key: int, state: str) -> None:
self._get_connection().send_message(TextCommandRequest(key=key, state=state)) 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( self._get_connection().send_message(
UpdateCommandRequest(key=key, install=install) UpdateCommandRequest(key=key, command=command)
) )
def execute_service( def execute_service(

View File

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

View File

@ -89,9 +89,6 @@ from aioesphomeapi.model import (
BinarySensorInfo, BinarySensorInfo,
BinarySensorState, BinarySensorState,
BluetoothDeviceRequestType, BluetoothDeviceRequestType,
)
from aioesphomeapi.model import BluetoothGATTService as BluetoothGATTServiceModel
from aioesphomeapi.model import (
BluetoothLEAdvertisement, BluetoothLEAdvertisement,
BluetoothProxyFeature, BluetoothProxyFeature,
CameraState, CameraState,
@ -107,10 +104,12 @@ from aioesphomeapi.model import (
LightColorCapability, LightColorCapability,
LockCommand, LockCommand,
MediaPlayerCommand, MediaPlayerCommand,
UpdateCommand,
UserService, UserService,
UserServiceArg, UserServiceArg,
UserServiceArgType, UserServiceArgType,
) )
from aioesphomeapi.model import BluetoothGATTService as BluetoothGATTServiceModel
from aioesphomeapi.model import ( from aioesphomeapi.model import (
VoiceAssistantAudioSettings as VoiceAssistantAudioSettingsModel, VoiceAssistantAudioSettings as VoiceAssistantAudioSettingsModel,
) )
@ -1036,8 +1035,14 @@ async def test_text_command(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"cmd, req", "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( async def test_update_command(