Giter Club home page Giter Club logo

python-host's Introduction

python-host

What is the SwitchBot opensource project?

SwitchBot is a smart IoT robot to mechanically control all your switches and buttons. You can control the bot by your smartphone app (iOS or Android, SwitchLink, or other platform based on our open APIs.

This project aims to provide a super light-weight solution to control your SwitchBot on Raspberry Pi/OpenWRT or any other Linux based board.

The python-host distribution is supported and tested on Python 2.7.

How to Install?

On Raspberry Pi. You will need:

Installation:

  • Boot your fresh Pi and open a command prompt.
  • Install the require library.
sudo apt-get update
sudo apt-get install python-pexpect
sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev 
sudo apt-get install libudev-dev libical-dev libreadline-dev
sudo pip install bluepy
  • Clone this repo to the Pi.
git clone https://github.com/OpenWonderLabs/python-host.git
  • run the python code.
cd python-host

You can use in two ways:

  1. Scan and control by device name.
sudo python switchbot.py
  • Follow the instruction, input the device number for SwitchBot you want to control.
  1. Control SwitchBot by MAC address. (MAC address should be retrived in advanced)
sudo python switchbot.py [mac_addr action_cmd]

action_cmd :Press, Turn On, Turn Off.

eg: sudo python switchbot.py  xx:xx:xx:xx:xx:xx Press
  1. Python 3 and new bluetooth stack support

The original switchbot.py script will work only on Python 2 and it relies on the old Bluez utils (like hciconfig and hcitool) that have been deprecated in the latest Bluez releases.

If you want to use the script on Python 3 or on a Linux distro that no longer ships Bluez with the old tools, use the switchbot_py3.py script instead.

To install the required dependencies on Ubuntu/Debian/Raspbian:

apt-get install python3-pip
pip3 install pybluez
apt-get install libboost-python-dev
apt-get install libboost-thread-dev
pip3 install gattlib

If for some reason the gattlib installation fails:

pip3 download gattlib
tar xvzf ./gattlib-0.20150805.tar.gz
cd gattlib-0.20150805/
sed -ie 's/boost_python-py34/boost_python-py35/' setup.py
pip3 install .

Type python3 switchbot_py3.py --help for usage tips.

Enjoy :)

Thanks to contributors:

BlackLight

Share your words in our community.

python-host's People

Contributors

blacklight avatar sizkin avatar switchbot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.