Logic Machine Forum
Script for Open Window - thermostat 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: Script for Open Window - thermostat protection mode (/showthread.php?tid=2115)



Script for Open Window - thermostat protection mode - Josema - 09.06.2019

Good afternoon
I have to make a script so that when the windows of the house are opened the thermostat is put in protection mode for this I have
1/1/1 heating mode true
1/1/2 window salon 1 or 1/1/3 window salon 2 o .....
then 1/1/8 protection mode thermostat salon true
also when also the 1/1/1 heating mode true
1/2/1 kitchen window 1 or 1/2/2 kitchen window 2 o ...
1/2/8 cooking thermostat protection mode true

I have an idea of how to do it but I can not make it work
Can you help me?

 BR



RE: Script for Open Window - thermostat protection mode - Erwin van der Zwart - 09.06.2019

Hi,

Here is a sample of a scheduler + twilight + overrule button logic so you can see how to build it.

The inputs 32/x/x are tagged and the script is event based attached to the same tag.

Code:
klok = '32/1/1'
schemer = '32/1/2'
overbrug = '32/1/3'
uitgang = '1/0/52'

waarde_klok = grp.getvalue(klok)
waarde_schemer = grp.getvalue(schemer)
waarde_overbrug = grp.getvalue(overbrug)
waarde_uitgang = grp.getvalue(uitgang)

if waarde_overbrug == true then
 if waarde_uitgang == false then
   grp.write(uitgang, true)
 end
else
 if waarde_klok == true and waarde_schemer == true then
   if waarde_uitgang == false then
     grp.write(uitgang, true)
   end
 else
   if waarde_uitgang == true then
     grp.write(uitgang, false)
   end
 end
end

BR,

Erwin


RE: Script for Open Window - thermostat protection mode - josemabera - 10.06.2019

(09.06.2019, 22:09)Erwin van der Zwart Wrote: Hi,

Here is a sample of a scheduler + twilight + overrule button logic so you can see how to build it.

The inputs 32/x/x are tagged and the script is event based attached to the same tag.

Code:
klok = '32/1/1'
schemer = '32/1/2'
overbrug = '32/1/3'
uitgang = '1/0/52'

waarde_klok = grp.getvalue(klok)
waarde_schemer = grp.getvalue(schemer)
waarde_overbrug = grp.getvalue(overbrug)
waarde_uitgang = grp.getvalue(uitgang)

if waarde_overbrug == true then
 if waarde_uitgang == false then
   grp.write(uitgang, true)
 end
else
 if waarde_klok == true and waarde_schemer == true then
   if waarde_uitgang == false then
     grp.write(uitgang, true)
   end
 else
   if waarde_uitgang == true then
     grp.write(uitgang, false)
   end
 end
end

BR

 Good morning Erwin:
  I appreciate very much the answer, but it's not exactly what I want to do, maybe what I want to do is easier, but it's hard for me
  What I want to do is that when the heating of the house is in "heating" mode 1/1/1 "true"
and there will be a Room Window 1/1/2 (window 1) or Window 2 of room 1/1/3 (window 2) or window "n" of the room
So
The address 1/1/8 thermostat protection mode is = true

but also in the rest of the rooms the same

  If heating mode 1/1/1 is true
and opens Window 1 of the room (1/2/1) or window 2 of the room (1/2/2) or window n of the room ...
so
the direction 1/2/8 protection mode of the thermostat is = true

  BR

  Josema



RE: Script for Open Window - thermostat protection mode - Erwin van der Zwart - 10.06.2019

Hi,

Yes i know, Normally we don't create scripts on request (simply not possible to do that for everyone) and we give samples how to achieve something..

Here is the  script you need:
Code:
heating_mode = grp.getvalue('1/1/1')
protection_mode = '1/1/8'
if heating_mode == true then
  windows = grp.tag('Window')
  windowopen = false
  for _, window in ipairs(windows) do
    if window.value == true then
      windowopen = true
      break
    end
  end 
  if windowopen then
    grp.checkwrite(protection_mode, true)
  else
    grp.checkwrite(protection_mode, false)
  end
else
  grp.checkwrite(protection_mode, false)
end
Tag your objects /script like this:

   
   

You can do this the same for another floor with second script and different (unique) TAG's.

BR,

Erwin


RE: Script for Open Window - thermostat protection mode - Josema - 10.06.2019

Hello Erwin
Thank you very much for the Script, I am very grateful to you, this script is an event script or a resident script,
I have a doubt because I have 2 thermostats to change to protection mode depending on the window that opens in the same room, so I have doubts.
Thanks again

BR

Josema


RE: Script for Open Window - thermostat protection mode - Erwin van der Zwart - 10.06.2019

Hi,

Just like the image shows the script is attached to a TAG (in this case "Heating") so event based.

All input objects are given this TAG "Heating" so if any window or heating is changing state, the scripts executes the logic. The windows are also given the TAG "Window" so the script can grab them all and check if any window is open. The output (protection object) should not have any TAG. (otherwise you create a permanent loop)

You can do this twice, One script for thermostat 1 and one script for thermostat 2. Change the TAG's to Heating1 and Heating2 and Window1 and Window2 and you have twice this logic. Make sure to change the line grp.tag('Window') to grp.tag('Window1') and in the other script grp.tag('Window2') and change the grp adresses in both scripts to the correct ones. (1/1/1 and 1/1/8)

BR,

Erwin


RE: Script for Open Window - thermostat protection mode - Josema - 10.06.2019

Hi , Erwin
I see that I have a lot to learn
Thank you

BR

Josema