Skip to main content

This is a python package that facilitates reading from and control over a DALI (IEC 62386) protocol bus using a USB adapter such as the Tridonic USB adapter.

The intention for this package is that it will be used to add DALI support to Home Assistant

Approach

DALI uses a short addressing scheme, assigning every device on the bus a number between 0 and 63 inclusive. But these addresses can change if a re-address operation is performed. Instead, when a device is created by this library, it determines a unique identifier by concatenating three pieces of information:

  1. The Device GTIN
  2. The device's serial number
  3. The logical enpoint number. A single device might house more than one gear endpoint. For example, a Tridonic 4 channel relay advertises itself as 4 separate devices, but each one will have the same GTIN and serial number.

All of this information is loaded in from memory bank 0 of the device (see this article for more details.). The unique Id isn't particularly human readable, but it will remain static for the lifetime of that device.

when dealing with devices, you should always use the unique_id property to refer to devices. That way they'll still work if a re-address is done or the device is moved to another bus.

Usage

All useage starts with the Bus Transciever. This is the component that interfaces to USB and will send/receive commands. This class exclusively uses asyncio.

Drivers can be explicitly opened using the constructor, or scanned for using scan_for_dali_transcievers() which will return a list of all auto-discovered drivers.

These drivers are also intended to pick up commands that are issued by other devices on the bus. This is important to keep any visible state displayed to a user in sync with what has happened, without having to do a lot of polling (which will use up more power). to listen to events on the bus, call add_message_callback() on the bus transciever. However, if you just want to send commands and get responses back, you don't need to use the callback system.

Example

from async_dali import TridonicDali
import asyncio


async def testit():
    busses = TridonicDali.scan_for_transcievers()
    if len(busses) == 0:
        raise Exception("No DALI transciever found")
    
    print("Opening first discovered bus", busses[0])
    async with busses[0] as bus:
        print("Scanning for gear")
        gear = await bus.scan_for_gear()

        if len(gear) == 0:
            raise Exception("No gear found on the bus")
        g = gear[0]
        print("Toggling", g.unique_id)

        # Toggle the light on then off again
        await g.on()
        await asyncio.sleep(2)
        await g.off()
    print("Done")


if __name__ == "__main__":
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)

    loop.run_until_complete(testit())
    loop.close()

Metadata

Release files for async-dali 0.1.7

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

Source distribution (sdist)

Source distribution for async-dali 0.1.7
File Size Uploaded Provenance
async_dali-0.1.7.tar.gz 19.6 kB Without provenance Details

Release files / async_dali-0.1.7.tar.gz

Download URL async_dali-0.1.7.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
45afb64ef2e7ef0742263243619fae11b714da070755eb401e069b57166aea7c
BLAKE2b-256 checksum
How to use checksums
28dc6568be8d20f5744a235c6993b15406c3013207b7eb625f2b53528c75dc46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Security for async-dali 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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