Dashboard › › Session ses_38a1f04f
ses_38a1f04f2ffeNtcIEbJEdeyJEV[{"op":"update","id":"5877787e-521f-4122-ad5d-ad8ab0759e46","content":"The chromecast_avr_bridge.py follows clean dependency injection: HkAvrSerial (RS-232 over SSH), IrBlaster (HTTP to ESP32-C3), and ChromecastAvrBridge (orchestrator) are separate classes. main() loads config.yaml, constructs all three, calls bridge.start(). No module-level state or globals. Config is in a separate config.yaml file, path resolved from CLI arg or script's own directory. Bridge monitors multiple Chromecast devices simultaneously — the primary device plus all devices sharing its IP address (which catches static groups, dynamic groups, and ad-hoc broadcast groups automatically). Config specifies only the primary device name (chromecast.name, e.g. 'Home Theater'); discovery finds all Chromecasts on the network via pychromecast.get_chromecasts(), locates the primary by name, gets its IP from cc.cast_info.host, then connects to all devices sharing that IP. Each device gets its own _DeviceListener instance that calls back to shared bridge. _active is a set of device names currently streaming. Any device going active triggers AVR power-on; turn-off timer only fires when ALL devices are inactive. IMPORTANT: bridge is purely passive — never calls mc.update_status() because that triggers pychromecast to launch an app, which kills group streams. Relies entirely on passive callbacks (new_media_status, new_cast_status, new_connection_status). new_connection_status handles CONNECTED by re-registering media listener and reading mc.status passively. _handle_start is idempotent: checks AVR is_on() first, only powers on if off. is_on() sends a single VOL UP as a side-effect-free liveness probe — a lone VOL UP after the OSD timeout only activates the display without changing volume. ...