Domoticz events within Python

Python and python framework

Moderator: leecollings

Post Reply
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Domoticz events within Python

Post 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
Debian buster on NUC and three RPi with buster.
User avatar
gizmocuz
Posts: 2552
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Domoticz events within Python

Post by gizmocuz »

yes that's still true, but we're working on a better python plugin system at the moment
Quality outlives Quantity!
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: Domoticz events within Python

Post by Number8 »

Good news, thanks
Debian buster on NUC and three RPi with buster.
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Domoticz events within Python

Post 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.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: Domoticz events within Python

Post 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.
Debian buster on NUC and three RPi with buster.
User avatar
Brutus
Posts: 249
Joined: Friday 26 September 2014 9:33
Target OS: Windows
Domoticz version:
Location: Netherlands
Contact:

Re: Domoticz events within Python

Post 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
1x Intel NUC8i5BEK (Windows 10 x64) Domoticz on Virtualbox with DietPi.
1x Aeon Labs USB Z-Stick S2
1x P1 Smart Meter USB
28x Fibaro Modules
SMA Solar System
Daikin Airco / Heating
Denon DHT-S716H & DSW-1H
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Domoticz events within Python

Post 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
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: Domoticz events within Python

Post 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?
Debian buster on NUC and three RPi with buster.
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Domoticz events within Python

Post 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.
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
moroen
Posts: 408
Joined: Sunday 15 January 2017 11:06
Target OS: Linux
Domoticz version: beta
Location: Norway
Contact:

Re: Domoticz events within Python

Post 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
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: Domoticz events within Python

Post 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?
Debian buster on NUC and three RPi with buster.
bobbytux
Posts: 2
Joined: Friday 30 October 2020 17:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Domoticz events within Python

Post 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 ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest