As I get further into Domoticz Im appreciating the power of dzvents. I've developed a bunch of scripts to work with PIR sensors in various rooms. As I've refined my code these scripts basically all do the same thing, but with different devices.
Rather than having a script for my bathroom, a script for the hallway etc, all containing duplicated identical logic but different devices, is it possible to have a 'generic' PIR device script that is called with parameters to specify the PIR/scenes to activate etc, so the logic is only contained in a single script?
I guess I could keep the 'on = {' section specific to each situation, but within the 'execute = {' call out to a parameterised generic helper function that contains the main bulk of the logic?
TIA
Andy.
Parameterised scripts
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Parameterised scripts
@Andyf66 ,
There are many ways to accomplish this varying from using wildcards in the on = section for the activation part, to the use of arrays, groups or description fields to identify what action should be taken for which device. Also possibilities to use datafiles, require (function) modules, global data with helper functions etc, etc..
it is more a matter of choice stress (which is probably a bad translation of the Dutch keuzestress
) than a lack of options..
There are many ways to accomplish this varying from using wildcards in the on = section for the activation part, to the use of arrays, groups or description fields to identify what action should be taken for which device. Also possibilities to use datafiles, require (function) modules, global data with helper functions etc, etc..
it is more a matter of choice stress (which is probably a bad translation of the Dutch keuzestress
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest