This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

Script for Open Window - thermostat protection mode
#1
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
Reply
#2
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
Reply
#3
(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
Reply
#4
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
Reply
#5
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
Reply
#6
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
Reply
#7
Hi , Erwin
I see that I have a lot to learn
Thank you

BR

Josema
Reply


Forum Jump: