Page 1 of 1

New plugin development questions

Posted: Monday 20 September 2021 12:26
by pgielen
I am not an experienced Python developer, but using the plugin.py template mentioned in the Domoticz Wiki, I am trying to develop a new hardware plugin based on a standalone Python script that is running fine from the command line of my RPi4B.

Unfortunately, in Domoticz I am running into problems right away. After installation of the plugin from the hardware tab, I get error messages. Are there limitation as to what libs you can import? Apart from the Domoticz and sys lib, I have added:

import aiohttp
import asyncio
import pysmartthings

These libs have been installed in Python3.7 from the CLI first.

The log says:

2021-09-20 12:05:56.549 Error: STEST1A: (SmartThings) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/smartthings/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'.
2021-09-20 12:05:56.549 Error: STEST1A: (STEST1A) Module Import failed, exception: 'SyntaxError'
2021-09-20 12:05:56.549 Error: STEST1A: (STEST1A) Import detail: File: , Line: 49, offset: 8
2021-09-20 12:05:56.549 Error: STEST1A: (STEST1A) Error Line ' async with aiohttp.ClientSession() as session:
2021-09-20 12:05:56.549 Error: STEST1A: (STEST1A) No traceback available

Line 49 is in this section in which I try to fill an array with available devices of my SmartThings setup on start:

Code: Select all

    def onStart(self):
        Domoticz.Log("onStart called")
        async with aiohttp.ClientSession() as session:
          api = pysmartthings.SmartThings(session, tokenSmartThings) 
          devices = await api.devices() 
It looks like the asyncio and/or the aiohttp lib is not loaded. Or did I make a mistake?

Re: New plugin development questions

Posted: Monday 20 September 2021 16:37
by waltervl
I am not sure (also no Python developer) but I think you have to use the Plugin Framework Connections method.
https://www.domoticz.com/wiki/Developin ... onnections

https://github.com/domoticz/domoticz/bl ... es/HTTP.py

At least if you are connecting to an extrnal site...

Re: New plugin development questions

Posted: Monday 20 September 2021 20:35
by breizhcat
Hi

I had the same issue with one library that i have installed through pip.
Unable to use it within my plugin. As it was a tiny library i put it directy into my plugin.py file as workaround.

I would like to have feedback and maybe a solution.

Br

Envoyé de mon Mi 9T Pro en utilisant Tapatalk