All Projects → home-assistant-libs → Pytradfri

home-assistant-libs / Pytradfri

Licence: mit
IKEA Trådfri/Tradfri API. Control and observe your lights from Python. Examples available. On pypi. Sans-io.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pytradfri

Core
🏡 Open source home automation that puts local control and privacy first.
Stars: ✭ 48,265 (+6103.73%)
Mutual labels:  asyncio, raspberry-pi, iot, internet-of-things
Homeassistant
Example Home Assistant Configs
Stars: ✭ 168 (-78.41%)
Mutual labels:  homeautomation, raspberry-pi, iot, internet-of-things
Rpieasy
Easy MultiSensor device based on Raspberry PI
Stars: ✭ 85 (-89.07%)
Mutual labels:  raspberry-pi, raspberry, iot, internet-of-things
Homeassistant Config
Stars: ✭ 211 (-72.88%)
Mutual labels:  homeautomation, raspberry-pi, iot, internet-of-things
Blynk Server
Blynk is an Internet of Things Platform aimed to simplify building mobile and web applications for the Internet of Things. Easily connect 400+ hardware models like Arduino, ESP8266, ESP32, Raspberry Pi and similar MCUs and drag-n-drop IOT mobile apps for iOS and Android in 5 minutes
Stars: ✭ 8 (-98.97%)
Mutual labels:  raspberry-pi, iot, internet-of-things
Home Assistant
Home-Assistant-Config
Stars: ✭ 182 (-76.61%)
Mutual labels:  raspberry-pi, iot, internet-of-things
Pjon
PJON (Padded Jittering Operative Network) is an experimental, arduino-compatible, multi-master, multi-media network protocol.
Stars: ✭ 2,615 (+236.12%)
Mutual labels:  raspberry-pi, iot, internet-of-things
Homeassistant
Example Home Assistant Configs
Stars: ✭ 846 (+8.74%)
Mutual labels:  homeautomation, iot, internet-of-things
Home Assistant Config
🏠 My Home Assistant configuration, a bit different that others :) Be sure to 🌟 this repository for updates!
Stars: ✭ 1,050 (+34.96%)
Mutual labels:  homeautomation, iot, internet-of-things
Mycontroller V1 Legacy
The Open Source Controller
Stars: ✭ 135 (-82.65%)
Mutual labels:  homeautomation, iot, internet-of-things
Pymarketcap
Python3 API wrapper and web scraper for https://coinmarketcap.com
Stars: ✭ 73 (-90.62%)
Mutual labels:  api, asyncio, pypi
Siricontrol System
Control anything with Siri voice commands.
Stars: ✭ 180 (-76.86%)
Mutual labels:  raspberry-pi, iot, internet-of-things
Blynk Library Python
Blynk library for Python. Works with Python 2, Python 3, MicroPython.
Stars: ✭ 170 (-78.15%)
Mutual labels:  raspberry-pi, iot, internet-of-things
Make
📖📖📖📖📖 写给软件工程师看的硬件编程指南
Stars: ✭ 170 (-78.15%)
Mutual labels:  raspberry-pi, iot, internet-of-things
Brad Homeassistant Config
Home Assistant configuration
Stars: ✭ 212 (-72.75%)
Mutual labels:  homeautomation, raspberry-pi, iot
Awesome Home Assistant
A curated list of amazingly awesome Home Assistant resources.
Stars: ✭ 3,487 (+348.2%)
Mutual labels:  homeautomation, iot, internet-of-things
Home assistant files
Here are my Home Assistant configuration files
Stars: ✭ 159 (-79.56%)
Mutual labels:  raspberry-pi, iot, internet-of-things
Cutehmi
CuteHMI is an open-source HMI (Human Machine Interface) software written in C++ and QML, using Qt libraries as a framework. GitHub repository is a mirror!
Stars: ✭ 90 (-88.43%)
Mutual labels:  raspberry-pi, iot, internet-of-things
Home Assistantconfig
🏠 Home Assistant configuration & Documentation for my Smart House. Write-ups, videos, part lists, and links throughout. Be sure to ⭐ it. Updated FREQUENTLY!
Stars: ✭ 3,687 (+373.91%)
Mutual labels:  homeautomation, raspberry-pi, iot
Blynk Library
Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc.
Stars: ✭ 3,305 (+324.81%)
Mutual labels:  raspberry-pi, iot, internet-of-things

