27.02.2022, 15:50
Code:
-- Comfort alarm for room 9. All adresses for room 9 = X / X / 9.
-- Thresholds for alarm
MaxCo2 = 800
MaxTemp = 25
MinTemp = 20
MaxHum = 60
MinHum = 40
-- Get co2, temperature and humidity values
Co2 = grp.getvalue('12/1/9')
Temp = grp.getvalue('6/1/9')
Humidity = grp.getvalue('13/1/9')
ComfortAlarm = grp.getvalue('25/1/9')
-- Check if values are within the thresholds
if Co2 > MaxCo2 or Temp > MaxTemp or Temp < MinTemp or Humidity > MaxHum or Humidity < MinHum then
-- Sets alarm on or off
if ComfortAlarm == false then
grp.write('25/1/9', 1)
else
end
else
if
ComfortAlarm == true then
grp.write('25/1/9', 0)
end
end
I have made a script to set a comfort alarm if Co2, room temperature or humidity is not within threshold values. This works fine.
The group adress structure in my project is that all adresses to one room = X / X / room number. So for the code above its a comfort alarm for room number 9.
Example Co2 in room number 9 is 12/1/9. Co2 in room 24 is 12/1/24. So main group and middle group is all the same in every room.
My question is if its possible to make a loop to run through every room checking the same adresses and setting the same alarm for each room?
So alarm for room 9 would set 25/1/9, and alarm for room 60 would set 25/1/60.
All help would be appreciated