Posts: 53
Threads: 17
Joined: Nov 2016
Reputation:
0
I have a event based script, that turns off the toilet light after ten minutes. This is working very well, but I want to control the script so that if we have guests we can turn it on while the guests are here. The Gira tastsensor with three rows are somewhat difficult for everyone to read.
I have created a virtual object thet I can control with a mosaic widget. If I set it to off the script turns off the light after ten minutes. If I set it to on the lights stays on.
Problem is it is not working. Here is the script
value = event.getvalue(0/2/10)
keep_on = grp.getvalue(32/1/4)
if keep_on == false then
if value == true then
os.sleep(600)
grp.write('0/2/10', false)
end
end
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
22.09.2018, 21:20
(This post was last modified: 22.09.2018, 21:26 by Erwin van der Zwart.)
Hi,
Have not checked your script fully, but in the first lines i already see mistakes..
1) event.getvalue(0/2/10) needs to be event.getvalue() without any value passing to the function.
2) grp.getvalue(32/1/4) is missing the quotes and needs to be grp.getvalue(‘32/1/4’)
Your script will probably start to work better if you change these mistakes, but i expect you notice more problems as you use a os.sleep() in a event based script without script to avoid paralell execution.
This will probably not going to work as you expect..
BR,
Erwin
Posts: 53
Threads: 17
Joined: Nov 2016
Reputation:
0
I did what you told me and now the script works. Thank you very much. The new code look like this:
value = event.getvalue('0/2/10')
keep_on = grp.getvalue('32/1/4')
if keep_on == false then
if value == true then
os.sleep(600)
grp.write('0/2/10', false)
end
end
I didnt fully understand what you meant by number 1. Should you not insert which object you want to check in event.getvalue like I have done now?
Do you also have another and better method for waiting in the script?
Posts: 53
Threads: 17
Joined: Nov 2016
Reputation:
0
Thank you Erwin, I will try that new script. Much better to not have several parallell threads running, and I will use these lines in scripts in the future.
Yeah, I eventually understood that of course the entire script is mapped to an object so that is why you dont need this.
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
04.10.2018, 18:49
(This post was last modified: 04.10.2018, 18:49 by Erwin van der Zwart.)
Hi,
The sample above includes the logic and the parallel script kill, so yes only 1 script is needed.
BR,
Erwin