Skip to content

[API] Sub devices and areas #1146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Jun 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1d39bf8
Start by adding the equvalent proto changes
dala318 Apr 9, 2025
c538291
Add model converter
dala318 Apr 9, 2025
d18cce9
Fix ruff
dala318 Apr 9, 2025
2b497be
An attempt at tests
dala318 Apr 10, 2025
f315f68
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 10, 2025
37b5f8b
Fix formatting in CI action
dala318 Apr 10, 2025
159efc0
Try fixing tests
dala318 Apr 10, 2025
cdcac47
Merge remote-tracking branch 'upstream/main' into multi_device
dala318 Apr 24, 2025
70623a1
Enable the reset of entities
dala318 Apr 24, 2025
dcdb36c
Update generated files
dala318 Apr 24, 2025
5f8374b
Merge pull request #2 from dala318/mult_device_2
dala318 Apr 24, 2025
ffd3a8a
Merge branch 'main' into multi_device
dala318 May 6, 2025
815ca43
Change id:str to uid:uint32
dala318 May 6, 2025
c67a390
Show diff and archive generated files in case of chnages
dala318 May 6, 2025
3b49d5c
Update all entidy models
dala318 May 6, 2025
cdc6f40
Adapt test
dala318 May 6, 2025
a177efd
Fix indenting in proto-file
dala318 May 6, 2025
c7b5044
Revert "Show diff and archive generated files in case of chnages"
dala318 May 6, 2025
f0b8eb4
Reorder tests to get result from codegen
dala318 May 6, 2025
3c68c63
Re-activate archiving
dala318 May 6, 2025
a10ed51
Add new generated files
dala318 May 6, 2025
4cff3c0
Clean up ci-test
dala318 May 6, 2025
54f31dc
Merge branch 'main' into multi_device
dala318 May 26, 2025
dc6c005
Generate proto after merge
dala318 May 26, 2025
037acf4
Show and archive generated proto-files if diff
dala318 May 26, 2025
39f9206
Revert CI changes and add to own PR
dala318 May 26, 2025
641992f
Merge branch 'main' into ci_proto
bdraco Jun 8, 2025
22529ab
Merge branch 'main' into multi_device
bdraco Jun 8, 2025
6e8625a
Merge remote-tracking branch 'origin/main' into multi_device
bdraco Jun 22, 2025
9d76082
merge
bdraco Jun 22, 2025
fb7167c
merge
bdraco Jun 22, 2025
e7c321f
updates
bdraco Jun 22, 2025
9d0435f
Merge branch 'main' into multi_device
bdraco Jun 22, 2025
f67bc28
Merge branch 'ci_proto' of https://github.com/dala318/aioesphomeapi i…
bdraco Jun 22, 2025
0e66e85
cover
bdraco Jun 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions aioesphomeapi/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,17 @@ message DeviceInfoRequest {
// Empty
}

message AreaInfo {
uint32 area_id = 1;
string name = 2;
}

message DeviceInfo {
uint32 device_id = 1;
string name = 2;
uint32 area_id = 3;
}

message DeviceInfoResponse {
option (id) = 10;
option (source) = SOURCE_SERVER;
Expand Down Expand Up @@ -236,6 +247,12 @@ message DeviceInfoResponse {

// Supports receiving and saving api encryption key
bool api_encryption_supported = 19;

repeated DeviceInfo devices = 20;
repeated AreaInfo areas = 21;

// Top-level area info to phase out suggested_area
AreaInfo area = 22;
}

message ListEntitiesRequest {
Expand Down Expand Up @@ -280,6 +297,7 @@ message ListEntitiesBinarySensorResponse {
bool disabled_by_default = 7;
string icon = 8;
EntityCategory entity_category = 9;
uint32 device_id = 10;
}
message BinarySensorStateResponse {
option (id) = 21;
Expand Down Expand Up @@ -315,6 +333,7 @@ message ListEntitiesCoverResponse {
string icon = 10;
EntityCategory entity_category = 11;
bool supports_stop = 12;
uint32 device_id = 13;
}

enum LegacyCoverState {
Expand Down Expand Up @@ -388,6 +407,7 @@ message ListEntitiesFanResponse {
string icon = 10;
EntityCategory entity_category = 11;
repeated string supported_preset_modes = 12;
uint32 device_id = 13;
}
enum FanSpeed {
FAN_SPEED_LOW = 0;
Expand Down Expand Up @@ -471,6 +491,7 @@ message ListEntitiesLightResponse {
bool disabled_by_default = 13;
string icon = 14;
EntityCategory entity_category = 15;
uint32 device_id = 16;
}
message LightStateResponse {
option (id) = 24;
Expand Down Expand Up @@ -563,6 +584,7 @@ message ListEntitiesSensorResponse {
SensorLastResetType legacy_last_reset_type = 11;
bool disabled_by_default = 12;
EntityCategory entity_category = 13;
uint32 device_id = 14;
}
message SensorStateResponse {
option (id) = 25;
Expand Down Expand Up @@ -595,6 +617,7 @@ message ListEntitiesSwitchResponse {
bool disabled_by_default = 7;
EntityCategory entity_category = 8;
string device_class = 9;
uint32 device_id = 10;
}
message SwitchStateResponse {
option (id) = 26;
Expand Down Expand Up @@ -632,6 +655,7 @@ message ListEntitiesTextSensorResponse {
bool disabled_by_default = 6;
EntityCategory entity_category = 7;
string device_class = 8;
uint32 device_id = 9;
}
message TextSensorStateResponse {
option (id) = 27;
Expand Down Expand Up @@ -814,6 +838,7 @@ message ListEntitiesCameraResponse {
bool disabled_by_default = 5;
string icon = 6;
EntityCategory entity_category = 7;
uint32 device_id = 8;
}

message CameraImageResponse {
Expand Down Expand Up @@ -916,6 +941,7 @@ message ListEntitiesClimateResponse {
bool supports_target_humidity = 23;
float visual_min_humidity = 24;
float visual_max_humidity = 25;
uint32 device_id = 26;
}
message ClimateStateResponse {
option (id) = 47;
Expand Down Expand Up @@ -999,6 +1025,7 @@ message ListEntitiesNumberResponse {
string unit_of_measurement = 11;
NumberMode mode = 12;
string device_class = 13;
uint32 device_id = 14;
}
message NumberStateResponse {
option (id) = 50;
Expand Down Expand Up @@ -1039,6 +1066,7 @@ message ListEntitiesSelectResponse {
repeated string options = 6;
bool disabled_by_default = 7;
EntityCategory entity_category = 8;
uint32 device_id = 9;
}
message SelectStateResponse {
option (id) = 53;
Expand Down Expand Up @@ -1081,6 +1109,7 @@ message ListEntitiesSirenResponse {
bool supports_duration = 8;
bool supports_volume = 9;
EntityCategory entity_category = 10;
uint32 device_id = 11;
}
message SirenStateResponse {
option (id) = 56;
Expand Down Expand Up @@ -1144,6 +1173,7 @@ message ListEntitiesLockResponse {

// Not yet implemented:
string code_format = 11;
uint32 device_id = 12;
}
message LockStateResponse {
option (id) = 59;
Expand Down Expand Up @@ -1183,6 +1213,7 @@ message ListEntitiesButtonResponse {
bool disabled_by_default = 6;
EntityCategory entity_category = 7;
string device_class = 8;
uint32 device_id = 9;
}
message ButtonCommandRequest {
option (id) = 62;
Expand Down Expand Up @@ -1238,6 +1269,8 @@ message ListEntitiesMediaPlayerResponse {
bool supports_pause = 8;

repeated MediaPlayerSupportedFormat supported_formats = 9;

uint32 device_id = 10;
}
message MediaPlayerStateResponse {
option (id) = 64;
Expand Down Expand Up @@ -1778,6 +1811,7 @@ message ListEntitiesAlarmControlPanelResponse {
uint32 supported_features = 8;
bool requires_code = 9;
bool requires_code_to_arm = 10;
uint32 device_id = 11;
}

message AlarmControlPanelStateResponse {
Expand Down Expand Up @@ -1823,6 +1857,7 @@ message ListEntitiesTextResponse {
uint32 max_length = 9;
string pattern = 10;
TextMode mode = 11;
uint32 device_id = 12;
}
message TextStateResponse {
option (id) = 98;
Expand Down Expand Up @@ -1863,6 +1898,7 @@ message ListEntitiesDateResponse {
string icon = 5;
bool disabled_by_default = 6;
EntityCategory entity_category = 7;
uint32 device_id = 8;
}
message DateStateResponse {
option (id) = 101;
Expand Down Expand Up @@ -1906,6 +1942,7 @@ message ListEntitiesTimeResponse {
string icon = 5;
bool disabled_by_default = 6;
EntityCategory entity_category = 7;
uint32 device_id = 8;
}
message TimeStateResponse {
option (id) = 104;
Expand Down Expand Up @@ -1952,6 +1989,7 @@ message ListEntitiesEventResponse {
string device_class = 8;

repeated string event_types = 9;
uint32 device_id = 10;
}
message EventResponse {
option (id) = 108;
Expand Down Expand Up @@ -1983,6 +2021,7 @@ message ListEntitiesValveResponse {
bool assumed_state = 9;
bool supports_position = 10;
bool supports_stop = 11;
uint32 device_id = 12;
}

enum ValveOperation {
Expand Down Expand Up @@ -2029,6 +2068,7 @@ message ListEntitiesDateTimeResponse {
string icon = 5;
bool disabled_by_default = 6;
EntityCategory entity_category = 7;
uint32 device_id = 8;
}
message DateTimeStateResponse {
option (id) = 113;
Expand Down Expand Up @@ -2069,6 +2109,7 @@ message ListEntitiesUpdateResponse {
bool disabled_by_default = 6;
EntityCategory entity_category = 7;
string device_class = 8;
uint32 device_id = 9;
}
message UpdateStateResponse {
option (id) = 117;
Expand Down
666 changes: 335 additions & 331 deletions aioesphomeapi/api_pb2.py

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions aioesphomeapi/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,39 @@ class VoiceAssistantSubscriptionFlag(enum.IntFlag):
API_AUDIO = 1 << 2


@_frozen_dataclass_decorator
class AreaInfo(APIModelBase):
area_id: int = 0
name: str = ""

@classmethod
def convert_list(cls, value: list[Any]) -> list[AreaInfo]:
ret = []
for x in value:
if isinstance(x, dict):
ret.append(AreaInfo.from_dict(x))
else:
ret.append(AreaInfo.from_pb(x))
return ret


@_frozen_dataclass_decorator
class SubDeviceInfo(APIModelBase):
device_id: int = 0
name: str = ""
area_id: int = 0

@classmethod
def convert_list(cls, value: list[Any]) -> list[SubDeviceInfo]:
ret = []
for x in value:
if isinstance(x, dict):
ret.append(SubDeviceInfo.from_dict(x))
else:
ret.append(SubDeviceInfo.from_pb(x))
return ret


@_frozen_dataclass_decorator
class DeviceInfo(APIModelBase):
uses_password: bool = False
Expand All @@ -154,6 +187,15 @@ class DeviceInfo(APIModelBase):
bluetooth_proxy_feature_flags: int = 0
suggested_area: str = ""
bluetooth_mac_address: str = ""
devices: list[SubDeviceInfo] = converter_field(
default_factory=list, converter=SubDeviceInfo.convert_list
)
areas: list[AreaInfo] = converter_field(
default_factory=list, converter=AreaInfo.convert_list
)
area: AreaInfo = converter_field(
default_factory=AreaInfo, converter=AreaInfo.from_pb
)

def bluetooth_proxy_feature_flags_compat(self, api_version: APIVersion) -> int:
if api_version < APIVersion(1, 9):
Expand Down Expand Up @@ -199,6 +241,7 @@ class EntityInfo(APIModelBase):
entity_category: EntityCategory | None = converter_field(
default=EntityCategory.NONE, converter=EntityCategory.convert
)
device_id: int = 0


@_frozen_dataclass_decorator
Expand Down
Loading