Display time of object - 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: Display time of object (/showthread.php?tid=3769) |
RE: Display time of object - Nir70 - 29.12.2021 (29.12.2021, 16:04)admin Wrote: Make sure you use a scheduled script that runs every minute not a resident script with low or 0 sleep time. I did not understand, I used your scrap, I should change something there (in scrap)? RE: Display time of object - admin - 29.12.2021 This solution consists of two scripts: 1. Event script which saves the time when the load has been turned on 2. Scheduled script that calculates the run time every minute If you say that you get high CPU load then check that the second script is not a resident script with 0 sleep time. This is how the scheduled script should be configured: RE: Display time of object - Dré - 30.12.2021 i change my event based script (a little), i had the problem, when i again get a off on my event, i got my value twice or more 'Last Run: '..Last_Run..' on'..time so on my visualization i saw 'Last Run: Last Run: Last Run: 00:06 on Thu, 30-12 on Thu, 30-12 on Thu, 30-12' Code: Laptop_Seat = event.getvalue() --'0 WCD Woonkamer - laptoplader Seat (tm)' RE: Display time of object - admin - 05.04.2022 Modified script version that has total and current running time. 1. Add to Common functions: Code: function formattime(output, seconds) 2. Event script mapped to load on/off status: Code: value = event.getvalue() 3. Scheduled script that runs every minute (or a resident script with sleep time > 0 if finer time resolution is needed): Code: key_curr = 'ontime_curr' In both scripts key_curr, out_curr, key_total, out_total variables should be adjusted as needed. Make sure that these variables have the same values in both scripts. RE: Display time of object - Rauschentofft - 03.11.2022 Hi. How can i reset the total timer? Br MR RE: Display time of object - admin - 04.11.2022 Use this to reset the total timer: Code: key_total = 'ontime_total' RE: Display time of object - Rauschentofft - 04.11.2022 Thanks alot. I have another problem you maybe can help me with. If i have two time stamps and i want to get the difference between them. Br MR RE: Display time of object - nmedalacabeza - 01.01.2023 Code: -------------------------------------------------------------------------- Hello, it counts backwards but it doesn't keep the value that I have wrong? Could you put the hours to be subtracted in a group address? Thank you RE: Display time of object - admin - 02.01.2023 Here's a different formatting function that will only show the largest units for the time (days, hours, minutes, seconds): Code: function formattimealt(output, seconds) If you have a fixed total run time then you can use this: Code: time_total = 22 * 3600 -- 22 hours in seconds RE: Display time of object - nmedalacabeza - 02.01.2023 (02.01.2023, 08:47)admin Wrote: Here's a different formatting function that will only show the largest units for the time (days, hours, minutes, seconds): hello, in which part of the script would it go? I'm lost, one is for events and the other for residents? Thank you RE: Display time of object - Daniel - 03.01.2023 Resident/Scheduled inside the if. RE: Display time of object - nmedalacabeza - 04.01.2023 (03.01.2023, 08:58)Daniel Wrote: Resident/Scheduled inside the if. it would be like this ?? --------------------------------------Common functions ------------------------ Code: function formattimealt(output, seconds) ---------------------------------------Scheduled------------------- Code: value = event.getvalue() -------------------------------- Resident-------------------------- Code: key_curr = 'ontime_curr' Thank you RE: Display time of object - admin - 04.01.2023 Second script is event not scheduled. RE: Display time of object - nmedalacabeza - 04.01.2023 (04.01.2023, 08:56)admin Wrote: Second script is event not scheduled. Hi, I don't understand what you mean, I'm very new to lua Thank you RE: Display time of object - admin - 05.01.2023 The second script starting with "value = event.getvalue()" must be an event script (script that is triggered by an object value change). RE: Display time of object - nmedalacabeza - 07.01.2023 (05.01.2023, 08:13)admin Wrote: The second script starting with "value = event.getvalue()" must be an event script (script that is triggered by an object value change). With your indications it works more or less for me;(, group time counter is set to 0, but the one that would have to be maintained and continue subtracting also goes to 0 - Code: value = event.getvalue('32/7/9') - Code: key_curr = 'ontime_curr' Thank you RE: Display time of object - nmedalacabeza - 21.01.2023 There is no way I tried according to indications and it doesn't work for me ;( RE: Display time of object - admin - 23.01.2023 For this to work correctly some kind of external reset is also needed when the generator is fueled again. The easiest solution is to have a reset button on the visualization so the counter starts again. But the best approach would be to have a known fuel level in the generator so the process is fully automated.. RE: Display time of object - nmedalacabeza - 23.01.2023 (23.01.2023, 08:16)administración Wrote: Para que esto funcione correctamente, también se necesita algún tipo de reinicio externo cuando el generador se alimenta nuevamente. La solución más sencilla es tener un botón de reinicio en la visualización para que el contador comience de nuevo. Pero el mejor enfoque sería tener un nivel de combustible conocido en el generador para que el proceso esté completamente automatizado. This is how I have assigned the group addresses for its operation, is this what you mean? Thanks RE: Display time of object - admin - 23.01.2023 If 3/0/10 contains the current fuel level you can calculate the remaining time based on that using an event script. |