Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

We Value Your Feedback!
Could you please spare a few minutes to share your thoughts on Cloud Connected vs On-Premise Services. Your feedback can help us shape the future of services.
Learn more about the survey or Click here to Launch the survey
Schneider Electric Services Innovation Team!

scripts keep running although adjusted

SpaceLogic KNX Forum

Schneider Electric SpaceLogic KNX forum to get support and share knowledge including selection, installation and troubleshooting for spaceLYnk, Wiser for KNX, eConfigure KNX, SpaceLogic KNX Hybrid module and other topics.

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • EcoStruxure Building
  • Light and Room Control
  • SpaceLogic KNX Forum
  • scripts keep running although adjusted
Options
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
Thomas_Rohde
Sisko Thomas_Rohde Sisko
123
Erwin-vd-Zwart
Sisko Erwin-vd-Zwart Sisko
54
Heribert_Dölger
Lt. Commander Heribert_Dölger Lt. Commander
30
FZetina
Lt. Commander FZetina Lt. Commander
27
View All

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to SpaceLogic KNX Forum
Solved
DannyV
DannyV
Cadet

Posted: ‎2024-07-26 04:09 AM . Last Modified: ‎2024-07-26 04:13 AM

0 Likes
4
749
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2024-07-26 04:09 AM

scripts keep running although adjusted

Hi experts,

 

I am using a Wiser for KNX and am activating some scripts.

I have the issue that when I activate a script and it works, after modification of the script the original script keeps being active. I tried already to deactivate the script, I even deleted the script but in the logs of scripts and more general logs in Wiser (since I use the log() function in the script) I can see the script remains active. I need to reboot the Wiser in order to stop the scripts (some sort of 'reset'). What might be the issue?
I have added an example script in attachment. It is when I f.e. delete a log() function, that the scripts keeps it logging. as example I added a logMessage function in the 30 seconds time check - this log keeps a log every 30 seconds. I removed it in the code, saved, deactivated, activated the script but it keeps logging although not any more present in the script.


This makes it hard to debug scripts since I don't know which modification is used.

Thank you,
Regards,
Danny


Script:

-- Lua Script for Wiser KNX Logic Controller
-- Turn on light randomly between 9:00 PM and 9:30 PM and off between 11:00 PM and 1:00 AM

-- Light group address
local lightGroupAddress = "0/0/18" -- ceno

-- Push button group address
local pushButtonGroupAddress = "0/0/45"

-- Function to switch a light on or off
function switchLight(lightGroupAddress, state)
grp.write(lightGroupAddress, state)
end

-- Function to log messages
function logMessage(message)
log(message)
end

-- Function to get the current time in hours and minutes
function getCurrentTime()
local now = os.date("*t")
return now.hour, now.min
end

-- Function to calculate a random time offset within a range (in seconds)
function getRandomOffset(minMinutes, maxMinutes)
local minSeconds = minMinutes * 60
local maxSeconds = maxMinutes * 60
return math.random(minSeconds, maxSeconds)
end

-- Function to wait until a specific time
function waitUntil(hour, minute)
while true do
local currentHour, currentMinute = getCurrentTime()
if currentHour == hour and currentMinute == minute then
break
end
os.sleep(30) -- Check every 30 seconds
end
end

-- Main function to control the light based on time
function controlLightBasedOnTime()
while true do
-- Wait until 9:00 PM
logMessage("waiting until 9:00 PM")
waitUntil(21, 0)

-- Get a random offset between 0 and 30 minutes
local onOffset = getRandomOffset(0, 30)
logMessage("Waiting " .. onOffset .. " seconds to turn on the light")
os.sleep(onOffset)

-- Turn on the light
switchLight(lightGroupAddress, 1)
logMessage("Light turned on at " .. os.date())

-- Get a random offset between 2 and 4 hours for turning off
local offOffset = getRandomOffset(120, 240)
logMessage("Waiting " .. offOffset .. " seconds to turn off the light")
os.sleep(offOffset)

-- Turn off the light
switchLight(lightGroupAddress, 0)
logMessage("Light turned off at " .. os.date())

-- Wait until the next day
os.sleep(86400 - (os.time() % 86400)) -- Sleep until midnight
end
end

-- Start the function
controlLightBasedOnTime()

Labels
  • Labels:
  • Scripts
  • Wiser for KNX
Tags (1)
  • Tags:
  • english
Reply
  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
Erwin-vd-Zwart
Sisko Erwin-vd-Zwart Sisko
Sisko

Posted: ‎2024-07-29 10:40 PM

2 Likes
1
689
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2024-07-29 10:40 PM

Its caused by your functions that contains while loops, and os.sleeps, you probably use them as event based script as a new instance is started at each event. In the latest FW you can set what event needs to be kept active (first or last instance) to avoid this behavior when using delays in parallel 

See Answer In Context

Reply
Replies 4
Thomas_Rohde
Sisko Thomas_Rohde Sisko
Sisko

Posted: ‎2024-07-29 05:29 AM . Last Modified: ‎2024-07-29 05:29 AM

0 Likes
0
710
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2024-07-29 05:29 AM

Hi DannyV.

this sounds interesting!
Would you mind to share a project-backup?
Of course some general informations like HW, FW-Version are always good to know 😉

 

Kind regards
Thomas

Application Design Engineer
Reply
Erwin-vd-Zwart
Sisko Erwin-vd-Zwart Sisko
Sisko

Posted: ‎2024-07-29 10:40 PM

2 Likes
1
690
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2024-07-29 10:40 PM

Its caused by your functions that contains while loops, and os.sleeps, you probably use them as event based script as a new instance is started at each event. In the latest FW you can set what event needs to be kept active (first or last instance) to avoid this behavior when using delays in parallel 

Reply
DannyV
DannyV
Cadet

Posted: ‎2024-07-31 10:20 PM

0 Likes
0
658
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2024-07-31 10:20 PM

Hi Erwin and Thomas,

Thank you for your answers. Is there a better way than using the os.sleep delays for switching on a light for a certain (fixed) time or for an 'away-system' (where lights during evenings switch on and off at certain times)?

Reply
Erwin-vd-Zwart
Sisko Erwin-vd-Zwart Sisko
Sisko

Posted: ‎2024-08-01 10:20 PM

0 Likes
0
637
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

‎2024-08-01 10:20 PM

Using the delay in the ETS application (if any available) is always the preferred method, otherwise os.sleep(x) is your only option, keep in mind that event based scripts can run in parallel so you must use the first/last instance setting or os.kill script we used in the past (not needed anymore with the new instance setting option)

Reply
Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of