Coverage Status PyPI version Reviewed by Hound

Python package to communicate with the IKEA Trådfri (Tradfri) ZigBee Gateway compatible with ZigBee Light Link products. By using this library you can communicate with the gateway and control IKEA's lights and wall plugs.

Some of the features include:

  • Get information on the gateway
  • Observe lights, groups and other resources and get notified when they change
  • Control wall plugs
  • List all devices connected to gateway
  • List all lights and get attributes of lights (name, state, color temp, dimmer level etc)
  • Change attribute values of lights (name, state, color temp, dimmer level etc)
  • Restart and reset the gateway
  • List smart tasks (wake up, on/off and not home) and their attributes
  • Alter values in smart tasks (some of these features not available in app yet)

Table of contents:

  1. Installation
  2. Verified Device Compatibility
  3. Stand-alone use (command-line interface)
  4. Implement in your own Python platform
  5. Docker support
  6. Known issues
  7. Acknowledgements

Installation

You might have to use superuser privileges (sudo) for some commands to work when installing.

To use the library in a synchronous application, you first need to install libcoap using this script. Use examples/example_sync.py when testing this.

For asynchronous applications you will need to install pytradfri[async], for instance using the requirements file: pip install pytradfri[async]. Please note that install might take considerable time on slow devices. Use examples/example_async.py when testing this.

Security best practice is to not store the security code that is printed on the gateway permanently in your application. Please always use the PSK when communicating with the gateway.

Verified Device Compatibility

Device Version
IKEA Gateway (E1526) 1.8.25
TRADFRI bulb E14 WS opal 400lm 1.2.217
TRADFRI bulb E27 WS opal 980lm 1.2.217
TRADFRI bulb E27 W opal 1000lm 1.2.214
TRADFRI remote control 1.2.214
TRADFRI motion sensor 1.2.214
TRADFRI wall plug 2.0.022

Stand-alone use (command-line interface)

Screenshot of command line interface

If you want to test this library stand-alone in a command-line interface:

$ python3 -i -m pytradfri IP

Where IP is substituted by the IP-address to your gateway.

The first time running pytradfri you will be asked to input the 'Security Code' found on the back of your IKEA gateway.

Examples of commands in the stand-alone prompt:

List all lights:

lights

Set the brightness of item 1 to 50 in lights list:

api(lights[1].light_control.set_dimmer(50))

Observe a light for changes:

def change_listener(device):
  print(device.name + " is now " + str(device.light_control.lights[0].state))

api(lights[0].observe(change_listener))

Implement in your own Python platform

Please see the example files.

Docker support

There is a Docker script available to bootstrap a dev environment. Run ./script/dev_docker and you will build and launch a container that is ready to go for both sync and async. After launching, follow the above instructions to test the library stand-alone.

The working directory of the Docker image is /usr/src/app. The checked out version of this repo is added there and installed as a Python dependency for easy development and testing. When you want to use the latest stable version from pip, you only have to change to another working directory.

Known issues

We are aware of issues some users face with their gateways. Anecdotal evicence suggests sending many requests (spamming) the gateway, or an unreliable network connection can be the culprit. As a first solution, try to limit the number of requests, and move the Gateway closer to the device running pytradfri on the nework. Other than that, there is unfortunately not anything this project can do to support or resolve these issues at this time. As this progresses, we will ensure the project is kept up-to-date.

Acknowledgements

This is an implementation based on analysis I found here by vidarlo.

Paulus Schoutsen (@balloob) made a working Python library of the initial code concept. Lewis Juggins (@lwis) added support for asyncio and improved management of dependencies and consistency around return types. Many others have contributed too.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].