Logic Machine Forum
Off limit display rules and time counter - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: Off limit display rules and time counter (/showthread.php?tid=5013)



Off limit display rules and time counter - fee_connect - 10.10.2023

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!


RE: Off limit display rules and time counter - Daniel - 10.10.2023

Try this to change color
https://forum.logicmachine.net/showthread.php?tid=1976&pid=20292#pid20292


RE: Off limit display rules and time counter - RomansP - 11.10.2023

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



RE: Off limit display rules and time counter - fee_connect - 11.10.2023

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?


RE: Off limit display rules and time counter - Daniel - 11.10.2023

See above, RomansP answer.


RE: Off limit display rules and time counter - fee_connect - 11.10.2023

(10.10.2023, 07:45)Daniel Wrote: Try this to change color
https://forum.logicmachine.net/showthread.php?tid=1976&pid=20292#pid20292

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


RE: Off limit display rules and time counter - fee_connect - 11.10.2023

(11.10.2023, 10:20)fee_connect Wrote:
(10.10.2023, 07:45)Daniel Wrote: Try this to change color
https://forum.logicmachine.net/showthread.php?tid=1976&pid=20292#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


RE: Off limit display rules and time counter - admin - 12.10.2023

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.