Skip to main content

Asyncio Python library for connecting to and controlling the Logitech Harmony

Project description

Python library for programmatically using a Logitech Harmony Link or Ultimate Hub.

This library originated from iandday/pyharmony which was a fork of bkanuka/pyharmony with the intent to:

  • Make the harmony library asyncio

  • Ability to provide one’s own custom callbacks to be called

  • Automatic reconnect, even if re-connection cannot be established for a time

  • More easily get the HUB configuration through API call

  • Additional callbacks: connect, disconnect, HUB configuration updated

  • Using unique msgid’s ensuring that responses from the HUB are correctly managed.

Protocol

As the harmony protocol is being worked out, notes will be in PROTOCOL.md.

Status

  • Retrieving current activity

  • Querying for entire device information

  • Querying for activity information only

  • Querying for current activity

  • Starting Activity

  • Sending Command

  • Changing channels

  • Custom callbacks.

Usage

aioharmony - Harmony device control

usage: aioharmony [-h] (--harmony_ip HARMONY_IP | --discover)
                  [--harmony_port HARMONY_PORT]
                  [--loglevel {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
                  [--show_responses | --no-show_responses] [--wait WAIT]
                  {show_config,show_detailed_config,show_current_activity,start_activity,power_off,sync,listen,send_command,change_channel}
                  ...

aioharmony - Harmony device control

positional arguments:
  {show_config,show_detailed_config,show_current_activity,start_activity,power_off,sync,listen,send_command,change_channel}
    show_config         Print the Harmony device configuration.
    show_detailed_config
                        Print the detailed Harmony device configuration.
    show_current_activity
                        Print the current activity config.
    start_activity      Switch to a different activity.
    power_off           Stop the activity.
    sync                Sync the harmony.
    listen              Output everything HUB sends out
    send_command        Send a simple command.
    change_channel      Change the channel

optional arguments:
  -h, --help            show this help message and exit
  --harmony_ip HARMONY_IP
                        IP Address of the Harmony device. (default: None)
  --discover            Scan for Harmony devices. (default: False)
  --harmony_port HARMONY_PORT
                        Network port that the Harmony is listening on.
                        (default: 5222)
  --loglevel {DEBUG,INFO,WARNING,ERROR,CRITICAL}
                        Logging level for all components to print to the
                        console. (default: INFO)
  --show_responses      Print out responses coming from HUB. (default: False)
  --no-show_responses   Do not print responses coming from HUB. (default:
                        False)
  --wait WAIT           How long to wait in seconds after completion, useful
                        in combination with --show-responses. Use -1 to wait
                        infinite, otherwise has to be a positive number.
                        (default: 0)

Release Notes

0.1.0. Initial Release

0.1.2. Fixed:
  • Enable callback connect only once initial connect and initialization is completed.

  • Fix exception when activity/device name/id is None when trying to retrieve name/id.

  • Fixed content type and name of README in setup.py

0.1.3. Fixed:
  • Retry connect on reconnect

0.1.4. Fixed:
  • Exception when retrieve_hub_info failed to retrieve information

  • call_callback helper would never return True on success.

  • Retry connect on reconnect (was not awaited upon)

0.1.5. Fixed:
  • Exception when an invalid command was sent to HUB (or sending command failed on HUB).

  • Messages for failed commands were not printed in main.

0.1.6. Fixed:
  • Ignore response code 200 when for sending commands

  • Upon reconnect, errors will be logged on 1st try only, any subsequent retry until connection is successful will only provide DEBUG log entries.

0.1.7. Fixed:
  • Fix traceback if no configuration retrieved or items missing from configuration (i.e. no activities)

  • Retrieve current activity only after retrieving configuration

0.1.8. Fixed:

NOTE: This version will ONLY work with 4.15.250 or potentially higher. It will not work with lower versions!

  • Fix traceback if HUB info is not received.

  • Fix for new HUB version 4.15.250. (Thanks to reneboer for providing the quick fix).

0.1.9. Fixed:
  • Fixed “Network unreachable” or “Host unreachable” on certain installations (i.e. in Docker, HassIO)

0.1.10. Changed:
  • On reconnect the wait time will now start at 1 seconds and double every time with a maximum of 30 seconds.

  • Reconnect sometimes might not work if request to close was received over web socket but it never was closed.

0.1.11. Changed:
  • Timeout changed from 30 seconds to 5 seconds for network activity.

  • For reconnect, first wait for 1 second before starting reconnects.

0.1.12. Fixed/Changed:
  • Fixed issue where connection debug messages would not be shown on failed reconnects.

  • Added debug log entry when connected to HUB.

0.1.13.
  • Fixed further potential issue where on some OS’s sockets would not be closed by now force closing them.

0.2.0. New:
  • Support for XMPP. If XMPP is enabled on Hub then that will be used, otherwise fallback to web sockets. There are no changes to the API for this. XMPP has to be explicitly enabled on the Harmony HUB. To do so open the Harmony app and go to: Menu > Harmony Setup > Add/Edit Devices & Activities > Remote & Hub > Enable XMPP Same steps can be followed to disable XMPP again.

  • Log entries from responsehandler class will now include ip address of HUB for easier identification

0.2.1 Fixed:
  • Fixed issue in sending commands to HUB wbe using XMPP protocol.

0.2.2 Fixed:
  • Added closing code from aiohttp for web sockets in debug logging if closing code provided.

  • Fixed further potential issue where on some OS’s sockets would not be closed by now force closing them (merge from 0.1.13)

  • Fixed listen parameter as it would just exit instead of continuously wait.

0.2.3 Changed:
  • Updated requirement for slixmpp to 1.5.2 as that version works with Home Assistant

TODO

  • Redo discovery for asyncio. This will be done once XMPP is re-implemented by Logitech

  • More items can be done from the Harmony iOS app; determining what could be done within the library as well

  • Is it possible to update device configuration?

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

aioharmony-0.2.3.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

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

aioharmony-0.2.3-py2.py3-none-any.whl (40.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file aioharmony-0.2.3.tar.gz.

File metadata

  • Download URL: aioharmony-0.2.3.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for aioharmony-0.2.3.tar.gz
Algorithm Hash digest
SHA256 445323810978454ba3b32be53ba6b43cf9948586de3f9734b8743b55858b3cc7
MD5 6bb2e6818eeb66b39a00f8492423964c
BLAKE2b-256 a744d10be51681869cbc83838fd243e4b78ad6d8f522244749d5f4f7dbf92214

See more details on using hashes here.

File details

Details for the file aioharmony-0.2.3-py2.py3-none-any.whl.

File metadata

  • Download URL: aioharmony-0.2.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 40.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for aioharmony-0.2.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b002125e248aed4622e5c1741aa71b99e6259a3600a76782c74d45c1a8871b49
MD5 f1f20e60ed2cf62fd7feefc9f20cfd74
BLAKE2b-256 cea40eaceb156d5771bd7a85125288ce5354474544d6cbf8dbaa7d3705b71452

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