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.

Display time of object
#32
(03.01.2023, 08:58)Daniel Wrote: Resident/Scheduled inside the if.

it would be like this ??

--------------------------------------Common functions ------------------------

Code:
function formattimealt(output, seconds)   local minutes = math.floor(seconds / 60)   local hours = math.floor(minutes / 60)   local days = math.floor(hours / 24)   local res   seconds = seconds % 60   minutes = minutes % 60   hours = hours % 24   if days > 0 then     res = days .. 'd'   elseif hours > 0 then     res = hours .. 'h'   elseif minutes > 0 then     res = minutes .. 'm'   else     res = seconds .. 's'   end     grp.update(output, res) end

---------------------------------------Scheduled-------------------
Code:
value = event.getvalue() key_curr = 'ontime_curr' out_curr = '33/1/2'       -- Time on Grupo Electrogeno key_total = 'ontime_total' out_total = '33/1/1'      -- Total on time de Encendido Grupo Electrogeno time_total = '33/1/3'   --- total hours to deduct time = storage.get(key_curr) now = os.time() if value then   if not time then     storage.set(key_curr, now)     formattime(out_curr, 0)   end else   if time then     time_total = storage.exec('incrby', key_total, now - time)     formattime(out_total, time_total)         storage.delete(key_curr)   end   grp.update(out_curr, '') end

-------------------------------- Resident--------------------------


Code:
key_curr = 'ontime_curr' out_curr = '33/1/2'       -- Time on Grupo Electrogeno Grupo Electrogeno key_total = 'ontime_total' out_total = '33/1/1'      -- Time on Grupo Electrogeno Grupo Electrogeno time_total = '33/1/3'   --- total hours to deduct time_curr = storage.get(key_curr) if time_curr then     time_curr = os.time() - time_curr   formattime(out_curr, time_curr)     time_total = 22 * 3600 -- 22 hours in seconds time_remaining = math.max(0, time_total - time_curr)   formattimealt(out_total, time_remaining) end

Thank you
Reply


Messages In This Thread
Display time of object - by Nir70 - 22.12.2021, 17:50
RE: Display time of object - by admin - 23.12.2021, 08:41
RE: Display time of object - by Nir70 - 23.12.2021, 08:47
RE: Display time of object - by admin - 23.12.2021, 09:32
RE: Display time of object - by Nir70 - 23.12.2021, 11:22
RE: Display time of object - by Dré - 27.12.2021, 15:03
RE: Display time of object - by admin - 23.12.2021, 11:46
RE: Display time of object - by Nir70 - 23.12.2021, 12:21
RE: Display time of object - by admin - 23.12.2021, 12:30
RE: Display time of object - by Dré - 24.12.2021, 15:49
RE: Display time of object - by khalil - 26.12.2021, 08:28
RE: Display time of object - by Nir70 - 23.12.2021, 14:49
RE: Display time of object - by admin - 23.12.2021, 14:52
RE: Display time of object - by Nir70 - 23.12.2021, 16:50
RE: Display time of object - by admin - 24.12.2021, 08:51
RE: Display time of object - by Nir70 - 27.12.2021, 20:25
RE: Display time of object - by admin - 28.12.2021, 08:31
RE: Display time of object - by Dré - 28.12.2021, 12:34
Display time of object - PCU heat - by Nir70 - 29.12.2021, 15:59
RE: Display time of object - by admin - 29.12.2021, 16:04
RE: Display time of object - by Nir70 - 29.12.2021, 16:19
RE: Display time of object - by admin - 29.12.2021, 16:35
RE: Display time of object - by Dré - 30.12.2021, 13:24
RE: Display time of object - by admin - 05.04.2022, 13:02
RE: Display time of object - by Rauschentofft - 03.11.2022, 23:35
RE: Display time of object - by admin - 04.11.2022, 08:26
RE: Display time of object - by Rauschentofft - 04.11.2022, 09:26
RE: Display time of object - by nmedalacabeza - 01.01.2023, 18:31
RE: Display time of object - by admin - 02.01.2023, 08:47
RE: Display time of object - by nmedalacabeza - 02.01.2023, 19:21
RE: Display time of object - by Daniel - 03.01.2023, 08:58
RE: Display time of object - by nmedalacabeza - 04.01.2023, 08:54
RE: Display time of object - by admin - 04.01.2023, 08:56
RE: Display time of object - by nmedalacabeza - 04.01.2023, 10:50
RE: Display time of object - by admin - 05.01.2023, 08:13
RE: Display time of object - by nmedalacabeza - 07.01.2023, 17:28
RE: Display time of object - by nmedalacabeza - 21.01.2023, 20:35
RE: Display time of object - by admin - 23.01.2023, 08:16
RE: Display time of object - by nmedalacabeza - 23.01.2023, 16:28
RE: Display time of object - by admin - 23.01.2023, 16:32
RE: Display time of object - by nmedalacabeza - 23.01.2023, 16:54
RE: Display time of object - by admin - 24.01.2023, 07:10

Forum Jump: