Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues.
Description
After a Remote 3 wakes, its Anthem integration can receive exit_standby followed by an enter_standby carrying an older generation timestamp on the same integration WebSocket. The driver then disconnects, its entities become unavailable, and commands fail until the next wake. The receive order is logged before driver lifecycle callbacks run, so it is separate from any possible asynchronous callback completion race.
How to reproduce
-
Configure the Anthem integration and use the remote through standby and wake transitions. The exact timing needed to reproduce on the device is not yet known; this was captured during normal use.
-
Record the integration WebSocket messages and their receipt times. On 2026-11-15, the same local WebSocket connection received these exact envelopes in this order:
{"kind":"event","msg":"exit_standby","cat":"REMOTE","ts":"2026-11-15T20:54:01.502150585Z","msg_data":null} {"kind":"event","msg":"enter_standby","cat":"REMOTE","ts":"2026-11-15T20:54:01.477586247Z","msg_data":null} -
Observe the integration state and send an Anthem on command before another wake. In this capture the entities became unavailable and commands returned
500, with the driver reporting that it was not connected. A later wake initiated reconnection.
For a deterministic demonstration of the consequence, save the replay below as ufcircle-core-lifecycle-replay.py and run it. It sends the captured envelopes over a real loopback WebSocket to the Python integration library and uses synchronous lifecycle listeners and a simulated command handler. It does not reproduce the remote's event generation or Anthem's actual network behavior.
With Python 3.11 or newer and Git installed, set up the library at the tested revision and run the replay:
python3 -m venv .venv
. .venv/bin/activate
python -m pip install 'ucapi @ git+https://github.com/unfoldedcircle/integration-python-library.git@3eea6509ff3248d5f8342d19900048e0bbab07fb'
python ufcircle-core-lifecycle-replay.pyThe replay reports callbacks=['exit_standby', 'enter_standby'] connected=False command_code=500, followed by after wake: connected=True command_code=200.
Expected behavior
Integration consumers should converge on the remote's current lifecycle state after rapid transitions. A stale standby transition should not leave an awake remote's integrations suspended indefinitely. Please investigate ordering and generation fencing at the core lifecycle owner, or provide a reliable current-state snapshot or equivalent convergence primitive for all consumers. This report does not identify the responsible core implementation. A receiver-side filter based only on wall-clock timestamps would not by itself be a reliable general solution if the clock changes.
System version
Remote 3, OS 2.13.0 beta; core 0.85.3-non-git; API 0.57.2; UI 0.85.2; Anthem integration 2.2.0.
What part of the system is affected?
Core, Integration.
Additional context
All times below are UTC on 2026-11-15. Both messages were received on the same integration WebSocket connection (local peer port 48750).
| Observation | Time |
|---|---|
exit_standby event timestamp |
20:54:01.502150585 |
exit_standby driver log / journal receipt |
20:54:01.515 / 20:54:01.523018 |
enter_standby event timestamp |
20:54:01.477586247 |
enter_standby driver log / journal receipt |
20:54:01.551 / 20:54:01.552157 |
| Entities reported unavailable | 20:54:01.584–20:54:01.623 |
On commands failed with 500, not connected |
20:54:40.717 and 20:54:44.562 |
Next exit_standby event timestamp |
20:55:00.954794514 |
| Connection established and initialized | 20:55:02.563 |
The Integration API specification describes ts as an optional event-generation timestamp, not a monotonic sequence number. A wall-clock step could affect timestamp comparison; the observed receipt order and subsequent behavior are independently logged, but the timestamps alone do not prove where the inversion arose.
Related wake reliability report: #791. This report adds a captured lifecycle-event receive order and its downstream state consequence.
The capture was made with dock firmware 0.8.2; the dock was subsequently updated to 0.10.5. The dock update is separate from this observed integration lifecycle problem.
Self-contained WebSocket replay
"""Replay captured lifecycle envelopes through a real local ucapi WebSocket."""
import asyncio
import json
import logging
import websockets
from ucapi import Events, IntegrationAPI, StatusCodes
from ucapi.switch import Attributes, Features, States, Switch
logging.disable(logging.CRITICAL)
EVENTS = [
{"kind": "event", "msg": "exit_standby", "cat": "REMOTE", "ts": "2026-11-15T20:54:01.502150585Z", "msg_data": None},
{"kind": "event", "msg": "enter_standby", "cat": "REMOTE", "ts": "2026-11-15T20:54:01.477586247Z", "msg_data": None},
]
async def main():
api = IntegrationAPI(asyncio.get_running_loop())
state = {"connected": True, "events": []}
def awake(**kwargs):
state["connected"] = True
state["events"].append("exit_standby")
def standby(**kwargs):
state["connected"] = False
state["events"].append("enter_standby")
api.add_listener(Events.EXIT_STANDBY, awake)
api.add_listener(Events.ENTER_STANDBY, standby)
async def command(entity, cmd, params):
return StatusCodes.OK if state["connected"] else StatusCodes.SERVER_ERROR
api.configured_entities.add(Switch(
"switch.endpoint", "Endpoint", [Features.ON_OFF],
{Attributes.STATE: States.ON}, cmd_handler=command,
))
async with websockets.serve(api._handle_ws, "127.0.0.1", 0) as server:
port = server.sockets[0].getsockname()[1]
async with websockets.connect(f"ws://127.0.0.1:{port}") as ws:
await ws.recv() # Initial authentication event.
for event in EVENTS:
await ws.send(json.dumps(event))
request = {"kind": "req", "id": 1, "msg": "entity_command", "msg_data": {"entity_id": "switch.endpoint", "cmd_id": "on"}}
await ws.send(json.dumps(request))
response = json.loads(await asyncio.wait_for(ws.recv(), 2))
print(f"callbacks={state['events']} connected={state['connected']} command_code={response['code']}")
assert state["events"] == ["exit_standby", "enter_standby"]
assert not state["connected"] and response["code"] == 500
await ws.send(json.dumps({"kind": "event", "msg": "exit_standby", "ts": "2026-11-15T20:55:00.954794514Z", "msg_data": None}))
request["id"] = 2
await ws.send(json.dumps(request))
response = json.loads(await asyncio.wait_for(ws.recv(), 2))
print(f"after wake: connected={state['connected']} command_code={response['code']}")
assert state["connected"] and response["code"] == 200
asyncio.run(main())
Activity