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.
Posted: 2016-05-08 09:00 PM . Last Modified: 2024-07-14 11:55 PM
Link copied. Please paste this link to share this article on your social media post.
Hi Guys,
I'm trying to include below flow diagram to SpaceLynk , but i have limited knowledge in Lua.
The function will be like this
While sensor trigger light on ->After 300sec if no movement dim down to 50% ,If got movement restart timer ->After another 300Sec no movement turn off light, if there is movement the light back to 100%.
Appreciate someone coach me for this.
Attach will be the flow diagram and here is the code
Link copied. Please paste this link to share this article on your social media post.
Hi Lee,
by random I found a script on the HL of Erwin van der Zwaart. I guess it will meet your requirements.
-- ** Staircase logic with external time object and retriggering on input object Version 3.1 ** --
-- ****************************** Created by Erwin van der Zwart **************************** --
-- ************************************** SET PARAMETERS ************************************ --
-- Set input address
AddressInput = '6/0/0'
-- Set output address
AddressOutput = '6/0/1'
-- Set external time address (optional)
AddressExternalTime = '6/0/2'
-- Use time left indication
UseTimeLeft = true -- Set to false if no time left indication is used
-- Set feedback adress of time left indication (optional)
AddressTimeLeft = '6/0/3'
-- Set time delay (Used when external time is not available)
SetDelay = 10
-- Seconds or Minutes
SetSec = true -- Set to false for Minutes
-- Set factor delay (Multiplies Delay)
SetFac = 1
-- Set unique name for staircase timer (to avoid same storage name usage)
StaircaseName = 'Staircase_1'
-- Logic can be turned of by value 0
Off_by_Value_Zero = false
-- ************************************** END PARAMETERS ************************************ --
-- *************************** DON'T CHANGE ANYTHING UNDER THIS LINE ************************ --
inputvalue = event.getvalue
if Off_by_Value_Zero == false and (event.getvalue() == false or event.getvalue() == 0) then
-- Exit script
return
end
ValueInput = grp.getvalue(AddressInput)
ValueOutput = grp.getvalue(AddressOutput)
ValueExternalTime = grp.getvalue(AddressExternalTime)
if SetSec == true then
SetSeconds = 1
else
SetSeconds = 60
end
if ValueExternalTime == nil then
ValueExternalTime = 0
end
if ValueExternalTime > 0 then
StairCaseTime = ValueExternalTime * SetSeconds * SetFac
else
StairCaseTime = SetDelay * SetSeconds * SetFac
end
if ValueInput == true then
--check for earlier started scrips
--check storage for stpid value
stpid = storage.get(StaircaseName)
--check if stpid has a value
if stpid == nil then
pid = os.getpid()
storage.set(StaircaseName, pid)
else
-- kill earlier running script
os.kill(stpid, signal.SIGKILL)
-- create new pid for next time to kill
pid = os.getpid()
storage.set(StaircaseName, pid)
end
if ValueOutput == false then
grp.write(AddressOutput, true)
ValueOutput = true
end
-- Check time left indication is used
if UseTimeLeft == true then
if StairCaseTime > 0 then
grp.update(AddressTimeLeft, StairCaseTime)
repeat
StairCaseTime = StairCaseTime - 1
grp.update(AddressTimeLeft, StairCaseTime)
os.sleep(1)
until StairCaseTime == 0
end
else
os.sleep(StairCaseTime)
end
ValueOutput = grp.getvalue(AddressOutput)
if ValueOutput == true then
ValueInput = grp.getvalue(AddressInput)
if ValueInput == true then
grp.write(AddressInput, false)
ValueInput = false
end
if Off_by_Value_Zero == false then
if ValueOutput == true then
grp.write(AddressOutput, false)
ValueOutput = false
end
else
-- Do nothing, this will trigger else condition below on next run
end
end
else
--check for earlier started scrips
--check storage for stpid value
stpid = storage.get(StaircaseName)
--check if stpid has a value
if stpid == nil then
else
-- kill earlier running script
os.kill(stpid, signal.SIGKILL)
grp.update(AddressTimeLeft, 0)
pid = nil
storage.set(StaircaseName, pid)
end
if ValueOutput == true then
grp.write(AddressOutput, false)
end
end
Posted: 2016-05-11 11:05 PM
Link copied. Please paste this link to share this article on your social media post.
Hi Thomas,
Many thanks I will test it whole back to home . Now meeting with customer
Sent from my iPhone
Link copied. Please paste this link to share this article on your social media post.
Hello Lee,
in case this topic is answered please mark it accordingly so that we can get a better view on which kind of topics are really still open.
Thanks a lot for your understanding and support.
Kind regards
Thomas
Posted: 2016-08-11 12:32 AM
Link copied. Please paste this link to share this article on your social media post.
Hi Thomas,
I will update the latest one by tomorrow.
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.