Logic Machine Forum
Dynamically change the Scheduled program time parameters from visualization - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: Dynamically change the Scheduled program time parameters from visualization (/showthread.php?tid=2899)

Pages: 1 2


Dynamically change the Scheduled program time parameters from visualization - Frank68 - 14.10.2020

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


RE: Dynamically change the Scheduled program time parameters from visualization - Daniel - 14.10.2020

Why don't you create event script and use normal scheduler to trigger it? This way you will have the editing sorted.


RE: Dynamically change the Scheduled program time parameters from visualization - Frank68 - 25.11.2020

(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


RE: Dynamically change the Scheduled program time parameters from visualization - admin - 26.11.2020

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/showthread.php?tid=2955&pid=19070#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' })



RE: Dynamically change the Scheduled program time parameters from visualization - Frank68 - 26.11.2020

(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/showthread.php?tid=2955&pid=19070#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


RE: Dynamically change the Scheduled program time parameters from visualization - Dré - 04.01.2022

(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/showthread.php?tid=2955&pid=19070#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



RE: Dynamically change the Scheduled program time parameters from visualization - admin - 04.01.2022

Internal functions are not documented because it's easy to use them incorrectly leading to some system parts not working at all.


RE: Dynamically change the Scheduled program time parameters from visualization - Dré - 04.01.2022

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


RE: Dynamically change the Scheduled program time parameters from visualization - Erwin van der Zwart - 04.01.2022

Well they are pretty much all available in the different forum threats..

So read and learn (:


RE: Dynamically change the Scheduled program time parameters from visualization - Dré - 14.09.2022

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.


RE: Dynamically change the Scheduled program time parameters from visualization - Daniel - 14.09.2022

What for?
https://forum.logicmachine.net/showthread.php?tid=265&pid=1917#pid1917


RE: Dynamically change the Scheduled program time parameters from visualization - Dré - 14.09.2022

Thanks Daniel, but it looks like it don't work.

Why, i would directly control the scheduled with more scripts.


RE: Dynamically change the Scheduled program time parameters from visualization - admin - 14.09.2022

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.


RE: Dynamically change the Scheduled program time parameters from visualization - Dré - 16.09.2022

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?


RE: Dynamically change the Scheduled program time parameters from visualization - admin - 19.09.2022

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.


RE: Dynamically change the Scheduled program time parameters from visualization - Dré - 19.09.2022

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.


RE: Dynamically change the Scheduled program time parameters from visualization - admin - 19.09.2022

grp.getvalue returns true/false for all Boolean sub-datatypes so it does not matter.


RE: Dynamically change the Scheduled program time parameters from visualization - Dré - 19.09.2022

I had that idea too, but it looks like it didn't work.


RE: Dynamically change the Scheduled program time parameters from visualization - Amelie - 29.02.2024

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?


RE: Dynamically change the Scheduled program time parameters from visualization - Dré - 29.02.2024

(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).