Page 1 of 1

Domoticz events within Python

Posted: Sunday 18 December 2016 14:51
by Number8
Hello
Wiki has been stating for quite a long time that in order to have Python script aware of Domoticz events it has to be compiled with Python enabled http://www.domoticz.com/wiki/Events#Lua ... _Interface. I wonder if it still true and if yes whether it will be supported in a future release. Thank you

Re: Domoticz events within Python

Posted: Sunday 18 December 2016 14:52
by gizmocuz
yes that's still true, but we're working on a better python plugin system at the moment

Re: Domoticz events within Python

Posted: Sunday 18 December 2016 14:55
by Number8
Good news, thanks

Re: Domoticz events within Python

Posted: Monday 19 December 2016 3:54
by Dnpwwo
I believe the existing Python event scripting uses the older Python 2.7 as a direct alternative to Lua scripting.

It would be fairly easy change that over to use Python 3 which would make it available to a lot more people. I would be interested to know how many people use this currently and how many people would use it if it was available.

Re: Domoticz events within Python

Posted: Monday 19 December 2016 7:18
by Number8
Dnpwwo wrote:I believe the existing Python event scripting uses the older Python 2.7 as a direct alternative to Lua scripting.

It would be fairly easy change that over to use Python 3 which would make it available to a lot more people. I would be interested to know how many people use this currently and how many people would use it if it was available.
Quite difficult to know. It seems to me that Python is more widely used as a language, i.e. Having a larger installed base. I discovered it with Domoticz and found it very convenient to use with many available libraries.

Re: Domoticz events within Python

Posted: Monday 19 December 2016 18:49
by Brutus
Dnpwwo wrote:I believe the existing Python event scripting uses the older Python 2.7 as a direct alternative to Lua scripting.

It would be fairly easy change that over to use Python 3 which would make it available to a lot more people. I would be interested to know how many people use this currently and how many people would use it if it was available.
Will it be made like the current LUA and Blockly editor? I would like a python editor. It gives new opportunity's

Re: Domoticz events within Python

Posted: Monday 19 June 2017 17:40
by EdwinK
I just noticed that you have a Python option in the internal editor. Cool. I think that would make live easier for some of us

Re: Domoticz events within Python

Posted: Monday 19 June 2017 18:03
by Number8
Very cool. Does that mean that the event model is now supported within Python as it is in LUA or is it still a work in progress?
What version of Python is supported?

Re: Domoticz events within Python

Posted: Monday 19 June 2017 18:29
by Westcott
Definitely cool!
As Number8 says, plus which version of Domoticz?
Yes, please, to Python3
I enabled the example script as Device type, but no messages are logged.

Re: Domoticz events within Python

Posted: Tuesday 20 June 2017 1:13
by moroen
Hi!

The pyhton-eventsystem now uses python3, the same as the python plugin-system. Events are enabled along with plugins, it's no longer possible to enable one without the other.

The most important change is that the module now is called DomticzEvenst, and the API now uses names with the first letter in caps.

Python events currently lack some of the features of the old module, but it's a work in progress. Responding to changes in lights/dimmers/switches works, as do setting lights/dimmers. Variables are supported.In the latest betas and master branch, there are a couple of (disabled) demo-scripts in the scripts/pyhton folder...

The most prominent features lacking are most kinds of sensors (temperature etc). I plan on adding sensor-dicts to the DomoticzEvents module, but at the moment time is a bit constrained, so work on this has somewhat stalled on my part...

Regards,
M

Re: Domoticz events within Python

Posted: Tuesday 20 June 2017 7:24
by Number8
Thanks moroen for the details. I want to make sure I understand. Does that mean that most sensors do not trigger an event on change and that reading a temperature sensor (for instance) is not working yet?

Re: Domoticz events within Python

Posted: Friday 30 October 2020 20:08
by bobbytux
Hello,

just adding these lines at the begining of my scripts lets me have access to python3 on my pi :

import DomoticzEvents as DE
sys.path.append('/usr/lib/python3/dist-packages/')

Have a good day ;)