"""Synthetic River 2 diagnostics. No device captures or private identifiers.""" import asyncio import importlib.util import struct from argparse import Namespace from pathlib import Path from unittest.mock import AsyncMock, Mock import pytest from bmspy.ecoflow_bt import EcoFlowBTDevice, EcoFlowPacket, _State ADDRESS = "02:00:00:00:00:03" @pytest.fixture def script(): path = Path(__file__).resolve().parents[1] / "tools" / "ecoflow-bt.py" spec = importlib.util.spec_from_file_location("ecoflow_live_diagnostics", path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) return module def device(prefix="R601"): return EcoFlowBTDevice(ADDRESS, prefix + "TEST00000001", "test-user") def attach(script, dev, watch=False): collector = script.PacketCollector(ADDRESS, script.MODEL_PROFILES[dev.serial_number[:4]], watch) dev.on_packet(collector.receive) return collector def river2_bypass_packets(): """Synthetic first burst: three core heartbeats, MPPT, and an empty reply.""" pd = bytearray(121) struct.pack_into("