Help connect River2 #177
-
|
Hi, All I do not have HA but I want to connect to my River 2 (and River 2 Pro). async def main():
USER_ID = "159****************"
TARGET_MAC = "60:57:F9:65:31:3D"
# TARGET_MAC = "F2:13:FA:02:36:FD"
# Replace with your actual River 2 serial number
SERIAL_NUMBER = "R601ZEB5HE9T0125"
# SERIAL_NUMBER = "R631ZCB6XECS6331"
print(f"--- Quick-Finding {TARGET_MAC} ---")
# This event helps us stop the scan the moment we find the device
found_event = asyncio.Event()
found_data = {"dev": None, "adv": None}
def callback(device, adv):
if device.address.upper() == TARGET_MAC:
found_data["dev"] = device
found_data["adv"] = adv
found_event.set() # Signal to stop scanning
# Start scanning with the callback
async with BleakScanner(detection_callback=callback):
try:
# Wait for the device to be found, or timeout after 10s
await asyncio.wait_for(found_event.wait(), timeout=10.0)
except asyncio.TimeoutError:
print("❌ Timeout: Device not found.")
return
my_river = Device(
ble_dev=found_data["dev"], adv_data=found_data["adv"], sn=SERIAL_NUMBER
)
await my_river.connect(USER_ID, 5, 90)after this I get these logs: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
-
|
@GnoX , yes I have a loop in the end of my script. it never ended Thanks for the app. It works. But can I control settings with it? or use it inside other scripts? |
Beta Was this translation helpful? Give feedback.
-
|
@GnoX , thanks
|
Beta Was this translation helpful? Give feedback.



If the script you posted is the whole script, then it's going to stop as soon as it sends that first message. You also have to
await device.wait_until_authenticated_or_error(raise_on_error=True)and set up an event to wait until you do something with it, otherwise the application just exists as it's not waiting for anything.I do have few scripts you can use outside of HA that you can use as an example:
Both runnable using uv script as
uv run connect.py.