Skip to main content

Python client for Unisenza Plus

Project description

Unisenza Plus is a product line that connects smart thermostats and other devices manufactured by Purmo to a cloud service via the Unisenza Plus Gateway. pyupgw is a python client for that cloud service.

Currently only the smart thermostats are supported.

Installation

Install the library using pip or your favorite package management tool:

$ pip install pyupgw

Usage

The following sample program illustrates how to use the client

import asyncio
from pyupgw import create_client, Client, Device

def report_changes(device: Device, changes: dict):
    print(f"{device.get_name()} has new changes:")
    for key, value in changes.items():
        print(f"- {key}: {value}")

 async def main():
     async with create_client("username", "password") as client:

         # Refresh device attributes from the server
         await client.refresh_all_devices()
         await asyncio.sleep(10)

         print("Gateways:")
         for gateway in client.get_gateways():
             print(f"- {gateway.get_name()}")

         print("Devices:")
         for gateway, device in client.get_devices():
             print(
                 f"- {device.get_name()},",
                 f"setpoint temperature: {device.get_temperature()},",
                 f"current temperature: {device.get_current_temperature()}",
             )

         device = client.get_gateways()[0].get_children()[0]
         device.subscribe(report_changes)

         print(f"Updating setpoint temperature for {device.get_name()}")
         await device.update_temperature(20.0)

         await asyncio.sleep(10)

 if __name__ == "__main__":
     asyncio.run(main())

Please note that the underlying API is MQTT based. Compared to REST APIs this makes it totally asynchronous. While the functions for refreshing and updating the device state are coroutines, they complete as soon as the server acknowledges the message (but before it actually responds with a message of its own). The server may not even report some updates, for instance when setting temperature to the same value it already has.

The sample program naively uses asyncio.sleep() calls to synchronize to the actual updates. A real program would do something more elegant, like update GUI elements or dispatch messages to event loop in response to the callbacks.

Goals

The main reason for this project is to (eventually) develop Home Assistant integration for the Unisenza Plus.

The client library is intended to give a robust and simplified interface to the most important attributes and functionality of the smart thermostats. By hiding complexity it trades off some degree of control.

The library only supports a subset of features of the devices. New features may be added on case-by-case basis.

Non-goals

The author of the library is in no way affiliated with the company Purmo, and not working using official API documentation. Hence, the scope of the library will likely never cover all the possible features of the products.

The Unisenza Plus service is based on the UleEco IoT platform. As such, this package might work with some modifications with other product lines based on the platform. However, since the author does not have official documentation, this is not guaranteed and a universal UleEco client is not in the scope of this project for the time being.

The intended usage of the library is developing scripts and other automations for the Purmo thermostats. The underlying API contains data specifically intended to be consumed by the official Unisenza Plus app (related to presentation and notifications, for instance). There is no intention to support those features in this library.

Contributing

This project is still in early stages. Please open an issue or PR in the Github repository if you want to get in touch with questions or contributions.

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

pyupgw-0.1.1.tar.gz (25.8 kB view details)

Uploaded Source

Built Distribution

pyupgw-0.1.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file pyupgw-0.1.1.tar.gz.

File metadata

  • Download URL: pyupgw-0.1.1.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for pyupgw-0.1.1.tar.gz
Algorithm Hash digest
SHA256 93f61254687b53a1a703dec59207deac66e3dcc02031dc4c9cf91629ec60e29a
MD5 98f9eb2b7e3c7cfc12a9cfacd0f6e60a
BLAKE2b-256 91814b3f587ceda71a34861f82f1856671fe7ea6c2e0e7904117992f797e5502

See more details on using hashes here.

File details

Details for the file pyupgw-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyupgw-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for pyupgw-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 13bb97fc6fbd930ec7a73a64241f0104700679c05f7663aae38bfc8ea21ae42e
MD5 6af2256cb36c6ad7e9fdb9f89a792e41
BLAKE2b-256 817ae869beb71469a9c1a595c3fcbbadde0773145732ec0cba722f2747fb5ca9

See more details on using hashes here.

Supported by

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