Skip to main content

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 legacy USB-stick to control the linked Circle+ and Circle plugs which could be controlled by the legacy Windows Source application supplied by Plugwise. As the primary goal is to support Plugwise nodes in Home Assistant, it can also be used independently.

Be aware this library does NOT support the new Plug (identified by having a local button) which complies to the Zigbee standard, while this is not the case for the legacy plugwise devices.

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 and functions listed below:

Plugwise node Relay control Power monitoring Comments
Circle+ Yes Yes Working
Circle Yes Yes Working
Scan N/A N/A Working
Sense N/A N/A Experimental (not tested)
Switch No No Not supported yet
Stealth Yes Yes Experimental (not tested)
Sting No No Not supported yet

When the connection to the stick is initialized it will automatically do a discovery of all 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.

This library supports linking or removing nodes from the Plugwise network. The easiest way of linking new nodes is after connection calling:

<stick_object>.allow_join_requests(True, True)

This will automatically add any new node not yet registered to any network (i.e. after it is set back to factory defaults)

Install

To install and use this library standalone use the following command:

pip install python-plugwise

If you want to control the Plugwise devices from Home Assistant, do not install this library but install this custom integration instead.

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 plugwise
from plugwise.constants import SENSOR_POWER_USE

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).get_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).get_relay_state()))
        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.subscribe_callback(power_update, SENSOR_POWER_USE["state"])

    print("start auto update every 10 sec")
    plugwise.auto_update(10)
    time.sleep(5)
    plugwise.node("000D6F00003FD440").set_relay_state(True)
    time.sleep(5)
    plugwise.node("000D6F00003FD440").set_relay_state(False)

    time.sleep(5)
    print ("Circle+ Poweruse last second (W)             : " + str(node.get_power_usage()))
    print ("Circle+ Poweruse last 8 seconds (W)          : " + str(node.get_power_usage_8_sec()))
    print ("Circle+ Power consumption current hour (kWh) : " + str(node.get_power_consumption_current_hour()))
    print ("Circle+ Power consumption previous hour (kWh): " + str(node.get_power_consumption_previous_hour()))
    print ("Circle+ Power consumption today (kWh)        : " + str(node.get_power_consumption_today()))
    print ("Circle+ Power consumption yesterday (kWh)    : " + str(node.get_power_consumption_yesterday()))
    print ("Circle+ Power production previous hour (kWh) : " + str(node.get_power_production_current_hour()))
    print ("Circle+ Power production current hour (kWh)  : " + str(node.get_power_production_previous_hour()))
    print ("Circle+ Ping roundtrip (ms)                  : " + str(node.get_ping()))
    print ("Circle+ RSSI in                              : " + str(node.get_rssi_in()))
    print ("Circle+ RSSI out                             : " + str(node.get_rssi_out()))


## Main ##
port = "/dev/ttyUSB0"  # or "com1" at Windows
plugwise = plugwise.stick(port, scan_finished, True)

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

time.sleep(5)

print("Exiting ...")
plugwise.disconnect()

Usage

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

Metadata

Release files for python-plugwise 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-plugwise 2.0.2
File Size Uploaded
python-plugwise-2.0.2.tar.gz 39.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-plugwise 2.0.2
File Interpreter ABI Platform
python_plugwise-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 85.7 kB

Release files / python-plugwise-2.0.2.tar.gz

Download URL python-plugwise-2.0.2.tar.gz
Size 39.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b004a34b3abbd6595e2ad70d7f3f0e7303c929a64129cd2a2c7ca8283a1aa2f6
BLAKE2b-256 checksum
How to use checksums
b528c2b0bdb3032ae7b04d761b4e9c2d1cd2260b7b343d02361bfcdb93d6e849
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.8.5

Release files / python_plugwise-2.0.2-py3-none-any.whl

Download URL python_plugwise-2.0.2-py3-none-any.whl
Size 46.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbc8976453bb685ac3487880130ba3b7ca6921804b71cfe0b54b8502258f94ae
BLAKE2b-256 checksum
How to use checksums
c858bb48b507930ed2eecbdcae251bd354cfbb43e1a87142bae52d6b7e7d02a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.8.5

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.9.1

2 release files

0.8

2 release files

0.7

2 release files

0.6

2 release files

0.5

2 release files

0.4

2 release files

0.3

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page