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 that you accept these cookies being set.

status of 100 windows and send a command to turn off the AC
#1
Hi, 

I need to track the status of 100 windows and send a command to turn off the AC in the room where window is open. Should send command every 5 minutes until window is closed.
Ideally, I'd like to achieve this with a single script, either resident (always running) or scheduled to run periodically. This simplifies maintenance by keeping everything in one place.
I'm unsure of the best approach. I tried using repeat..until loop, but it seems to keep running even when disabled.
Another option is a resident script that checks all 100 windows every minute and sends the "off" signal to the AC if any are open. The downside here is that the script would send the signal every minute instead of the desired 5-minute interval. 

Any insights or experiences would be appreciated Smile
Reply
#2
I think you don't need use repeat..until loop, as resident script is already launched periodically by itself.
Reply
#3
Each object has Pool interval parameter where you can set time for read request sent.
------------------------------
Ctrl+F5
Reply
#4
(04.07.2024, 07:18)djaval Wrote: I think you don't need use repeat..until loop, as resident script is already launched periodically by itself.

At first I thought to use event based scripts. Sorry for the confusion in my problem description.

(04.07.2024, 07:40)Daniel Wrote: Each object has Pool interval parameter where you can set time for read request sent.

Could you please explain more about your idea?
Reply
#5
https://openrb.com/wp-content/uploads/20...3.2022.pdf
page 17
------------------------------
Ctrl+F5
Reply
#6
You can use this as a scheduled script. mapping table contains tag as a key and output address as a value.
Off is sent to the output address when at least one of the tagged objects is true. Otherwise no action is performed.

Code:
function tag_or(tag)
  local result = false
  local objects = grp.tag(tag)

  for _, object in ipairs(objects) do
    result = result or object.data
  end

  return result
end

mapping = {
  ['window1'] = '1/1/1',
  ['window2'] = '1/1/2',
  ['window3'] = '1/1/3',
  ['window4'] = '1/1/4',
}

for tag, output in pairs(mapping) do
  value = tag_or(tag)

  if value then
    grp.write(output, false)
    os.sleep(0.2)
  end
end
Reply
#7
(04.07.2024, 08:33)admin Wrote: You can use this as a scheduled script. mapping table contains tag as a key and output address as a value.
Off is sent to the output address when at least one of the tagged objects is true. Otherwise no action is performed.

Code:
function tag_or(tag)
  local result = false
  local objects = grp.tag(tag)

  for _, object in ipairs(objects) do
    result = result or object.data
  end

  return result
end

mapping = {
  ['window1'] = '1/1/1',
  ['window2'] = '1/1/2',
  ['window3'] = '1/1/3',
  ['window4'] = '1/1/4',
}

for tag, output in pairs(mapping) do
  value = tag_or(tag)

  if value then
    grp.write(output, false)
    os.sleep(0.2)
  end
end

This script is exactly what I needed. Thank you, admin!
Reply


Forum Jump: