Compare commits

...

7 Commits

Author SHA1 Message Date
dependabot[bot] ebfdedff9d
Merge 88a8191545 into ab390acf93 2024-04-23 14:44:24 +12:00
dependabot[bot] ab390acf93
Bump types-protobuf from 4.25.0.20240417 to 5.26.0.20240422 (#865)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-23 14:44:20 +12:00
github-actions[bot] 1c4d7a60bb Bump version to 24.3.0 2024-04-22 10:48:36 +00:00
David Friedland f1538a7ed0
Support for Event entity messages (#853)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2024-04-22 22:48:21 +12:00
github-actions[bot] e88f1468cb Bump version to 24.2.1 2024-04-22 05:04:53 +00:00
Jesse Hills 397c64f3e3
Alphabetise model_conversions.py (#864) 2024-04-22 17:04:38 +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
9 changed files with 170 additions and 89 deletions

View File

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

View File

@ -1721,6 +1721,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;

File diff suppressed because one or more lines are too long

View File

@ -46,6 +46,7 @@ from .api_pb2 import ( # type: ignore
DeviceInfoResponse,
DisconnectRequest,
DisconnectResponse,
EventResponse,
ExecuteServiceRequest,
FanCommandRequest,
FanStateResponse,
@ -66,6 +67,7 @@ from .api_pb2 import ( # type: ignore
ListEntitiesDateResponse,
ListEntitiesDateTimeResponse,
ListEntitiesDoneResponse,
ListEntitiesEventResponse,
ListEntitiesFanResponse,
ListEntitiesLightResponse,
ListEntitiesLockResponse,
@ -374,6 +376,8 @@ MESSAGE_TYPE_TO_PROTO = {
104: TimeStateResponse,
105: TimeCommandRequest,
106: VoiceAssistantAudio,
107: ListEntitiesEventResponse,
108: EventResponse,
109: ListEntitiesValveResponse,
110: ValveStateResponse,
111: ValveCommandRequest,

View File

@ -262,6 +262,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):
@ -907,6 +919,7 @@ COMPONENT_TYPE_TO_INFO: dict[str, type[EntityInfo]] = {
"text": TextInfo,
"time": TimeInfo,
"valve": ValveInfo,
"event": EventInfo,
}
@ -1269,6 +1282,7 @@ _TYPE_TO_NAME = {
TextInfo: "text_info",
TimeInfo: "time",
ValveInfo: "valve",
EventInfo: "event",
}

View File

@ -9,6 +9,7 @@ from .api_pb2 import ( # type: ignore
CoverStateResponse,
DateStateResponse,
DateTimeStateResponse,
EventResponse,
FanStateResponse,
LightStateResponse,
ListEntitiesAlarmControlPanelResponse,
@ -19,6 +20,7 @@ from .api_pb2 import ( # type: ignore
ListEntitiesCoverResponse,
ListEntitiesDateResponse,
ListEntitiesDateTimeResponse,
ListEntitiesEventResponse,
ListEntitiesFanResponse,
ListEntitiesLightResponse,
ListEntitiesLockResponse,
@ -62,6 +64,8 @@ from .model import (
DateTimeState,
EntityInfo,
EntityState,
Event,
EventInfo,
FanInfo,
FanState,
LightInfo,
@ -91,48 +95,50 @@ from .model import (
)
SUBSCRIBE_STATES_RESPONSE_TYPES: dict[Any, type[EntityState]] = {
AlarmControlPanelStateResponse: AlarmControlPanelEntityState,
BinarySensorStateResponse: BinarySensorState,
ClimateStateResponse: ClimateState,
CoverStateResponse: CoverState,
FanStateResponse: FanState,
LightStateResponse: LightState,
NumberStateResponse: NumberState,
DateStateResponse: DateState,
DateTimeStateResponse: DateTimeState,
EventResponse: Event,
FanStateResponse: FanState,
LightStateResponse: LightState,
LockStateResponse: LockEntityState,
MediaPlayerStateResponse: MediaPlayerEntityState,
NumberStateResponse: NumberState,
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,
ListEntitiesFanResponse: FanInfo,
ListEntitiesLightResponse: LightInfo,
ListEntitiesNumberResponse: NumberInfo,
ListEntitiesDateResponse: DateInfo,
ListEntitiesDateTimeResponse: DateTimeInfo,
ListEntitiesEventResponse: EventInfo,
ListEntitiesFanResponse: FanInfo,
ListEntitiesLightResponse: LightInfo,
ListEntitiesLockResponse: LockInfo,
ListEntitiesMediaPlayerResponse: MediaPlayerInfo,
ListEntitiesNumberResponse: NumberInfo,
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,
}

View File

@ -3,7 +3,7 @@ black==24.4.0
flake8==7.0.0
isort==5.13.2
mypy==1.9.0
types-protobuf==4.25.0.20240417
types-protobuf==5.26.0.20240422
pytest>=6.2.4,<9
pytest-asyncio==0.23.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()
VERSION = "24.2.0"
VERSION = "24.3.0"
PROJECT_NAME = "aioesphomeapi"
PROJECT_PACKAGE_NAME = "aioesphomeapi"
PROJECT_LICENSE = "MIT"

View File

@ -16,6 +16,7 @@ from aioesphomeapi.api_pb2 import (
DateStateResponse,
DateTimeStateResponse,
DeviceInfoResponse,
EventResponse,
FanStateResponse,
HomeassistantServiceMap,
HomeassistantServiceResponse,
@ -27,6 +28,7 @@ from aioesphomeapi.api_pb2 import (
ListEntitiesCoverResponse,
ListEntitiesDateResponse,
ListEntitiesDateTimeResponse,
ListEntitiesEventResponse,
ListEntitiesFanResponse,
ListEntitiesLightResponse,
ListEntitiesLockResponse,
@ -82,6 +84,8 @@ from aioesphomeapi.model import (
DateTimeInfo,
DateTimeState,
DeviceInfo,
Event,
EventInfo,
FanInfo,
FanState,
HomeassistantServiceCall,
@ -280,6 +284,8 @@ def test_api_version_ord():
(TimeState, TimeStateResponse),
(DateTimeInfo, ListEntitiesDateTimeResponse),
(DateTimeState, DateTimeStateResponse),
(EventInfo, ListEntitiesEventResponse),
(Event, EventResponse),
],
)
def test_basic_pb_conversions(model, pb):