This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Changing Schedule time via script for visulation page
#1
Hello ,

We have a thermostat page in our project . This thermostat page is communication with a modbus thermostat. 
We created a time scheduler which turn on and off the thermostat and it's working.
But my customer asked that I don't want to go another page for changing scheduler.
Because of that I created a turn on time knx object, turn off knx object and a time scheduler active decative object in my page.
I want that, when i push the time scheduler active object, a script will enable that scheduler and same script will change event times of scheduler with value of  turn on time knx object, turn off knx object in the screen

Regards,
Reply
#2
First, you need to get ID of each event you want to change:
Code:
log(db:getall('SELECT * FROM scheduler_events'))

Then you can use this function to change event time:
Code:
hour = 12 -- event time / start hour
min = 30 -- event time / minute
id = 42 -- event DB id

db:update('scheduler_events', {
  start_hour = hour,
  start_min = min
}, { id = id })

You can change active state of schedulers by name:
Code:
name = 'My scheduler'
active = 1 -- 1 = active, 0 = inactive
db:update('schedulers', { active = active }, { name = name })

After each change you need to clear schedulers cache:
http://forum.logicmachine.net/showthread...04#pid2804
Reply


Forum Jump: