Skip to content

Comments

refactor: add named parameter support for events, provide websocket#49

Merged
zehnm merged 1 commit intomainfrom
refactor/event-params
Feb 18, 2026
Merged

refactor: add named parameter support for events, provide websocket#49
zehnm merged 1 commit intomainfrom
refactor/event-params

Conversation

@zehnm
Copy link
Contributor

@zehnm zehnm commented Feb 16, 2026

Provide the websocket handle in events. This allows the integration driver to send request messages to the Remote.
Furthermore, external integration driver can keep track of multiple Remote connections.
Event listeners are wrapped for compatibility: existing event handlers without parameters still work.

BREAKING CHANGE: client event handler using parameters must use the named parameter names.
This mainly affects SUBSCRIBE_ENTITIES and UNSUBSCRIBE_ENTITIES: the parameter must be named entity_ids.

An integration is free to choose which parameters are required. Example:

@api.listens_to(ucapi.Events.SUBSCRIBE_ENTITIES)
async def on_subscribe0() -> None:
    print("SUBSCRIBE_ENTITIES")


@api.listens_to(ucapi.Events.SUBSCRIBE_ENTITIES)
async def on_subscribe1(websocket) -> None:
    print("SUBSCRIBE_ENTITIES with websocket param only", websocket)


@api.listens_to(ucapi.Events.SUBSCRIBE_ENTITIES)
async def on_subscribe2(entity_ids) -> None:
    print("SUBSCRIBE_ENTITIES with entity_ids param only:", entity_ids)


@api.listens_to(ucapi.Events.SUBSCRIBE_ENTITIES)
async def on_subscribe(websocket, entity_ids) -> None:
    print("SUBSCRIBE_ENTITIES", entity_ids, websocket)

This change is required for PR #47

Provide the `websocket` handle in events. This allows the integration
driver to send request messages to the Remote.
Furthermore, external integration driver can keep track of multiple
Remote connections.
Event listeners are wrapped for compatibility: existing event handlers
without parameters still work.

BREAKING CHANGE: client event handler using parameters must use the
named parameter names. This mainly affects SUBSCRIBE_ENTITIES and
UNSUBSCRIBE_ENTITIES: the parameter must be named `entity_ids`.
@zehnm zehnm self-assigned this Feb 16, 2026
@zehnm zehnm merged commit 26dadcd into main Feb 18, 2026
12 checks passed
@zehnm zehnm deleted the refactor/event-params branch February 18, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant