Skip to main content

Async library for Plugwise stick

Project description

python-plugwise: An async python library to control Plugwise plugs Circle+ and Circle

This library was created to extent my Home Assisstant setup with the Plugwise stick to control the linked Circle+ and Circle plugs. As the primary goal is to support Plugwise nodes in Home Assistant, it can also be used independently.

There's no official documentation available about the protocol of the Plugwise so this library is based on partial reverse engineering by Maarten Damen and several other sources bitbucket.org/hadara/python-plugwise and openHAB

The latest version of the library is published as a python package on pypi and currently supports the devices an functions listed below:

Plugwise node Relay control Power monitoring Comments
Circle+ Yes Yes Supported
Circle Yes Yes Supported
Scan No No Not supported yet
Sense No No Not supported yet
Switch No No Not supported yet
Stealth No No Not supported yet
Sting No No Not supported yet

When the connection to the stick is initialized it will automatically connected to Scan for linked nodes

I would like to extend this library to support other Plugwise device types, unfortunately I do not own these devices so I'm unable to test. So feel free to submit pull requests or log issues through github for functionality you like to have included.

Note: This library does not support linking or removing nodes from the Plugwise network. You still need the Plugwise Source software for that.

Install

To install run the following command as root:

python setup.py install

Example usage

The library currently only supports a USB (serial) connection (socket connection is in development) to the Plugwise stick. In order to use the library, you need to first initialize the stick and trigger a scan to query the Circle+ for all linked nodes in the Plugwise Zigbee network.

import time
import plugwise

CALLBACK_RELAY = "RELAY"
CALLBACK_POWER = "POWER"

def scan_start():

    def scan_finished():
        """
        Callback for init finished
        """

        def power_update(power_use):
            """
            Callback for new power use value
            """
            print("New power use value : " + str(round(power_use, 2)))


        print("== Initialization has finished ==")
        print("")
        for mac in plugwise.nodes():
            print ("- type  : " + str(plugwise.node(mac).get_node_type()))
            print ("- mac   : " + mac)
            print ("- state : " + str(plugwise.node(mac).available))
            print ("- update: " + str(plugwise.node(mac).get_last_update()))
            print ("- hw ver: " + str(plugwise.node(mac).get_hardware_version()))
            print ("- fw ver: " + str(plugwise.node(mac).get_firmware_version()))
            print ("- relay : " + str(plugwise.node(mac).is_on()))
            print ("")
        print ("circle+ = " + plugwise.nodes()[0])
        node = plugwise.node(plugwise.nodes()[0])
        mac = node.get_mac()
        print("Register callback for power use updates of node " + mac)
        node.on_status_update(power_update, CALLBACK_POWER)

        print("start auto update every 10 sec")
        plugwise.auto_update(10)

    # Scan for linked nodes and print all scan activities to console
    plugwise.scan(scan_finished, True)

## Main ##
print("start connecting to stick")
port = "/dev/ttyUSB0"
plugwise = plugwise.stick(port, scan_start)

time.sleep(300)
print("stop auto update")
plugwise.auto_update(0)

time.sleep(5)

print("Exiting ...")
plugwise.stop()

Usage

You can use example.py as an example to get power usage from the Circle+

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-plugwise-0.1.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_plugwise-0.1-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file python-plugwise-0.1.tar.gz.

File metadata

  • Download URL: python-plugwise-0.1.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.4

File hashes

Hashes for python-plugwise-0.1.tar.gz
Algorithm Hash digest
SHA256 92926f6846075081e194aaeb5b86369364a7c4efa74876a03c09f5a792f19a03
MD5 461f86ccf5648e9ebc7fa308a9f71482
BLAKE2b-256 3b8a70a5493579dc8f48920014888fd88a77d4e65ebb2603bd2ac0aef186b647

See more details on using hashes here.

File details

Details for the file python_plugwise-0.1-py3-none-any.whl.

File metadata

  • Download URL: python_plugwise-0.1-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.4

File hashes

Hashes for python_plugwise-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d364264a7fd9e47776a869fa4e0c2b4b67845c8676597a4ed498ec556cb3a250
MD5 652680ade086c8499b5adf155a763766
BLAKE2b-256 699d089e109592eef6bbcbb8212a77e2a9a92272f76e359db8739976f6dc0c75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page