Schedule in LUA (or shell/python)?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
JustME125
Posts: 31
Joined: Monday 27 April 2015 16:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.4547
Location: The Netherlands
Contact:

Schedule in LUA (or shell/python)?

Post by JustME125 »

I have been playing around with domoticz for a while now and have a lot of lights, switches, heating and ventilation running through domoticz (my girlfriend actually likes it ) but I am wondering how it is possible to create schedule functionality that is available in lua (for example). I know I can make a dummy switch and attach a schedule to it through the timer functionality but I am looking for a more elegant solution.

I could off course hardcode the scheduling in lua but that prevents me from easily editing the schedule by phone for example and drastically reduces the WAF.

I am looking for a way to create more elaborate scheduling which allows for a broader use instead of only being able to schedule 1 device through 1 timer.

Anyone any idea how to create such schedule that is not linked to 1 particular device and is easily editable (WAF), available in lua and elegant in use (not additional dummy switches)?

Verstuurd vanaf mijn HTC One_M8 met Tapatalk
User avatar
gizmocuz
Posts: 2481
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Schedule in LUA (or shell/python)?

Post by gizmocuz »

If you want to control multiple lights at once, place them in a 'group' and add a timer on this group.
it is probably the same you do with lua/blockly/python right ?
And besides the 'dummy switch and elegant stuff', how often are you going to create new timers ?
Quality outlives Quantity!
annieoroberts00
Posts: 5
Joined: Tuesday 05 July 2016 8:36
Target OS: Windows
Domoticz version:
Contact:

Re: Schedule in LUA (or shell/python)?

Post by annieoroberts00 »

very useful thread.
JustME125
Posts: 31
Joined: Monday 27 April 2015 16:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.4547
Location: The Netherlands
Contact:

Re: Schedule in LUA (or shell/python)?

Post by JustME125 »

Unfortunately no replies so for.
jannl
Posts: 666
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: Schedule in LUA (or shell/python)?

Post by jannl »

I think the reply of gizmocuz is not bad. Besides, I basically never change my schedules. Running mostly for 2 years almost. Only added hardware needs updates to a schedule.
paulD
Posts: 16
Joined: Wednesday 20 January 2016 14:46
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Schedule in LUA (or shell/python)?

Post by paulD »

Hi,

You may define your schedule in googlecalendar. Search the forum and wiki to interact with google calendar in your lua script.
JustME125
Posts: 31
Joined: Monday 27 April 2015 16:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.4547
Location: The Netherlands
Contact:

Re: Schedule in LUA (or shell/python)?

Post by JustME125 »

Thanks for that angle Paul, never thought of that. One example of what I would like to accomplish is heating. Normally you tend to time the moment that your heating has to switch on or off, but I have pretty much defined how fast I can heat the house based on environment temperature etc so I don't need to know when I need to switch on (which can be achieved perfectly with the build in timers) but when a temperature should be reached. So instead of reacting on a schedule I want to anticipate when to switch on to achieve the desired state described in the schedule, the moment to switch depends on variables.

I hope this kind of clarifies why I asked my question.

Verstuurd vanaf mijn HTC One_M8 met Tapatalk
georgesattali
Posts: 84
Joined: Saturday 05 March 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: Schedule in LUA (or shell/python)?

Post by georgesattali »

Hello,
Your question is quite straightforward and easy to understand, but a bit difficult to implement, as it's a prediction in the future.

it seems that curl 'http://127.0.0.1:8080/json.htm?type=sch ... ter=device' returns the list of timers planned for the next 24 hours ("ScheduleDate"). You may decode this result using JSON.lua (google).

So, you could create a Schedule for the moment you aim being warm plus a "time" script (called every minutes), that computes the time needed to heat and starts heating if

Code: Select all

now < ScheduleDate <= now+"time needed"
and "not already started".

if you know that time needed is less than 2 hours, then you dont need to compute if now+"2 hours" < ScheduleDate.

Hope this helps, see you,
GD
JustME125
Posts: 31
Joined: Monday 27 April 2015 16:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.4547
Location: The Netherlands
Contact:

Re: Schedule in LUA (or shell/python)?

Post by JustME125 »

Hi GD,

That sounds damn good and pretty easy. I am absolutely no coder but I think I can figure out how to do it. My main concerns is getting the timer stuff in lua, not find some time to start working on this solution.

Thanks so far!

Verstuurd vanaf mijn HTC One_M8 met Tapatalk
JustME125
Posts: 31
Joined: Monday 27 April 2015 16:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.4547
Location: The Netherlands
Contact:

Re: Schedule in LUA (or shell/python)?

Post by JustME125 »

georgesattali wrote:Hello,
it seems that curl 'http://127.0.0.1:8080/json.htm?type=sch ... ter=device' returns the list of timers planned for the next 24 hours ("ScheduleDate"). You may decode this result using JSON.lua (google).

Code: Select all

now < ScheduleDate <= now+"time needed"
and "not already started".
Hope this helps, see you,
GD
I found out that:
curl 'http://127.0.0.1:8080/json.htm?type=sch ... thermostat' returns only thermostat type schedules. One step further, I have my holidays in a few weeks so I hope to finish this by the end of my holidays.

BR
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 1 guest