Feature Request: If anyof / if allof

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Haringstad
Posts: 13
Joined: Tuesday 22 November 2016 9:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Feature Request: If anyof / if allof

Post by Haringstad »

First of all, I am not a programmer, and I have some difficulties in creating scripts that use these options:

Code: Select all

if anyof

Code: Select all

if allof
This might come very handy, in for example, a presence-check:
(Example of what should happen)

Code: Select all

if anyof {devices-list} status = on then
 turn on presence switch
 elseif allof {devices-list} status = off then
 turn off presence switch
end
Some help, or implementation of this, would greatly be appreciated

Regards
Jacco
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Feature Request: If anyof / if allof

Post by tlpeter »

You can create that already if i am not mistaken.
Something like MyDevices = ('device1' and 'device2' and 'device3')
I am not sure if that is correct but it should be something like that.
Then you can call MyDevice in your script i think.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Feature Request: If anyof / if allof

Post by dannybloe »

Haringstad wrote: Tuesday 15 August 2017 9:26 First of all, I am not a programmer, and I have some difficulties in creating scripts that use these options:

Code: Select all

if anyof

Code: Select all

if allof
This might come very handy, in for example, a presence-check:
(Example of what should happen)

Code: Select all

if anyof {devices-list} status = on then
 turn on presence switch
 elseif allof {devices-list} status = off then
 turn off presence switch
end
Some help, or implementation of this, would greatly be appreciated

Regards
Jacco
Jacco, I'm not sure if I can follow what you mean. Do you want to have a way in Lua to do this?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Haringstad
Posts: 13
Joined: Tuesday 22 November 2016 9:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Feature Request: If anyof / if allof

Post by Haringstad »

Danny,

Nope, but it does exist in python.......

And I want to do this in a dzVents.

Maybe it needs a bit more explaning. With the use of the internal pinger of Domoticz, I check if certain devices are "Alive" within the network. If they are, that "Device Switch" gets switched on. Good! So, I do see a lot of switches flipping from off, to on, when I enter the house. But I am not the only person, so more devices are in the "detection" list.

If *any of those* is detected to be switched "On", flip the "Master switch: Someone at Home".

But if *all of those* are "Off", then you can set the Master switch to "off". (Or trigger the alarm to be turned on, or what you like...)

So, to make it compact, and keep it fast, that is why I had this question.....

Jacco
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Feature Request: If anyof / if allof

Post by dannybloe »

But what Lua command do you envision for this then?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
mivo
Posts: 80
Joined: Friday 21 April 2017 8:58
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Czechia
Contact:

Re: Feature Request: If anyof / if allof

Post by mivo »

Hi Jacco,

I think I understand what you mean. And what about to create function, which gets arguments: device list, how check (any / all), what check (On / Off) ?
Then in this function, make some iteration, check logic, etc. ?
Now I don't know how exactly to do it, just shallowly thinking ;)
My toys:
Raspberry Pi 3 + UPS PIco HV3.0 A Stack
Minibian (Raspbian Jessie) + Domoticz beta
RFLink 433 Gateway, 1wire DS18B20 temp sensors (GPIO)
RaZberry module + 2x Comet Z-Wave + Z-wave socket
---
Plugins: WeMo Switch, UPS PIco HV3.0A on GitHub
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Feature Request: If anyof / if allof

Post by tlpeter »

This is what you can do:

if ((phonemiguelstatus == 'On') or (phoneedastatus == 'On') or (macmiguelstatus == 'On')) and date.hour < 22 and date.hour > 6 and otherdevices['Kitchen - Router'] == 'Off' then

Replace or with and so that all devices must be On to set a switch.
This is from the wiki -> smart lua scripts.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Feature Request: If anyof / if allof

Post by dannybloe »

Or use a reducer/filter as in some of my examples.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Haringstad
Posts: 13
Joined: Tuesday 22 November 2016 9:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Feature Request: If anyof / if allof

Post by Haringstad »

Guys! THANKS! It gives me some new points of view, and I will give it a shot!

And @dannybloe, again: I am not a real programmer, so I try my best, and hope that others can help me out.... A joke: 88-2 Generaal Spoor Kazerne, 11 Pagncie, 2e Pel, Charly Group.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests