"""
{definition:s}
"""

# See https://github.com/python/cpython/issues/91375
import sys
sys.modules["_asyncio"] = None

from local_tuya.domoticz.plugin.plugin import Plugin
from local_tuya.domoticz.units import UnitCommand

from {import_path:s} import {on_start_name:s}
try:
    from {import_path:s} import {unit_ids_name:s}
except ImportError:
    {unit_ids_name:s} = None

plugin = Plugin(
    package="{package:s}",
    on_start={on_start_name:s},
    unit_ids={unit_ids_name:s},
)


def onStart() -> None:
    global plugin
    plugin.start(Parameters, Devices)


def onStop() -> None:
    global plugin
    plugin.stop()


def onHeartbeat() -> None:
    ...


def onCommand(_, unit_id, command, level, color) -> None:
    global plugin
    plugin.on_command(
        unit_id,
        UnitCommand(command, level, color),
    )
