OpenWonderLabs / python-host

The python code running on Raspberry Pi or other Linux based boards to control SwitchBot.
Apache License 2.0
376 stars 84 forks source link

Can't scan the SwitchBot. #13

Closed hwangjr closed 4 years ago

hwangjr commented 4 years ago

I run the script:

sudo python switchbot.py
Usage: "sudo python switchbot.py [mac_addr  cmd]" or "sudo python switchbot.py"
Start scanning...
scan timeout
No SwitchBot nearby, exit

Raspberry Pi 4 with Bluetooth 5.5. SwitchBot S1, FCC ID:2AKXBS1

thepiam commented 4 years ago

Same thing happened to me, scan always timed out. But when I specified BLE MAC and a command it worked, like so:

sudo python python-host/switchbot.py C6:F2:0E:A1:86:70 Turn On sudo python python-host/switchbot.py C6:F2:0E:A1:86:70 Turn Off sudo python python-host/switchbot.py C6:F2:0E:A1:86:70 Up sudo python python-host/switchbot.py C6:F2:0E:A1:86:70 Down sudo python python-host/switchbot.py C6:F2:0E:A1:86:70 Press

hwangjr commented 4 years ago

@thepiam yep, but I can't get the address without scanning the device. (except connect to the phone to get the address first)

Thomasbomb commented 4 years ago

I believe this is due to a firmware update on the switchbot. Someone should see if they can update it to work with the new firmware. I might if I end up buying one

hwangjr commented 4 years ago

seems no one care about this. I already buy 10+ SwitchBots...

hwangjr commented 4 years ago

@SwitchBot any progress for this issue?

nicolas-kuechler commented 4 years ago

@hwangjr What firmware version do your bots have? (you can find the information with the official app)

You can try my api which relies on another python ble library: https://github.com/nicolas-kuechler/switchbot

After setting up the python environment as described in the readme, the code below (must be run with sudo) should find the switchbots:

from switchbot import Scanner

scanner = Scanner()
mac_addresses = scanner.scan(known_dict={})

My code is tested with firmware version 4.5 and a raspberry pi 3.

hwangjr commented 4 years ago

@nicolas-kuechler ok, I will have a try. thx