Skip to main content

local-tuya-domoticz-tools

tests version python

Tools to create a Domoticz plugin for local-tuya devices.

💡 The Domoticz version should be 2022.1 or higher.

Creating the plugin

To create a plugin, you will need to create 2 things.

Plugin metadata

This is the XML header that is used to populate the plugin creation page in Domoticz. You can create it using local_tuya_domoticz_tools.PluginMetadata.

Starting the device.

To start the plugin, you need to create the device and register the units.

Check local_tuya_domoticz_tools.plugin.plugin.OnStart for the function signature.

Units should be created using manager.register(...).

For a switch unit, it would look like:

from typing import Dict

from local_tuya import DeviceConfig, ProtocolConfig
from local_tuya_domoticz_tools import UnitManager, switch_unit

from my_device import SwitchState, SwitchDevice


def on_start(
    protocol_config: ProtocolConfig,
    _: Dict[str, str],
    manager: UnitManager[SwitchState],
) -> SwitchDevice:
    device = SwitchDevice(config=DeviceConfig(protocol=protocol_config))
    manager.register(
        switch_unit(
            id_=1,
            name="power",
            image=9,
            command_func=device.switch,
        ),
        lambda s: s.power,
    )
    return device

Units

Units represent a Domoticz device and is associated to a Domoticz hardware.

Manager

The role of the manager is to

  • create/remove units: register method
  • dispatch the commands from units: on_command method
  • update units state: update method

Unit types

For common units parameters, see the base.

Installing the plugin

You should provide a script that will be used to install the plugin. It would look like:

from local_tuya_domoticz_tools import install_plugin, PluginMetadata

def on_start(...):
    ...


if __name__ == "__main__":
    install_plugin(
        metadata=PluginMetadata(...),
        on_start=on_start,
        import_path="my_device.domoticz",
    )

💡 Domoticz path defaults to ~/domoticz a -p option can be passed to change that.

Filtering units

You can automatically add an option to the plugin to filter created units.

To enable it, you need to implement local_tuya_domoticz_tools.UnitId and add all unit IDs, then simply pass it to the install function. UnitManager.register will handle device deletion.

Metadata

Release files for local_tuya_domoticz_tools 1.2.0

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

Source distribution (sdist)

Source distribution for local_tuya_domoticz_tools 1.2.0
File Size Uploaded Provenance Actions
local_tuya_domoticz_tools-1.2.0.tar.gz 11.3 kB Without provenance Details for local_tuya_domoticz_tools-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for local_tuya_domoticz_tools 1.2.0
File Interpreter ABI Platform Actions
local_tuya_domoticz_tools-1.2.0-py3-none-any.whl Python 3 none any Details for local_tuya_domoticz_tools-1.2.0-py3-none-any.whl

Total release size: 27.4 kB

Release files / local_tuya_domoticz_tools-1.2.0.tar.gz

Download URL local_tuya_domoticz_tools-1.2.0.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
519f0dc53ec436ecde9edfb43760ffd3f29f996655b45bff074ef10696e37682
BLAKE2b-256 checksum
How to use checksums
a5c6c1294a3ef2ee1c33a244144a63dc77257c996e0686a45d0ba72aa24aa2c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.3 Linux/6.5.0-1018-azure

Release files / local_tuya_domoticz_tools-1.2.0-py3-none-any.whl

Download URL local_tuya_domoticz_tools-1.2.0-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
428c5fd899636db1fd5fa00a9e4d5d98f123f3f25cb09dc1da35b986e1297f1a
BLAKE2b-256 checksum
How to use checksums
4f0c3ec0c8971e924d7c5e43f2a1ba8c2715eb120f8b0b770aa33a37b4cc2886
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.3 Linux/6.5.0-1018-azure

Security for local_tuya_domoticz_tools 1.2.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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