Created
May 1, 2017 11:03
-
-
Save aerialist/163a5794e95ccd28dc023161324009ed to your computer and use it in GitHub Desktop.
Activate switchbot by python with bluepy on Raspberry Pi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Activate switchbot by python with bluepy on Raspberry Pi | |
# https://github.com/IanHarvey/bluepy | |
# | |
# Switchbot's API is taken from this | |
# https://github.com/OpenWonderLabs/python-host | |
import binascii | |
from bluepy.btle import Peripheral | |
# find your switchbot address by | |
# pi@raspberry:~ $ sudo hcitool lescan | |
# replace "ff:..:ff" | |
p = Peripheral("ff:ff:ff:ff:ff:ff", "random") | |
hand_service = p.getServiceByUUID("cba20d00-224d-11e6-9fb8-0002a5d5c51b") | |
hand = hand_service.getCharacteristics("cba20002-224d-11e6-9fb8-0002a5d5c51b")[0] | |
hand.write(binascii.a2b_hex("570100")) | |
p.disconnect() |
I follow
Try entering your mac address with all lowercase letters, fixed this issue for me.
I can't even get that far on my RPI4 - I just entered the code as above but chaning my MAC number - no mistakes - yet...
pi@mainpi:~:11:46[0]> ./switchbot_bluepi.py
./switchbot_bluepi.py: line 7: import: command not found
from: too many arguments
./switchbot_bluepi.py: line 13: syntax error near unexpected token `('
./switchbot_bluepi.py: line 13: `p = Peripheral("fb:ff:1f:00:4d:aa", "random")'
pi@mainpi:~:11:46[2]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
same thing...no luck. does anyone have a solution to this problem?