This post is not about criticism. It may be that I cannot see the wood for the trees and need help.
So I have a single perfectly running python script that controls 35 IP devices with over 100 command rules. I send the results to Domoticz dummy devices for display using json.
The python initial command rule data is pulled into an array and various subroutines do magic to send up.down/stop on/off etc at the appropriate times.
I wanted to bring the functionality into Dzvents...
There are no arrays or subroutines that I can find....
It seems impossible to directly replicate one python script with one Dzvents script.
The, as far as I can tell, lack of subroutines makes my Dzvents script(s) incredibly verbose and the lack of arrays means that I need at least one script for every device.
So what have I got so badly wrong or misunderstood? Will I be better off using LUA or something else?
Again this is not criticism of Dzvents. I either need educating or need to use a different tool.
Am I doing this wrong?
Moderator: leecollings
- jvdz
- Posts: 2334
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Am I doing this wrong?
dzvents is LUA and LUA can have functions, so I am a little lost what it is you are looking for. Any "simple" example snippet in python you can share to shows what it is you do not understand how to translate into LUA?
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 270
- Joined: Thursday 14 March 2024 10:11
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Am I doing this wrong?
I guess it is not so difficult. In dzVents you can use the lua script language. You can create arrays as you like. (Find examples here). Also you can create local or global functions.
May be I can point you to my new script with examples of all these things in Script for Airplanes.live api.
May be I can point you to my new script with examples of all these things in Script for Airplanes.live api.
Dz on Ubuntu VM on DS718+ behind FRITZ!Box.
EvoHome; MELCloud; P1 meter; Z-Stick GEN5; Z-Wave-js-ui; Sonoff USB-Dongle Plus-E; Zigbee2Mqtt; MQTT; Greenwave powernodes 1+6; Fibaro switch, plugs, smoke; FRITZ!DECT 200. Scripts listed in profile interests.
EvoHome; MELCloud; P1 meter; Z-Stick GEN5; Z-Wave-js-ui; Sonoff USB-Dongle Plus-E; Zigbee2Mqtt; MQTT; Greenwave powernodes 1+6; Fibaro switch, plugs, smoke; FRITZ!DECT 200. Scripts listed in profile interests.
-
- Posts: 96
- Joined: Monday 23 May 2016 23:07
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Am I doing this wrong?
Well thanks for the answers.
@jvdz how do functions = subroutines. I cannot find this functionality.
Anyhow here is a very simplified schema of my python script.
@janpep the example link for lua array examples gives me 3 large black circles! 
Anyhow I just found this https://www.domoticz.com/wiki/LUA_commands which I didn't know existed and I guess will help a lot and also mentions "local functions" of which I was also not aware.
Thank you for your patience.
@jvdz how do functions = subroutines. I cannot find this functionality.
Anyhow here is a very simplified schema of my python script.
Code: Select all
Python
setup array
read in data (tuples)
=========
example data for one shutter device
# device, time1, time2, offset-time, up/down-on/off, stopafterseconds,firedtoday
(1,"07:30","0",0,0,10,0),
(1,"08:00","09:00",35,0,0,0),
(1,"16:00","23:00",0,1,14,0),
(1,"17:00","23:00",70,1,13,0),
(1,"23:59","0",0,3,0,0 ),
=========
setup array2
subroutine setup action times for +-100 rules (array2) (could use single array)
every minute
index through array2
if rule=time now then
subroutine for http command or
subroutine for 433Mhz device (receive only) or
subroutine for Zigbee device
and
subroutine for json command for domoticz dummy devices
various other subroutines for housekeeping emailing telegram

Anyhow I just found this https://www.domoticz.com/wiki/LUA_commands which I didn't know existed and I guess will help a lot and also mentions "local functions" of which I was also not aware.
Thank you for your patience.
-
- Posts: 270
- Joined: Thursday 14 March 2024 10:11
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Am I doing this wrong?
As you spoke about dzVents, also see https://www.domoticz.com/wiki/DzVents:_ ... _scripting
Dz on Ubuntu VM on DS718+ behind FRITZ!Box.
EvoHome; MELCloud; P1 meter; Z-Stick GEN5; Z-Wave-js-ui; Sonoff USB-Dongle Plus-E; Zigbee2Mqtt; MQTT; Greenwave powernodes 1+6; Fibaro switch, plugs, smoke; FRITZ!DECT 200. Scripts listed in profile interests.
EvoHome; MELCloud; P1 meter; Z-Stick GEN5; Z-Wave-js-ui; Sonoff USB-Dongle Plus-E; Zigbee2Mqtt; MQTT; Greenwave powernodes 1+6; Fibaro switch, plugs, smoke; FRITZ!DECT 200. Scripts listed in profile interests.
Who is online
Users browsing this forum: No registered users and 1 guest