Posts: 327
Threads: 126
Joined: May 2020
Reputation:
0
Hello
I should be able to change the weekly scheduling data from Visu to be able to pilot scenarios, is this possible? I found an example in the forum but it refers only to one day, I would need a weekly schedule, is there the possibility to do it in visu without having to modify the scripts?
BR
Posts: 4643
Threads: 24
Joined: Aug 2017
Reputation:
207
Why don't you create event script and use normal scheduler to trigger it? This way you will have the editing sorted.
------------------------------
Ctrl+F5
Posts: 327
Threads: 126
Joined: May 2020
Reputation:
0
(14.10.2020, 13:57)Daniel. Wrote: Why don't you create event script and use normal scheduler to trigger it? This way you will have the editing sorted.
Hi
I have to use scripted switching at 4 different times of the day, I would like to give the user the possibility to change the times from view, placing them on virtual date / time objects in order to then set the times in the scheduled scripts but I don't know if it is possible.
BR
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
You can change the running time for a scheduled script via db queries.
This event script is attached to the time/day object and you need to change 3 to your scheduled script id (see this: https://forum.logicmachine.net/showthrea...0#pid19070):
Code: id = 3 -- scheduled script id
value = event.getvalue()
params = string.format('%d %d * * *', value.minute, value.hour)
db:update('scripting', { params = params }, { id = id })
script.reloadsingle({ type = 'scheduled' })
Posts: 327
Threads: 126
Joined: May 2020
Reputation:
0
(26.11.2020, 07:35)admin Wrote: You can change the running time for a scheduled script via db queries.
This event script is attached to the time/day object and you need to change 3 to your scheduled script id (see this: https://forum.logicmachine.net/showthrea...0#pid19070):
Code: id = 3 -- scheduled script id
value = event.getvalue()
params = string.format('%d %d * * *', value.minute, value.hour)
db:update('scripting', { params = params }, { id = id })
script.reloadsingle({ type = 'scheduled' })
Perfect thank's
Posts: 167
Threads: 20
Joined: Apr 2017
Reputation:
2
04.01.2022, 16:00
(This post was last modified: 04.01.2022, 16:28 by Dré.)
(26.11.2020, 07:35)admin Wrote: You can change the running time for a scheduled script via db queries.
This event script is attached to the time/day object and you need to change 3 to your scheduled script id (see this: https://forum.logicmachine.net/showthrea...0#pid19070):
Code: id = 3 -- scheduled script id
value = event.getvalue()
params = string.format('%d %d * * *', value.minute, value.hour)
db:update('scripting', { params = params }, { id = id })
script.reloadsingle({ type = 'scheduled' })
Wow this looks very simple, is there a manual for things like this?
it is working for me, but im wondering how you know this.
i made next script with knowing how to use it.
Code: Airco_status = event.getvalue()
if Airco_status == true then
id = 110 -- scheduled script id
params = string.format('5 * * * *') --starts every 5 minutes
db:update('scripting', { params = params }, { id = id })
script.reloadsingle({ type = 'scheduled' })
else
id = 110 -- scheduled script id
params = string.format('* 1 * * *') --starts every hour
db:update('scripting', { params = params }, { id = id })
script.reloadsingle({ type = 'scheduled' })
end
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
Internal functions are not documented because it's easy to use them incorrectly leading to some system parts not working at all.
Posts: 167
Threads: 20
Joined: Apr 2017
Reputation:
2
oké i understand, thanks for the answer.
but it's communicate to some people, who have the knowledge how to work with a LM? or just to trail and error to find out?
just interesting how people know these things.
im just a beginner and curious
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
Well they are pretty much all available in the different forum threats..
So read and learn (:
Posts: 167
Threads: 20
Joined: Apr 2017
Reputation:
2
I'm looking for a script that turn on an off a schedule.
I know about the option with a groupadress to enable and disable it, but if it is possible i would do it with a script.
Posts: 4643
Threads: 24
Joined: Aug 2017
Reputation:
207
------------------------------
Ctrl+F5
Posts: 167
Threads: 20
Joined: Apr 2017
Reputation:
2
Thanks Daniel, but it looks like it don't work.
Why, i would directly control the scheduled with more scripts.
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
Map a virtual object to scheduler on/off an use grp.update. You can use object name like "Scheduler A on/off" instead of a group address to make the code more readable.
Posts: 167
Threads: 20
Joined: Apr 2017
Reputation:
2
16.09.2022, 15:39
(This post was last modified: 18.09.2022, 12:32 by Dré.)
I'm afraid i was wrong.
I meant to asking if there a script like
Code: id = 3 -- scheduled script id
value = event.getvalue()
params = string.format('%d %d * * *', value.minute, value.hour)
db:update('scripting', { params = params }, { id = id })
script.reloadsingle({ type = 'scheduled' })
But not changing the time, but just enable and disable it?
I think I have to change line 4, but don't know what to use.
------------------------------------------------------------------------------
I was still trying to solve my problem, but he always set the Scheduled script off, never on, also when the input value was true
Code: verl_aanrecht_TM = grp.getvalue('1/4/5') --'0 verl. aanrechtblad (tm)'
if verl_aanrecht_TM == true then
script.set('12.01 Check if Light can turn Off', enable)
elseif verl_aanrecht_TM == false then
script.set('12.01 Check if Light can turn Off', disable)
end
Someone who knows what i do wrong?
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
Use this:
Code: state = grp.getvalue('1/4/5')
script.set('12.01 Check if Light can turn Off', state)
In your case enable/disable variables are not defined (nil) so both script.set calls disable the script.
Posts: 167
Threads: 20
Joined: Apr 2017
Reputation:
2
Thank you, at my side it wasn't working, maybe because my object '1/4/5' was a switch 01.001 data type?
I changed it to
Code: if state == true
then script.set('12.01 Check if Light can turn Off', true)
else
then script.set('12.01 Check if Light can turn Off', false)
end
to get this working.
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
grp.getvalue returns true/false for all Boolean sub-datatypes so it does not matter.
Posts: 167
Threads: 20
Joined: Apr 2017
Reputation:
2
I had that idea too, but it looks like it didn't work.
Posts: 34
Threads: 10
Joined: Feb 2020
Reputation:
0
I have a scheduled script which changes the value of a group address to 0 and then I have a second scheduled script which puts the value back to 1. The first script has ID=112 and the second 113.
Now, I want to change the time that both scripts are performed, using a script. I want that the first script is performed at 23 o'clock and the second script at 24h. I changed the code to:
Code: id = 112 -- scheduled script id
value = event.getvalue()
params = string.format('00 23 * * *', value.minute, value.hour)
db:update('scripting', { params = params }, { id = id })
script.reloadsingle({ type = 'scheduled' })
--
id = 113 -- scheduled script id
value = event.getvalue()
params = string.format('00 24 * * *', value.minute, value.hour)
db:update('scripting', { params = params }, { id = id })
script.reloadsingle({ type = 'scheduled' })
But, nothing is changing. What am I doing wrong?
Posts: 167
Threads: 20
Joined: Apr 2017
Reputation:
2
29.02.2024, 20:13
(This post was last modified: 29.02.2024, 20:15 by Dré.)
(29.02.2024, 19:26)Amelie Wrote: I have a scheduled script which changes the value of a group address to 0 and then I have a second scheduled script which puts the value back to 1. The first script has ID=112 and the second 113.
Now, I want to change the time that both scripts are performed, using a script. I want that the first script is performed at 23 o'clock and the second script at 24h. I changed the code to:
Code: id = 112 -- scheduled script id
value = event.getvalue()
params = string.format('00 23 * * *', value.minute, value.hour)
db:update('scripting', { params = params }, { id = id })
script.reloadsingle({ type = 'scheduled' })
--
id = 113 -- scheduled script id
value = event.getvalue()
params = string.format('00 24 * * *', value.minute, value.hour)
db:update('scripting', { params = params }, { id = id })
script.reloadsingle({ type = 'scheduled' })
But, nothing is changing. What am I doing wrong?
I think you use it on a wrong way.
Go to scripting and then Scheduled, create a new script here, fill in when it has to run.
* = every minutes/hours
not forget to activate.
click on editor (green note on the right side) and put there the script you want to run, what you want to set to 0 and set to 1, not the script of above here.
not sure what you want but 0 and 1 are not allowed for a Boolean, so maybe you have to change it in true or false, but this you can try when you run the script manual.
the script in this topic is for changing a scheduled script, for when it has to run. (the time).
|