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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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...