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.

Off limit display rules and time counter
#1
Hi there,

I have an air quality sensor giving me temperature, humidity and CO2 concentration. limits have been set for good air quality,
I need to realise 2 functions:
- when the variable goes off limit, the font colour needs to change to red
- I need to display for each the number of hour each year the variable was off limits, and reset it on Jan 1st.

Have you done something similar?

Thanks!
Reply
#2
Try this to change color
https://forum.logicmachine.net/showthrea...2#pid20292
------------------------------
Ctrl+F5
Reply
#3
Hello, fee_connect

Here is a script for hour counter.

Code:
value = grp.getvalue('38/1/4')
limit = 50

year = os.date('%Y')
key = 'counter_' .. year

if value > limit then
  minutes = storage.exec('incr', key)
  hours = math.round(minutes / 60)
  grp.checkupdate('38/1/6', hours)
end
Reply
#4
Thanks a lot Daniel! that does the job just fine.

and about the count of the number of hours off limit, what lua function shall I use?
Reply
#5
See above, RomansP answer.
------------------------------
Ctrl+F5
Reply
#6
(10.10.2023, 07:45)Daniel Wrote: Try this to change color
https://forum.logicmachine.net/showthrea...2#pid20292

Oh, thanks RomansP, I had not seen your post. I will try it tonight!
Reply
#7
(11.10.2023, 10:20)fee_connect Wrote:
(10.10.2023, 07:45)Daniel Wrote: Try this to change color
https://forum.logicmachine.net/showthrea...2#pid20292

Oh, thanks RomansP, I had not seen your post. I will try it tonight!

Well, I'm not quite there yet, the counter has not updated in spite off several hours with ppm over the limit. I'm looking into it, will telll you
Reply
#8
This code is meant to be used in a scheduled script that runs every minute. Set Minute, Hour and Day of the month to * in script configuration.
Reply


Forum Jump: