Logic Machine Forum
object correction - 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: object correction (/showthread.php?tid=5075)



object correction - benanderson_475 - 04.11.2023

Hi, 

I have an zennio knx AC interface which sometimes misses commands being sent to the AC unit, and sw obj and swfb for on/off command are different states so in some case sw is true and sw fb is off and AC is not running (so KNX sw obj has been sent but AC interface has either sent the command to the AC unit and the AC unit has not responded or AC interface has not sent it... ) 

I believe its a compatibility issue between KNX AC interface and my AC unit.

A simple off then on again for the sw obj returns the correct operation and sw and fb are the same state.  

Below is what i have thought about for an event script, may I expect to see any issue/s doing it like this? or perhaps there is better way to achieve the same? 

Code:
local AC_State = event.getvalue() -- 1/7/0 AC Switch obj bool

os.sleep(2) -- wait for fb to be changed/updated
local AC_State_FB = grp.getvalue('1/7/1') --1/7/1 AC fb obj bool

if AC_State_FB ~= AC_State then
 
  if  AC_State then
  grp.write('1/7/0',false)
  grp.write('1/7/0',true)
    end
 
  if not AC_State then 
    grp.write('1/7/0',true)
    grp.write('1/7/0',false)
    end
end 



RE: object correction - admin - 06.11.2023

Your script is executing itself when the status value is different from control. It executes two instances where both check for an opposite value. This means that one of them will fail and then will execute the same thing again.

If a single on/off or off/on is enough you can add this check to the beginning of you script. It will stop execution if this script is triggered by an event script.
Code:
if event.sender == 'se' then
  return
end

Otherwise you can use a resident script to check if status and control values are different every X seconds.