Dashboard › › Session ses_37b017d2
ses_37b017d2bffeDr02MXPNQRDvipyes, let's do that
<path>/home/byk/Code/chromecast_avr_bridge.py</path>
<type>file</type>
<content>492: log.info(">>> Also active: %s (start already in progress)", name)
493: else:
494: log.info(">>> Also active: %s (AVR already handled)", name)
495:
496: # Start AVR liveness polling whenever any device is active
497: with self._lock:
498: if self._active and not self._avr_polling:
499: self._avr_polling = True
500: self._cancel_stop_stream_timer()
501: threading.Thread(target=self._poll_avr_liveness, daemon=True).start()
502:
503: def on_device_inactive(self, name: str):
(Showing lines 492-503 of 738. Use offset=504 to continue.)
</content>
<path>/home/byk/Code/chromecast_avr_bridge.py</path>
<type>file</type>
<content>503: def on_device_inactive(self, name: str):
504: with self._lock:
505: self._active.discard(name)
506: if self._active:
507: log.debug(
508: "[%s] inactive but others still active: %s", name, self._active
509: )
510: return
511: # No devices active — schedule turn-off
512: log.info(">>> All devices inactive, turn-off in %ds", self._turn_off_delay)
513: self._schedule_turn_off()
514:
(Showing lines 503-514 of 738. Use offset=515 to continue.)
</content>
Edit applied successfully. LSP errors detected in this file, please fix: <diagnostics file="/home/byk/Code/chromecast_avr_bridge.py"> ERROR [58:8] Import "pychromecast" could not be resolved </diagnostics>
LSP error is just the missing pychromecast type stub — not real. Now restart:
Feb 23 18:29:29 labs systemd[11972]: Stopping chromecast-avr-bridge.service - Chromecast AVR Bridge... Feb 23 18:29:29 labs uv[1180486]: 2026-02-23 18:29:29 [INFO] bridge: Received signal 15 Feb 23 18:29:29 labs uv[1180486]: 2026-02-23 18:29:29 [INFO] bridge: Shutting down... Feb 23 18:29:29 labs uv[1180486]: 2026-02-23 18:29:29 [INFO] bridge: Shutdown complete Feb 23 18:29:29 labs uv[1180486]: 2026-02-23 18:29:29 [INFO] bridge: Received signal 15 Feb 23 18:29:29 labs uv[1180486]: 2026-02-23 18:29:29 [INFO] bridge: Shutting down... Feb 23 18:29:29 labs uv[1180486]: 2026-02-23 18:29:29 [INFO] bridge: Shutdown complete Feb 23 18:29:29 labs systemd[11972]: Stopped chromecast-avr-bridge.service - Chromecast AVR Bridge. Feb 23 18:29:29 labs systemd[11972]: chromecast-avr-bridge.service: Consumed 2min 51.173s CPU time, 29.8M memory peak, 0B memory swap peak. Feb 23 18:29:29 labs systemd[11972]: Started chromecast-avr-bridge.service - Chromecast AVR Bridge. ...
[
{
"content": "Analyze turn-off logs to identify pattern",
"status": "completed",
"priority": "high"
},
{
"content": "Identify root cause: ghost new_cast_status(app_id=None) triggers turn-off when nothing is streaming",
"status": "completed",
"priority": "high"
},
{
"content": "Propose and apply fix",
"status": "completed",
"priority": "high"
}
]
Done. The fix is 4 lines in on_device_inactive (chromecast_avr_bridge.py:504-507):
was_active = name in self._active
self._active.discard(name)
if not was_active:
return # ignore ghost callbacks
The turn-off timer now only starts when a device that was genuinely streaming transitions to inactive. The ghost new_cast_status(app_id=None) callbacks — which fire at 06:00, 08:00, after group transitions, and whenever an app closes — are silently dropped. The daily 06:01 spurious power-offs and all the rapid-fire cycles should be gone.