Logic Machine Forum
Problems with Script Contact Window - Protection Mode - 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: Problems with Script Contact Window - Protection Mode (/showthread.php?tid=2294)



Problems with Script Contact Window - Protection Mode - josemabera - 21.10.2019

Good morning:
  I made a script so that when a window of a room is opened, the thermostat goes into protection mode.
Once the summer is over, when the heating is switched on and the system is in heating mode the thermostat is put in protection mode even when all the windows are closed, I have no remote connection to the installation but I imagine that the problem is that since LM does not perform the Change from cooling mode to heating mode, any suggestions? 


 
The script is as follows
local ModoCalefaccion = grp.getvalue ("0/1/0")
local ModoTermostato = "6/7/1"

local tagname = 'ContatosVentanacocinasaloncomedor'


if ModoCalefaccion then

  for _, obj in ipairs(grp.tag(tagname)) do  --lee todos los objetos si se cumple la condicion (ventana abierta) pone el termostato en modo proteccion
                                              --si una vez leidos todos no se ha cumplido la condicion escribe en el modo false

                if obj.value then              --Al menos una ventana esta abierta

      grp.checkwrite(ModoTermostato ,true)

      return

    end

  end

                grp.checkwrite(ModoTermostato,false) -- Todas las ventanas estan cerrada

  end




RE: Problems with Script Contact Window - Protection Mode - Daniel - 21.10.2019

Don't you miss else before
grp.checkwrite(ModoTermostato,false)
?


RE: Problems with Script Contact Window - Protection Mode - josemabera - 21.10.2019

(21.10.2019, 08:20)Daniel. Wrote: Don't you miss else before
grp.checkwrite(ModoTermostato,false)
?

 Thank you Daniel for your response, tomorrow I will verify locally if the Script has it with "else" or as I wrote it in the post

 Thank you so much

 Regards



RE: Problems with Script Contact Window - Protection Mode - josemabera - 22.10.2019

(21.10.2019, 08:20)Daniel. Wrote: Don't you miss else before
grp.checkwrite(ModoTermostato,false)
?
 Checking the script I see ,the return causes it to exit the function so if the first one is fulfilled it does not reach the second

(21.10.2019, 08:20)Daniel. Wrote: Don't you miss else before
grp.checkwrite(ModoTermostato,false)
?
Checking the script , the return causes it to exit the function, so if the first one is fulfilled it does not reach the second.
The error was in a TAG that should not be applied in the D.G."0/1/0"

 Thank you
 B.R.