<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title><![CDATA[LogicMachine Forum - Scripting]]></title>
		<link>https://forum.logicmachine.net/</link>
		<description><![CDATA[LogicMachine Forum - https://forum.logicmachine.net]]></description>
		<pubDate>Wed, 01 Jul 2026 22:03:53 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[mail multiple]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6492</link>
			<pubDate>Tue, 30 Jun 2026 16:49:12 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=3803">dezza@sdme.it</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6492</guid>
			<description><![CDATA[Is there a way to send an email to multiple recipients? <br />
In the to field: xxx@yyy, aaa@rrr]]></description>
			<content:encoded><![CDATA[Is there a way to send an email to multiple recipients? <br />
In the to field: xxx@yyy, aaa@rrr]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Trends manipulation / forecast]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6489</link>
			<pubDate>Mon, 29 Jun 2026 09:05:43 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=2114">epps</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6489</guid>
			<description><![CDATA[Hello there,<br />
<br />
is it possible to manipulate a Trend?<br />
I use the Weather script from the Examples. In there is a Object call: "precipitation_amount_6h". If i run the Script every hour then i have a continius forecast of 6hours of Rain.<br />
Can i manipulate a Trend to show the aktual data +6hours. So i hava a "forecast trend" ?<br />
<br />
I hope you understand what i mean.<br />
<br />
Thanks.<br />
Kind regards.<br />
Epps]]></description>
			<content:encoded><![CDATA[Hello there,<br />
<br />
is it possible to manipulate a Trend?<br />
I use the Weather script from the Examples. In there is a Object call: "precipitation_amount_6h". If i run the Script every hour then i have a continius forecast of 6hours of Rain.<br />
Can i manipulate a Trend to show the aktual data +6hours. So i hava a "forecast trend" ?<br />
<br />
I hope you understand what i mean.<br />
<br />
Thanks.<br />
Kind regards.<br />
Epps]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[New Visualization – Is HTML widget JavaScript / KNX interaction officially supported?]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6487</link>
			<pubDate>Thu, 25 Jun 2026 10:47:05 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=5871">Ahmed.K</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6487</guid>
			<description><![CDATA[Hello,<br />
I would like to clarify the supported behavior of the HTML widget in the new LogicMachine visualization.<br />
Questions<br />
<ol type="1" class="mycode_list"><li>Does the HTML widget in the new visualization support inline / embedded JavaScript execution, or is it limited to HTML/CSS rendering only? <br />
</li>
<li>Is Custom JavaScript in the new visualization supposed to interact with DOM elements created inside an HTML widget? <br />
</li>
<li>If we build a custom HTML-based interface in the new visualization, is there any officially supported way to trigger KNX writes (switch / dimming / RGB values) from that interface? <br />
</li>
<li>If not, is the recommended approach to use native LM widgets only for all control logic in the new visualization? <br />
</li>
</ol>
I would like to confirm what is officially supported before finalizing the architecture of a custom supervision page.<br />
Thank you.]]></description>
			<content:encoded><![CDATA[Hello,<br />
I would like to clarify the supported behavior of the HTML widget in the new LogicMachine visualization.<br />
Questions<br />
<ol type="1" class="mycode_list"><li>Does the HTML widget in the new visualization support inline / embedded JavaScript execution, or is it limited to HTML/CSS rendering only? <br />
</li>
<li>Is Custom JavaScript in the new visualization supposed to interact with DOM elements created inside an HTML widget? <br />
</li>
<li>If we build a custom HTML-based interface in the new visualization, is there any officially supported way to trigger KNX writes (switch / dimming / RGB values) from that interface? <br />
</li>
<li>If not, is the recommended approach to use native LM widgets only for all control logic in the new visualization? <br />
</li>
</ol>
I would like to confirm what is officially supported before finalizing the architecture of a custom supervision page.<br />
Thank you.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[cURL to LUA to set Dahua Camera parameters]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6482</link>
			<pubDate>Wed, 24 Jun 2026 10:01:58 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=5828">xtech</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6482</guid>
			<description><![CDATA[Hello! I am trying to send a curl command to a Dahua camera from LM. I have successfully tested the direct cURL command and it works as expected and we avoided extra parameter for 'globoff'. But we have difficulties in translating that into LUA language. I am trying to achieve video enable/disable by simple on-off button in the visualization so thought of using if-else statement. Would something like this work?<br />
<br />
Here is the cURL link <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>curl --digest -u "admin:xxxxxx" "http://10.0.100.10/cgi-bin/configManager.cgi?action=setConfig&amp;Encode%5b0%5d.MainFormat%5b0%5d.VideoEnable=true&amp;Encode%5b0%5d.ExtraFormat%5b0%5d.VideoEnable=true"</code></div></div><br />
Here is a code adapted from Hikvision relay thread. Not sure if I can use PUT method in our case.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>url = 'http://admin:xxxxxx@10.0.100.10/cgi-bin/'

local skthttp = require('socket.http')
local skturl = require('socket.url')
local ltn12 = require('ltn12')
local md5sum = require('encdec').md5

local value = event.getvalue()

local hash = function(...)
  return md5sum(table.concat({...}, ':'))
end

local parse_header = function(header)
  local result = {}
  for key, value in (header .. ','):gmatch('(%w+)=(.-),') do
    if value:sub(1, 1) == '"' then -- strip quotes
      result[ key:lower() ] = value:sub(2, -2)
    else
      result[ key:lower() ] = value
    end
  end
  return result
end

local make_digest_header = function(headers)
  local digest = {}
  for _, header in ipairs(headers) do
    if not header.unquote then
      header[ 2 ] = '"' .. header[ 2 ] .. '"'
    end

    digest[ #digest + 1 ] = header[ 1 ] .. '=' .. header[ 2 ]
  end
  return 'Digest ' .. table.concat(digest, ', ')
end

local _request = function(req)
  if not req.url then
    return nil, 'missing url'
  end

  local url = skturl.parse(req.url)
  local user, password = url.user, url.password
  if not user or not password then
    return nil, 'missing credentials in url'
  end

  url.user, url.password, url.authority, url.userinfo = nil, nil, nil, nil
  req.url = skturl.build(url)
  local source
  if req.source then
    local chunks = {}
    local capture = function(chunk)
      if chunk then
        chunks[ #chunks + 1 ] = chunk
      end
      return chunk
    end
    local chunk_id = 0
    source = function()
      chunk_id = chunk_id + 1
      return chunks[ chunk_id ]
    end
    req.source = ltn12.source.chain(req.source, capture)
  end
  local body, code, hdrs = skthttp.request(req)
  if code == 401 and hdrs['www-authenticate'] then
    local ht = parse_header(hdrs['www-authenticate'])
    if not ht.realm or not ht.nonce then
      return nil, 'missing realm/nonce from response'
    end
    if ht.qop ~= 'auth' then
      return nil, 'unsupported qop ' .. tostring(ht.qop)
    end
    if ht.algorithm and ht.algorithm:lower() ~= 'md5' then
      return nil, 'unsupported algo ' .. tostring(ht.algorithm)
    end
    local nc = '00000001'
    local cnonce = string.format('%08x', os.time())
    local uri = skturl.build({ path = url.path, query = url.query })
    local method = req.method or 'GET'
    local response = hash(
      hash(user, ht.realm, password),
      ht.nonce,
      nc,
      cnonce,
      'auth',
      hash(method, uri)
    )
    req.headers = req.headers or {}
    local auth = {
      { 'username', user },
      { 'realm', ht.realm },
      { 'nonce', ht.nonce },
      { 'uri', uri },
      { 'cnonce', cnonce },
      { 'nc', nc, unquote = true },
      { 'qop', 'auth' },
      { 'algorithm', 'MD5' },
      { 'response', response },
    }
    if ht.opaque then
      table.insert(auth, { 'opaque', ht.opaque })
    end
    req.headers.authorization = make_digest_header(auth)
    if not req.headers.cookie and hdrs['set-cookie'] then
      -- not really correct but enough for httpbin
      local cookie = (hdrs['set-cookie'] .. ';'):match('(.-=.-)[;,]')
      if cookie then
        req.headers.cookie = '&#36;Version: 0; ' .. cookie .. ';'
      end
    end
    if req.source then
      req.source = source
    end
    body, code, hdrs = skthttp.request(req)
  end

  return body, code, hdrs
end

local request = function(url)
  local t = type(url)
  if t == 'table' then
    return _request(table.clone(url))
  elseif t == 'string' then
    local req = {}
    local _, code, headers = _request({ url = url, sink = ltn12.sink.table(req) })
    return table.concat(req), code, headers
  end
end

if (value == true) then
res, err, hdrs = request({
  url = url,
  method = 'PUT',
  body = 'configManager.cgi?action=setConfig&amp;Encode%5b0%5d.MainFormat%5b0%5d.VideoEnable=true&amp;Encode%5b0%5d.ExtraFormat%5b0%5d.VideoEnable=true'
})
else
res, err, hdrs = request({
  url = url,
  method = 'PUT',
  body = 'configManager.cgi?action=setConfig&amp;Encode%5b0%5d.MainFormat%5b0%5d.VideoEnable=false&amp;Encode%5b0%5d.ExtraFormat%5b0%5d.VideoEnable=false'
})
end

log(res, err, hdrs)</code></div></div>]]></description>
			<content:encoded><![CDATA[Hello! I am trying to send a curl command to a Dahua camera from LM. I have successfully tested the direct cURL command and it works as expected and we avoided extra parameter for 'globoff'. But we have difficulties in translating that into LUA language. I am trying to achieve video enable/disable by simple on-off button in the visualization so thought of using if-else statement. Would something like this work?<br />
<br />
Here is the cURL link <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>curl --digest -u "admin:xxxxxx" "http://10.0.100.10/cgi-bin/configManager.cgi?action=setConfig&amp;Encode%5b0%5d.MainFormat%5b0%5d.VideoEnable=true&amp;Encode%5b0%5d.ExtraFormat%5b0%5d.VideoEnable=true"</code></div></div><br />
Here is a code adapted from Hikvision relay thread. Not sure if I can use PUT method in our case.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>url = 'http://admin:xxxxxx@10.0.100.10/cgi-bin/'

local skthttp = require('socket.http')
local skturl = require('socket.url')
local ltn12 = require('ltn12')
local md5sum = require('encdec').md5

local value = event.getvalue()

local hash = function(...)
  return md5sum(table.concat({...}, ':'))
end

local parse_header = function(header)
  local result = {}
  for key, value in (header .. ','):gmatch('(%w+)=(.-),') do
    if value:sub(1, 1) == '"' then -- strip quotes
      result[ key:lower() ] = value:sub(2, -2)
    else
      result[ key:lower() ] = value
    end
  end
  return result
end

local make_digest_header = function(headers)
  local digest = {}
  for _, header in ipairs(headers) do
    if not header.unquote then
      header[ 2 ] = '"' .. header[ 2 ] .. '"'
    end

    digest[ #digest + 1 ] = header[ 1 ] .. '=' .. header[ 2 ]
  end
  return 'Digest ' .. table.concat(digest, ', ')
end

local _request = function(req)
  if not req.url then
    return nil, 'missing url'
  end

  local url = skturl.parse(req.url)
  local user, password = url.user, url.password
  if not user or not password then
    return nil, 'missing credentials in url'
  end

  url.user, url.password, url.authority, url.userinfo = nil, nil, nil, nil
  req.url = skturl.build(url)
  local source
  if req.source then
    local chunks = {}
    local capture = function(chunk)
      if chunk then
        chunks[ #chunks + 1 ] = chunk
      end
      return chunk
    end
    local chunk_id = 0
    source = function()
      chunk_id = chunk_id + 1
      return chunks[ chunk_id ]
    end
    req.source = ltn12.source.chain(req.source, capture)
  end
  local body, code, hdrs = skthttp.request(req)
  if code == 401 and hdrs['www-authenticate'] then
    local ht = parse_header(hdrs['www-authenticate'])
    if not ht.realm or not ht.nonce then
      return nil, 'missing realm/nonce from response'
    end
    if ht.qop ~= 'auth' then
      return nil, 'unsupported qop ' .. tostring(ht.qop)
    end
    if ht.algorithm and ht.algorithm:lower() ~= 'md5' then
      return nil, 'unsupported algo ' .. tostring(ht.algorithm)
    end
    local nc = '00000001'
    local cnonce = string.format('%08x', os.time())
    local uri = skturl.build({ path = url.path, query = url.query })
    local method = req.method or 'GET'
    local response = hash(
      hash(user, ht.realm, password),
      ht.nonce,
      nc,
      cnonce,
      'auth',
      hash(method, uri)
    )
    req.headers = req.headers or {}
    local auth = {
      { 'username', user },
      { 'realm', ht.realm },
      { 'nonce', ht.nonce },
      { 'uri', uri },
      { 'cnonce', cnonce },
      { 'nc', nc, unquote = true },
      { 'qop', 'auth' },
      { 'algorithm', 'MD5' },
      { 'response', response },
    }
    if ht.opaque then
      table.insert(auth, { 'opaque', ht.opaque })
    end
    req.headers.authorization = make_digest_header(auth)
    if not req.headers.cookie and hdrs['set-cookie'] then
      -- not really correct but enough for httpbin
      local cookie = (hdrs['set-cookie'] .. ';'):match('(.-=.-)[;,]')
      if cookie then
        req.headers.cookie = '&#36;Version: 0; ' .. cookie .. ';'
      end
    end
    if req.source then
      req.source = source
    end
    body, code, hdrs = skthttp.request(req)
  end

  return body, code, hdrs
end

local request = function(url)
  local t = type(url)
  if t == 'table' then
    return _request(table.clone(url))
  elseif t == 'string' then
    local req = {}
    local _, code, headers = _request({ url = url, sink = ltn12.sink.table(req) })
    return table.concat(req), code, headers
  end
end

if (value == true) then
res, err, hdrs = request({
  url = url,
  method = 'PUT',
  body = 'configManager.cgi?action=setConfig&amp;Encode%5b0%5d.MainFormat%5b0%5d.VideoEnable=true&amp;Encode%5b0%5d.ExtraFormat%5b0%5d.VideoEnable=true'
})
else
res, err, hdrs = request({
  url = url,
  method = 'PUT',
  body = 'configManager.cgi?action=setConfig&amp;Encode%5b0%5d.MainFormat%5b0%5d.VideoEnable=false&amp;Encode%5b0%5d.ExtraFormat%5b0%5d.VideoEnable=false'
})
end

log(res, err, hdrs)</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Data/time question]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6473</link>
			<pubDate>Tue, 16 Jun 2026 05:43:03 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=1993">mrKayne</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6473</guid>
			<description><![CDATA[Hi, <br />
<br />
I'm having an issue with getting datetime. I used a script from the Logicmachine site:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>-- get current date as table
now = os.date('*t')

-- write to bus
grp.write('0/0/2', now, dt.date)
grp.write('0/0/1', now, dt.time)

-- system week day starts from sunday, convert it to knx format
wday = now.wday == 1 and 7 or now.wday - 1

--- full date bits
OCT08 = now.year - 1900
OCT07 = now.month
OCT06 = now.day
OCT05 = bit.bor(bit.lshift(wday, 5), now.hour)
OCT04 = now.min
OCT03 = now.sec
OCT02 = 0 -- subfields like working day and dst not specified in this sample
OCT01 = 0 -- subfields like quality of clock not specified in this sample

-- write to bus
date_time = string.char(OCT08, OCT07, OCT06, OCT05, OCT04, OCT03, OCT02, OCT01)
grp.write('0/0/3', date_time)</code></div></div><br />
Date and time works (0/0/2 and 0/0/1) but 0/0/3 gives no output.<br />
<br />
What am I doing wrong? <img src="https://forum.logicmachine.net/images/smilies/smile.png" alt="Smile" title="Smile" class="smilie smilie_1" /><br />
<div>
<img src="https://forum.logicmachine.net/images/attachtypes/image.png" title="PNG Image" border="0" alt=".png" />
&nbsp;&nbsp;<a href="attachment.php?aid=5027" target="_blank">Skærmbillede 2026-06-16 074212.png</a> (Size: 39.4 KB / Downloads: 51)</div>
<br />
<div>
<img src="https://forum.logicmachine.net/images/attachtypes/image.png" title="PNG Image" border="0" alt=".png" />
&nbsp;&nbsp;<a href="attachment.php?aid=5028" target="_blank">Skærmbillede 2026-06-16 074157.png</a> (Size: 11.11 KB / Downloads: 51)</div>
]]></description>
			<content:encoded><![CDATA[Hi, <br />
<br />
I'm having an issue with getting datetime. I used a script from the Logicmachine site:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>-- get current date as table
now = os.date('*t')

-- write to bus
grp.write('0/0/2', now, dt.date)
grp.write('0/0/1', now, dt.time)

-- system week day starts from sunday, convert it to knx format
wday = now.wday == 1 and 7 or now.wday - 1

--- full date bits
OCT08 = now.year - 1900
OCT07 = now.month
OCT06 = now.day
OCT05 = bit.bor(bit.lshift(wday, 5), now.hour)
OCT04 = now.min
OCT03 = now.sec
OCT02 = 0 -- subfields like working day and dst not specified in this sample
OCT01 = 0 -- subfields like quality of clock not specified in this sample

-- write to bus
date_time = string.char(OCT08, OCT07, OCT06, OCT05, OCT04, OCT03, OCT02, OCT01)
grp.write('0/0/3', date_time)</code></div></div><br />
Date and time works (0/0/2 and 0/0/1) but 0/0/3 gives no output.<br />
<br />
What am I doing wrong? <img src="https://forum.logicmachine.net/images/smilies/smile.png" alt="Smile" title="Smile" class="smilie smilie_1" /><br />
<div>
<img src="https://forum.logicmachine.net/images/attachtypes/image.png" title="PNG Image" border="0" alt=".png" />
&nbsp;&nbsp;<a href="attachment.php?aid=5027" target="_blank">Skærmbillede 2026-06-16 074212.png</a> (Size: 39.4 KB / Downloads: 51)</div>
<br />
<div>
<img src="https://forum.logicmachine.net/images/attachtypes/image.png" title="PNG Image" border="0" alt=".png" />
&nbsp;&nbsp;<a href="attachment.php?aid=5028" target="_blank">Skærmbillede 2026-06-16 074157.png</a> (Size: 11.11 KB / Downloads: 51)</div>
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[VPN]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6468</link>
			<pubDate>Fri, 12 Jun 2026 10:58:32 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=3803">dezza@sdme.it</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6468</guid>
			<description><![CDATA[Good morning, I need to use the LM also as a VPN for the internal network. Is this possible?]]></description>
			<content:encoded><![CDATA[Good morning, I need to use the LM also as a VPN for the internal network. Is this possible?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Presence simulation / os.sleep() VS sleep()]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6465</link>
			<pubDate>Thu, 11 Jun 2026 10:10:22 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=4312">_BG_</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6465</guid>
			<description><![CDATA[Hi,<br />
I'm building a presence simulation script. A resident script (60s interval) picks a random light from a list of 4, turns it on for a random time between 1–3 hours, then turns it off. Presence mode is controlled by a virtual on/off object.<br />
<br />
Logic: Presence mode ON → random lamp ON → os.sleep(random 1-3h) → lamp OFF. <br />
I've tested os.sleep() and sleep(). Both work, script DOES NOT run again (60s interval ) while "sleeping". <br />
<br />
Questions:<br />
1. What is the difference between sleep() and os.sleep()? Are there any practical differences in behaviour?<br />
2. Will os.sleep() for 1–3 hours cause any load on the LM?<br />
3. Is resident script the right approach for this, or is there a better way?<br />
<br />
Thanks!<br />
<br />
BG<br />
<br />
<br />
PS. I know there is a dedicated app for presence simulation, but I have specific client requirements that need a custom implementation.<br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>--------------------------------------------------
-- Presence simulation
--------------------------------------------------
local lights = {
  { addr = '40/3/1', name = 'lamp 1' },
  { addr = '40/3/2', name = 'lamp 2' },
  { addr = '40/3/3', name = 'lamp 3 '},
  { addr = '40/3/4', name = 'lamp 4' },
}

local active = grp.getvalue('40/3/10') -- presence mode ON/OFF
if not active then return end

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

math.randomseed(os.time())

local pick   &nbsp;&nbsp;= lights[ math.random(#lights) ]
local duration = math.random(3600, 10800)

log('Presence simulation -&gt; ON  ' .. pick.name .. '  ' .. math.floor(duration / 60) .. ' min')
grp.write(pick.addr, true)

os.sleep(duration)

grp.write(pick.addr, false)
log('Presence simulation -&gt; OFF ' .. pick.name)</code></div></div>]]></description>
			<content:encoded><![CDATA[Hi,<br />
I'm building a presence simulation script. A resident script (60s interval) picks a random light from a list of 4, turns it on for a random time between 1–3 hours, then turns it off. Presence mode is controlled by a virtual on/off object.<br />
<br />
Logic: Presence mode ON → random lamp ON → os.sleep(random 1-3h) → lamp OFF. <br />
I've tested os.sleep() and sleep(). Both work, script DOES NOT run again (60s interval ) while "sleeping". <br />
<br />
Questions:<br />
1. What is the difference between sleep() and os.sleep()? Are there any practical differences in behaviour?<br />
2. Will os.sleep() for 1–3 hours cause any load on the LM?<br />
3. Is resident script the right approach for this, or is there a better way?<br />
<br />
Thanks!<br />
<br />
BG<br />
<br />
<br />
PS. I know there is a dedicated app for presence simulation, but I have specific client requirements that need a custom implementation.<br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>--------------------------------------------------
-- Presence simulation
--------------------------------------------------
local lights = {
  { addr = '40/3/1', name = 'lamp 1' },
  { addr = '40/3/2', name = 'lamp 2' },
  { addr = '40/3/3', name = 'lamp 3 '},
  { addr = '40/3/4', name = 'lamp 4' },
}

local active = grp.getvalue('40/3/10') -- presence mode ON/OFF
if not active then return end

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

math.randomseed(os.time())

local pick   &nbsp;&nbsp;= lights[ math.random(#lights) ]
local duration = math.random(3600, 10800)

log('Presence simulation -&gt; ON  ' .. pick.name .. '  ' .. math.floor(duration / 60) .. ' min')
grp.write(pick.addr, true)

os.sleep(duration)

grp.write(pick.addr, false)
log('Presence simulation -&gt; OFF ' .. pick.name)</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[curl to post value to TRMNL api]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6463</link>
			<pubDate>Thu, 11 Jun 2026 06:41:26 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=2913">Pierre</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6463</guid>
			<description><![CDATA[Hello,<br />
<br />
I want to send data to TRMNL server<br />
<br />
this curl command is ok : <br />
<br />
curl "https://trmnl.com/api/custom_plugins/xxxxxxxxxxxxxxxxxxxxxxxxxxx\<br />
  -H "Content-Type: application/json" \<br />
  -d '{"merge_variables": {"text":"Test", "author": "Pierre"}}' \<br />
  -X POST<br />
<br />
but my lua code don't work:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>-- Load modules
https = require('ssl.https')
ltn12 = require('ltn12')
json = require('json')

body ='{"merge_variables": {"text":"Test", "author": "Pierre"}}'

resp = {}
  body = json.encode(Body) 
  res, code, headers = https.request({
    url = 'https://trmnl.com/api/custom_plugins/xxxxxxxxxxxxxxxxxxxxxxxxxxx',
    method = 'POST',
    source = ltn12.source.string(body),
    sink = ltn12.sink.table(resp),
    headers = { 
                ['Content-Type'] = 'application/json',
                ['Content-Length'] = #body  
              }
  })
  -- handle feedback
  
    resp = table.concat(resp)
    resp = json.pdecode(resp)
  log(resp</code></div></div><br />
i have this error: Must be nested inside a merge_variables payload object<br />
could you can help me please.]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
I want to send data to TRMNL server<br />
<br />
this curl command is ok : <br />
<br />
curl "https://trmnl.com/api/custom_plugins/xxxxxxxxxxxxxxxxxxxxxxxxxxx\<br />
  -H "Content-Type: application/json" \<br />
  -d '{"merge_variables": {"text":"Test", "author": "Pierre"}}' \<br />
  -X POST<br />
<br />
but my lua code don't work:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>-- Load modules
https = require('ssl.https')
ltn12 = require('ltn12')
json = require('json')

body ='{"merge_variables": {"text":"Test", "author": "Pierre"}}'

resp = {}
  body = json.encode(Body) 
  res, code, headers = https.request({
    url = 'https://trmnl.com/api/custom_plugins/xxxxxxxxxxxxxxxxxxxxxxxxxxx',
    method = 'POST',
    source = ltn12.source.string(body),
    sink = ltn12.sink.table(resp),
    headers = { 
                ['Content-Type'] = 'application/json',
                ['Content-Length'] = #body  
              }
  })
  -- handle feedback
  
    resp = table.concat(resp)
    resp = json.pdecode(resp)
  log(resp</code></div></div><br />
i have this error: Must be nested inside a merge_variables payload object<br />
could you can help me please.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Tag triggered script but only on value change]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6456</link>
			<pubDate>Tue, 09 Jun 2026 11:03:03 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=3682">Ceros2112</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6456</guid>
			<description><![CDATA[Hello,<br />
<br />
is it possible to trigger an event script based on tag objects but only if the value of that single object is changed?<br />
<br />
for example, I have some objects with cyclic send and I want to trigger the script only when the value change<br />
<br />
thank you]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
is it possible to trigger an event script based on tag objects but only if the value of that single object is changed?<br />
<br />
for example, I have some objects with cyclic send and I want to trigger the script only when the value change<br />
<br />
thank you]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Scheduler Trend]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6454</link>
			<pubDate>Mon, 08 Jun 2026 14:47:52 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=3803">dezza@sdme.it</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6454</guid>
			<description><![CDATA[Good morning, is it possible to create a monthly schedule to send trend CSV data via Telegram or email?]]></description>
			<content:encoded><![CDATA[Good morning, is it possible to create a monthly schedule to send trend CSV data via Telegram or email?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Auth via URL for a custom app API]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6448</link>
			<pubDate>Mon, 01 Jun 2026 15:01:49 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=3682">Ceros2112</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6448</guid>
			<description><![CDATA[Hello,<br />
<br />
I'm building a custom app with a simple UI that stores some data in a database table but also needs to act as a server that passes those data in JSON format to other lm5s with a custom API request.<br />
<br />
As the app is the endpoint of that http request, I need to authenticate my client to be able to access the app but I can't simply pass user:password in the url, right?<br />
<br />
Is there a way to do it?<br />
<br />
Thank you for your help]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
I'm building a custom app with a simple UI that stores some data in a database table but also needs to act as a server that passes those data in JSON format to other lm5s with a custom API request.<br />
<br />
As the app is the endpoint of that http request, I need to authenticate my client to be able to access the app but I can't simply pass user:password in the url, right?<br />
<br />
Is there a way to do it?<br />
<br />
Thank you for your help]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Script checking tagcache]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6445</link>
			<pubDate>Thu, 28 May 2026 09:27:50 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=495">Trond Hoyem</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6445</guid>
			<description><![CDATA[Hi<br />
<br />
I want to, in a loop, check a lot of adresses based on the content of the tagcache. I know that I can create a table with all objects with a certain tag by using the obj = grp.tag(), but I want to check for more than one spesifik tag within a range of objects where some can have "tag1, tag2, tag3" etc, and others maybe just "tag1".<br />
<br />
Is there some kind of wildcard I can use for this, like '*tag1*' in the script?<br />
<br />
I have a SQL query that finds all the objects I want to check. Within that rage I want to do different things with the objects depending on which tags are on each object. <br />
<br />
Example; all objects containing "tag2"; switch on to 30%, all other objects; switch OFF.]]></description>
			<content:encoded><![CDATA[Hi<br />
<br />
I want to, in a loop, check a lot of adresses based on the content of the tagcache. I know that I can create a table with all objects with a certain tag by using the obj = grp.tag(), but I want to check for more than one spesifik tag within a range of objects where some can have "tag1, tag2, tag3" etc, and others maybe just "tag1".<br />
<br />
Is there some kind of wildcard I can use for this, like '*tag1*' in the script?<br />
<br />
I have a SQL query that finds all the objects I want to check. Within that rage I want to do different things with the objects depending on which tags are on each object. <br />
<br />
Example; all objects containing "tag2"; switch on to 30%, all other objects; switch OFF.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Automatic holidays calendar]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6440</link>
			<pubDate>Tue, 26 May 2026 09:02:34 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=3682">Ceros2112</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6440</guid>
			<description><![CDATA[Hello,<br />
<br />
one of my customer is asking if there is a way to change the holidays calendar automatically by year (let' s pretend that I can retrieve this information somehow  <img src="https://forum.logicmachine.net/images/smilies/confused.png" alt="Confused" title="Confused" class="smilie smilie_13" /> )<br />
<br />
for example: he wants to change the holiday schedule automatically with every non working day in Italy in 2026, next year it will be updated.<br />
<br />
I know, it's a crazy request.<br />
<br />
Thank you for your help.]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
one of my customer is asking if there is a way to change the holidays calendar automatically by year (let' s pretend that I can retrieve this information somehow  <img src="https://forum.logicmachine.net/images/smilies/confused.png" alt="Confused" title="Confused" class="smilie smilie_13" /> )<br />
<br />
for example: he wants to change the holiday schedule automatically with every non working day in Italy in 2026, next year it will be updated.<br />
<br />
I know, it's a crazy request.<br />
<br />
Thank you for your help.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Filter tags for differentiated EMAIL and SMS sending]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6437</link>
			<pubDate>Fri, 22 May 2026 14:18:31 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=2310">Frank68</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6437</guid>
			<description><![CDATA[Hi <br />
I would like to try to differentiate between sending emails and text messages based on the tags in the subject that triggers the alarm.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>&nbsp;&nbsp;&nbsp;&nbsp;for i, tag in ipairs(tags) do
&nbsp;&nbsp;&nbsp;&nbsp;  if tag == 'MEC' then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- ASSEGNO LISTA MAIL DA UTILIZZARE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iddest = emailsMAN
&nbsp;&nbsp;&nbsp;&nbsp;  elseif tag == 'ELE' then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iddest = emailsVIS2
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- COMPILARE LISTA MAIL PER CUI ALLARME E ATTIVO
&nbsp;&nbsp;&nbsp;&nbsp;  elseif tag == 'TEC' then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iddest = emailsALL
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- COMPILARE LISTA MAIL PER CUI ALLARME E ATTIVO
&nbsp;&nbsp;&nbsp;&nbsp;  elseif tag == 'ALL' then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iddest = emailsALL
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- COMPILARE LISTA MAIL PER CUI ALLARME E ATTIVO&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;  else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- COMPILARE LISTA MAIL PER CUI ALLARME E ATTIVO    
&nbsp;&nbsp;&nbsp;&nbsp;  end 
&nbsp;&nbsp;&nbsp;&nbsp;end&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;-- verificare indirizzi a cui mandare mail
&nbsp;&nbsp;&nbsp;&nbsp;    emails = {}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      -- verifico indirizzi per MAIL
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (grp.getvalue('32/1/29') == true) then
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maddr= grp.getvalue('32/1/1')</code></div></div>I was thinking of using this code, but I don't know how to pass the group to the email address. I wanted to know if there was a way to assign TAGS to the email address, then compare the matches, add them to the address list, and finally check the various lists. If the length is &gt;0, send emails to the lists, sending for all the lists.<br />
<br />
Could this be a solution?<br />
<br />
Thank you very much.]]></description>
			<content:encoded><![CDATA[Hi <br />
I would like to try to differentiate between sending emails and text messages based on the tags in the subject that triggers the alarm.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>&nbsp;&nbsp;&nbsp;&nbsp;for i, tag in ipairs(tags) do
&nbsp;&nbsp;&nbsp;&nbsp;  if tag == 'MEC' then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- ASSEGNO LISTA MAIL DA UTILIZZARE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iddest = emailsMAN
&nbsp;&nbsp;&nbsp;&nbsp;  elseif tag == 'ELE' then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iddest = emailsVIS2
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- COMPILARE LISTA MAIL PER CUI ALLARME E ATTIVO
&nbsp;&nbsp;&nbsp;&nbsp;  elseif tag == 'TEC' then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iddest = emailsALL
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- COMPILARE LISTA MAIL PER CUI ALLARME E ATTIVO
&nbsp;&nbsp;&nbsp;&nbsp;  elseif tag == 'ALL' then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iddest = emailsALL
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- COMPILARE LISTA MAIL PER CUI ALLARME E ATTIVO&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;  else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- COMPILARE LISTA MAIL PER CUI ALLARME E ATTIVO    
&nbsp;&nbsp;&nbsp;&nbsp;  end 
&nbsp;&nbsp;&nbsp;&nbsp;end&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;-- verificare indirizzi a cui mandare mail
&nbsp;&nbsp;&nbsp;&nbsp;    emails = {}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      -- verifico indirizzi per MAIL
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (grp.getvalue('32/1/29') == true) then
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maddr= grp.getvalue('32/1/1')</code></div></div>I was thinking of using this code, but I don't know how to pass the group to the email address. I wanted to know if there was a way to assign TAGS to the email address, then compare the matches, add them to the address list, and finally check the various lists. If the length is &gt;0, send emails to the lists, sending for all the lists.<br />
<br />
Could this be a solution?<br />
<br />
Thank you very much.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Converting 1-byte object to several 1-bit status object]]></title>
			<link>https://forum.logicmachine.net/showthread.php?tid=6433</link>
			<pubDate>Wed, 20 May 2026 07:33:57 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.logicmachine.net/member.php?action=profile&uid=180">stonecroft</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.logicmachine.net/showthread.php?tid=6433</guid>
			<description><![CDATA[Hello all.<br />
<br />
I get feedback from a pharos lightning controller (from 0 to lets say 100) and want to convvert it to status object in knx.<br />
<br />
The code below is working fine but I have some status that should be True if "status" = 31, if "status" is betwen 41-45 nothing shall happen and if "status" is any other  number status should be False.<br />
<br />
How to do that?<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>status = event.getvalue()

if (status == 17 ) then
&nbsp;&nbsp;grp.checkwrite('STATUS_SCEN1', true)
else
  grp.checkwrite('STATUS_SCEN1', false)
end

if (status == 18 ) then
&nbsp;&nbsp;grp.checkwrite('STATUS_SCEN2', true)
else
  grp.checkwrite('STATUS_SCEN2', false)
end

if (status == 19 ) then
&nbsp;&nbsp;grp.checkwrite('STATUS_SCEN3', true)
else
  grp.checkwrite('STATUS_SCEN3', false)
end</code></div></div>]]></description>
			<content:encoded><![CDATA[Hello all.<br />
<br />
I get feedback from a pharos lightning controller (from 0 to lets say 100) and want to convvert it to status object in knx.<br />
<br />
The code below is working fine but I have some status that should be True if "status" = 31, if "status" is betwen 41-45 nothing shall happen and if "status" is any other  number status should be False.<br />
<br />
How to do that?<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>status = event.getvalue()

if (status == 17 ) then
&nbsp;&nbsp;grp.checkwrite('STATUS_SCEN1', true)
else
  grp.checkwrite('STATUS_SCEN1', false)
end

if (status == 18 ) then
&nbsp;&nbsp;grp.checkwrite('STATUS_SCEN2', true)
else
  grp.checkwrite('STATUS_SCEN2', false)
end

if (status == 19 ) then
&nbsp;&nbsp;grp.checkwrite('STATUS_SCEN3', true)
else
  grp.checkwrite('STATUS_SCEN3', false)
end</code></div></div>]]></content:encoded>
		</item>
	</channel>
</rss>