Custom LED animations - cannot import baseArray #117
-
Hi, I'm having fun getting to grips with the library and have it integrated with Home Assistant with some success. I'm trying to create a custom WS281x animation and following the steps. I've put a file customled.py containing one function into the default /etc/mqttany/led-anim directory. This requires importing the baseArray from the array/base package when starting, but this package has been imported using a relative import in anim.py and I'm not sure how to correctly import the same baseArray (contained in module located /opt/mqttany/mqttany/modules/led/array/base.py into the custom animation file located at /etc/mqttany/led-anim/customled.py. As it is I tried copying the array directory into /etc/mqttany/led-anim/customled.py and importing using the same from .array.base import baseArray but I get the following error:
This is the customled.py file I'm trying to import: from .array.base import baseArray
Could you please give a little guidance on the format of the import needed in this custom animation file? Thanks for any help. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Seems you've stumbled on some misleading documentation! You don't need to import If you want the type hints you'll have to setup your IDE to have the install path of MQTTany available and import it like this: import typing as t
if t.TYPE_CHECKING:
from modules.led.array.base import baseArray And use it like this: def anim_test(
array, # type: baseArray
cancel, # type: threading.Event
**kwargs, # type: t.Any
):
# type: (...): -> None |
Beta Was this translation helpful? Give feedback.
-
No problem, was a quick change and I'll raise as an issue. Thanks for your prompt feedback, much appreciated. |
Beta Was this translation helpful? Give feedback.
Module naming fixed in #122
Docs updated in #129