Time dependent script - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Time dependent script (/showthread.php?tid=139) |
Time dependent script - FatMax - 18.11.2015 I´m not too familiar with Lua as a scripting language, and my brief investigation into the script functions leaves some questions un-answered. I would like some PIR´s to control lights in common areas and bathrooms dependent on time of day. If its night/early morning, I would like one value to be sent to the dimmer, and the rest of the day a different value. The only time functions I´ve seen so far, is timers. I would also like to send system time to the bus, but haven't yet found how to do that. Any input? RE: Time dependent script - admin - 19.11.2015 I guess you need something like this in your script: Code: date = os.date('*t') RE: Time dependent script - FatMax - 19.11.2015 Thank you! I´m reading a book on Lua right now, hopefully I´ll get to grips with this soon enough. I´ll play with your example and see how I do RE: Time dependent script - FatMax - 14.01.2016 I´m getting an error with this script: Code: -- Changes light depending on time of day The error reads: Attempt to index global ' grp'(a nil value) Shouldn't the system check the group database for correct datatype and act accordingly..? Or am I misinterpreting the error..? RE: Time dependent script - admin - 14.01.2016 Again, remove spaces before grp / else / if. Chrome copies non-breaking spaces which Lua inteprets as a valid variable characters, that's why you end up with " grp" instead of "grp". RE: Time dependent script - FatMax - 14.01.2016 Ah, ok, good to know I´m interpreting the code correctly so far Thank you! RE: Time dependent script - KoBra - 12.09.2023 tried to get the above script working but it keeps jumping around on value's Code: -- Changes light depending on time of day RE: Time dependent script - admin - 13.09.2023 This logic part is wrong: 19 <= hour and hour <= 7 Another issue with this script is that if the input object value is false it will first write 70 then 0 to the output. This can cause the light to flicker. Corrected version (event script, as it should be): Code: value = event.getvalue() RE: Time dependent script - KoBra - 13.09.2023 (13.09.2023, 07:44)admin Wrote: This logic part is wrong: 19 <= hour and hour <= 7 Tnx, is it also possible to add multiple time frames by just copying them and changing the timr? RE: Time dependent script - admin - 13.09.2023 You can add multiple elseif statements. Just make sure that hour checks are in an ascending order. Code: value = event.getvalue() RE: Time dependent script - KoBra - 14.09.2023 (13.09.2023, 14:16)admin Wrote: You can add multiple elseif statements. Just make sure that hour checks are in an ascending order. Thanks for the support! I only added a seperate telegram delay to it as the LED light has to start at 25% before able to dim back to 10% (KNX dimm actor was set to 25% starting value) |