This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Multiple Value true
#1
Hello,
I would like to make an event script on an alarm address. This script sent the status of the windows that would be open at this time. The problem in the script I could create is that as soon as the first window is open then the script stops.

alarm grp.getvalue = ( '...')
windows1 = grp.getvalue ( '...')
w2 =
w3 =
...
w50 =
if alarm == true and windows1 == true then
log (test)
elseif alarm == true and windows 2 == true then
log (test2) ..... etc
I would like to be able to send an email indicating the window 1, the window 2 and the window 32 are open.


Best regards.
Reply
#2
First use (for) and increment adress for knx (its better for script)

exemple :

--------------------------------------------------------
windows_number = 50

windows{}

For a = 0,Windows_number,1 do

windows[a] = grp.getvalue('0/0/'..tonumber(a))
os.sleep(0.2)

end

message = windows

if windows[1] == true then
message =message + ' 1'
end

if windows[2] == true then
message =message + ', 2'
end

if windows[32] == true then
message =message + ' ,32'
end

message = message + ' is open'

--------------------------------------------------------

then use mail function

Best regard

Give me the knx adress (alarme and all windows ) and i will write a script for you (whith mail )
Reply
#3
You should tag window status objects and use grp.tag to find out if which ones are open.
Reply
#4
As admin mention do it like that. Tag all windows and put tag in this script.  Add description to windows object, this will be displayed in email as window name.

Code:
tagname = 'windows'

windows=''
for i, object in ipairs(grp.tag(tagname)) do
 if object.value then
   windows= windows .. object.comment..', '
 end
end
-- make sure mail settings are set in user function library before using this function
subject = 'E-mail test'
message = 'open windows are '..windows
mail('user@example.com', subject, message)
------------------------------
Ctrl+F5
Reply
#5
(24.01.2019, 15:14)Daniel. Wrote: As admin mention do it like that. Tag all windows and put tag in this script.  Add description to windows object, this will be displayed in email as window name.

Code:
tagname = 'windows'

windows=''
for i, object in ipairs(grp.tag(tagname)) do
 if object.value then
   windows= windows .. object.comment..', '
 end
end
-- make sure mail settings are set in user function library before using this function
subject = 'E-mail test'
message = 'open windows are '..windows
mail('user@example.com', subject, message)

Perfect Thank you.
B.R.
Reply
#6
I have a second question about comparing an address with its old value. I explain myself I have an event script (on TAG) with two addresses. I send an email as soon as the address goes to 10 (2 Byte signed integer). The value 10 indicates a fault. I would like to send the return to the proper functioning after the passage of 10 to some other value. For example value 10 then sending mail, change to value 5 (after value 10) then send a second mail. On the other hand passage from 5 to 0 or 0 to 5 we do nothing ...

FAULT1 = grp.getvalue('14/1/34') -- Status FAULT1
FAULT2 = grp.getvalue('13/1/34') -- Status FAULT2


subject = 'FAULT'
message = 'FAULT'

subject1 = 'OK'
message1 = 'OK'

if FAULT1 == 10 or FAULT2 == 10 then
 mail('@', subject, message)
 
--elseif FAULT1 ~= 10 and FAULT2 ~= 10 then
--  mail('alertes@test', subject1, message1)
 
end

with this script the sending of the second mail is systematic during a change of state different from 10

Do you have to compare the event.dst value with the old value given that I have several group addresses on this tag? Thank you.
Best regards
Reply
#7
You need to use storage to save current fault state so message is sent only once on status change:
Code:
FAULT1 = grp.getvalue('14/1/34') -- Status FAULT1
FAULT2 = grp.getvalue('13/1/34') -- Status FAULT2

fault_status = storage.get('fault_status', false)

subject = 'FAULT'
message = 'FAULT'

subject1 = 'OK'
message1 = 'OK'

if FAULT1 == 10 or FAULT2 == 10 then
  if not fault_status then
    mail('test@test.com', subject, message)
    storage.set('fault_status', true)
  end
else
  if fault_status then
    mail('test@test.com', subject1, message1)
    storage.set('fault_status', false)
  end
end
Reply
#8
(25.01.2019, 08:58)admin Wrote: You need to use storage to save current fault state so message is sent only once on status change:
Code:
FAULT1 = grp.getvalue('14/1/34') -- Status FAULT1
FAULT2 = grp.getvalue('13/1/34') -- Status FAULT2

fault_status = storage.get('fault_status', false)

subject = 'FAULT'
message = 'FAULT'

subject1 = 'OK'
message1 = 'OK'

if FAULT1 == 10 or FAULT2 == 10 then
 if not fault_status then
   mail('@', subject, message)
   storage.set('fault_status', true)
 end
else
 if fault_status then
   mail('@', subject1, message1)
   storage.set('fault_status', false)
 end
end

Perfect as always.
Thank you so much.
B.R.
Reply


Forum Jump: