Logic Machine Forum
Email synax: messeage depending on the value of a group value - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Email synax: messeage depending on the value of a group value (/showthread.php?tid=5368)



Email synax: messeage depending on the value of a group value - cgn - 17.04.2024

Sending emails with my W4K is working. Once a day, I'd like to send an email. The message should depend on the vealue of the group values. This message should be list, of all values, which are below a certain limit - in this case 85. I tried the following code - synax error. Any idea? 

Code:
for i = 0, 30, 1 do
  SP = grp.getvalue('35/1/' ..i)
  if (SP < 85) then
    message = 'Alert: ' '35/1/' ..i '<br>'

end
end



RE: Email synax: messeage depending on the value of a group value - fleeceable - 17.04.2024

(17.04.2024, 21:36)cgn Wrote: Sending emails with my W4K is working. Once a day, I'd like to send an email. The message should depend on the vealue of the group values. This message should be list, of all values, which are below a certain limit - in this case 85. I tried the following code - synax error. Any idea? 

Code:
for i = 0, 30, 1 do
  SP = grp.getvalue('35/1/' ..i)
  if (SP < 85) then
    message = 'Alert: ' '35/1/' ..i '<br>'

end
end

...missing string concat after Alert: string...

Code:
for i = 0, 30, 1 do
  SP = grp.getvalue('35/1/' .. i)
  if (SP < 85) then
    message = 'Alert: ' .. '35/1/' .. i '<br>'
  end
end



RE: Email synax: messeage depending on the value of a group value - Erwin van der Zwart - 18.04.2024

'35/1/' ..i '<br>' Must be '35/1/' .. i .. '<br>'


RE: Email synax: messeage depending on the value of a group value - admin - 18.04.2024

Corrected version that will alert all objects that are below the threshold instead of only one:
Code:
message = ''

for i = 0, 30 do
  addr = '35/1/' .. i
  value = grp.getvalue(addr)
  
  if value < 85 then
    message = message .. 'Alert: ' .. addr .. ' = ' .. value .. '<br>\n'
  end
end

if message == '' then
  message = 'OK'
end