Page 1 of 1
Feature Request: If anyof / if allof
Posted: Tuesday 15 August 2017 9:26
by Haringstad
First of all, I am not a programmer, and I have some difficulties in creating scripts that use these options:
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
Re: Feature Request: If anyof / if allof
Posted: Tuesday 15 August 2017 10:39
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.
Re: Feature Request: If anyof / if allof
Posted: Tuesday 15 August 2017 11:05
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:
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?
Re: Feature Request: If anyof / if allof
Posted: Tuesday 15 August 2017 11:42
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
Re: Feature Request: If anyof / if allof
Posted: Tuesday 15 August 2017 11:47
by dannybloe
But what Lua command do you envision for this then?
Re: Feature Request: If anyof / if allof
Posted: Tuesday 15 August 2017 12:39
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
Re: Feature Request: If anyof / if allof
Posted: Tuesday 15 August 2017 12:43
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.
Re: Feature Request: If anyof / if allof
Posted: Tuesday 15 August 2017 12:57
by dannybloe
Or use a reducer/filter as in some of my examples.
Re: Feature Request: If anyof / if allof
Posted: Tuesday 15 August 2017 13:40
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.