Jump to content

Variable based scheduling of programs


Goose66

Recommended Posts

Posted

I would like some way of scheduling program execution times without requiring the admin GUI. For example, if programs could be scheduled to run based on date and time in variables, then the REST interface could be used to set the variables for the scheduled run time, and 3rd party packages could use this interface to schedule execution of programs. Any other interface allowing third-party apps to schedule execution of programs would be acceptable.

 

I have two use cases (although I am sure there are plenty others):

 

1) I have a wakeup program that serves as my alarm clock. It slowly fades up the lights in my room (over 5 minutes) and then turns on my TV and tunes CNN. It would be nice to be able to pickup my phone and adjust my wakeup time before I go to bed.

 

2) When I leave on vacation, I set the house to vacation mode. This, among other things, sets the thermostats back to save energy. I always forget to take it out of vacation mode until I return, however, and then I suffer through several hours of a hot house until it can cool down. I would like to be able to put the house in vacation mode and then schedule a day and time for it to come out of vacation mode from my phone right then when I am thinking about it.

 

I am sure MobilLinc or other third party providers could add scheduling of program execution to their apps. But that would require 1) that the phone be in contact with the house when the program is scheduled to run and 2) that the MobiLinc program be running in the background. I would much prefer to have this schedule maintained in the ISY.

Posted

I wrote a set of programs in ISY that would adjust the time my AC changed the night time setpoints so that the house reached the right temperature at the same time every night. While this application is a bit more complex than your examples, I believe it does demonstrate how this can be accomplished right now.

 

As a note, variable based timers have already been mentioned for the 5.x branch.

 

The first part of the program was to measure how long it takes from the time the AC setpoints changed until the house reached the new setpoint.

 

This was accomplished with a simple disabled program being called when the setpoints were changed. This disabled program would call itself every minute and increment up a variable that represented run time in minutes.

 

Next, the framework established already in the background where I have variables with the Thermostats Heating, Cooling, Humidity and Status variables allows me to also know what the temperature was when this started.

 

Knowing the time it takes to cool, and dividing it by the difference in starting temperature and final setpoint gave me a variable with how long it takes to cool per degree.

 

Next, we take that variable and average it with the last weeks worth of variables. This gives a slow seasonal adjustment.

 

Finally, with the ISY's Web Logging I had a CSV file with outside temperatures and run times. This gave me an adjustment factor of 1-5 minutes per degree difference in current house temperature and outside temperature. I resolved this by a simple band (if outside is 1-5 degrees warmer then inside then add 2 minutes for every degree difference).

 

 

 

All of that gets us to your variable timer. Essentially, I now have a single variable that represents how long the AC should take to get the house to the night time setpoint.

 

Then what we do is set a program to run at the same time every day that will be well before any AC time. For me this was 6pm. My target time is 10pm to be at the cooling set point. This 6pm program would set the daily timer at 240 minutes and call itself every minute to reduce that timer.

 

Lets say the calculated cooling time is 60 minutes. We would then change the AC setpoint when the daily timer hit 180 minutes, or at 9pm.

 

 

 

 

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

 

Lets apply this to your daily wake up timer.

 

For ease of use we are going to start a program at midnight that runs every minute.

We are also going to set two variables one for hours and one for minutes. This is what the user will set. So in my program I set the Hours to 9 and the Minutes to 15. My alarm should trigger at 9:15.

 

First we have our Daily Timer:

If
       Time is 12:00:00AM

Then
       $State_Alarm.Clock_Current.Time  = 0
       $State_Alarm.Clock_Current.Time Init To $State_Alarm.Clock_Current.Time
       Run Program 'Current Time' (Then Path)
       $Int_Alarm.Clock_Alarm.Total.Minutes  = $Int_Alarm.Clock_Alarm.Hour
       $Int_Alarm.Clock_Alarm.Total.Minutes *= 60
       $Int_Alarm.Clock_Alarm.Total.Minutes += $Int_Alarm.Clock_Alarm.Minute
       $Int_Alarm.Clock_Alarm.Total.Minutes Init To $Int_Alarm.Clock_Alarm.Total.Minutes
       $Int_Alarm.Clock_Alarm.Hour Init To $Int_Alarm.Clock_Alarm.Hour
       $Int_Alarm.Clock_Alarm.Minute Init To $Int_Alarm.Clock_Alarm.Minute
       Enable Program 'Alarm Clock'

Else
  - No Actions - (To add one, press 'Action')

 

This gets us set for the day and starts up our Current Time Path.

 

Now our Current Time Path looks like this:

If
  - No Conditions - (To add one, press 'Schedule' or 'Condition')

Then
       Wait  1 minute 
       $State_Alarm.Clock_Current.Time += 1
       $State_Alarm.Clock_Current.Time Init To $State_Alarm.Clock_Current.Time
       Run Program 'Current Time' (Then Path)

Else
  - No Actions - (To add one, press 'Action')

 

Now we have a state variable updated with how many minutes from midnight we are currently at.

 

Finally we have our Alarm Clock Program:

If
       $State_Alarm.Clock_Current.Time >= $Int_Alarm.Clock_Alarm.Total.Minutes

Then
       Set 'Hall - Light' On
       Disable Program 'Alarm Clock'

Else
  - No Actions - (To add one, press 'Action')

 

 

 

Using the above, you now have a variable timer that you can set to whatever time you want from a REST Interface or the normal variable set points in the ISY apps/web page.

 

 

 

I won't write up the 2nd example program, but the thought process is the same.

Somewhere on the forums is a bunch of code that gives you variables for the current Month / Day.

The basics are to have 7 week day programs.

Each have the condition that it is Monday, or Tuesday and so on.

They set a variable for Day of Week 1-7.

 

Next you have a Day of Month variable that those 7 programs add +1 to. You now know what day it is in the month.

 

Last you have 3 programs that feed off that Day of Month State Variable. If the Day is 31 on a Month Variable that ends at 30, then set the Day to 1 and add +1 to the Month; as an example.

 

Now you have the following variables:

Day of Week, 1-7

Day of Month, 1-31

Current Month, 1-12

 

With this information, you can now add your two Vacation Home Variables, Day I'll Be Home and Month I'll Be Home.

You can also feed off the above code for the Current Time, as this runs every minute all day. So you can add Hour I'll Be Home and Minute I'll Be Home.

 

Now your Alarm Clock code from above just adds the IF conditions that they match your I'll Be Home Variables.

Posted

The things I would add to the above code for reliability:

 

Change the INT variables for Hour and Minutes to State Variables.

Add a program that if either of the State Hour and State Minute times are >=0 Then:

Update the Int Total.Minutes variable.

 

 

This essentially would allow you to change the alarm clock time in the wee hours of the morning without having to think about also updating the total.minutes bit as that is only set at midnight.

Posted

That's a nice solution using existing functionality. The problem is that no third-party app developer is going to implement scheduling of programs around such a convoluted hack (and I mean that with all due respect).

 

If we can get the ISY to implement a variable type of datetime, and allow programs to be setup to run based on datetime variables (e.g. "If Time Is $wakeup_time"), then we can then ask MobiLinc and other developers to create a nice interface for setting dates and times for variables, and place those variables in our favorites so that they are instantly available for adjustment.

Posted

Oh, I certainly agree on the getting native support for variable timers.

 

But... mobilinc currently does not let you even see your variables, which is a shame. If they did you could simply favorite your Hour and Minute variable. You could even combine the two into a single variable of 0915. You would just set a quick program to run on state change that subtracts 100 if >=100 and then adds the remaining minutes back in.

 

Another app called ISYController does let you set the variables and is rather quick to change the Hour and Minutes variables to your time.

 

Also, the default web interface for ISY lets you adjust variables directly. I use a custom built web page that we access to do our common tasks.

 

For the phone I actually use the Tasker where we have several icons that update on one of our home screens. We use the REST functionality of Tasker to directly interface with the ISY. Adding a tasker scene that pops up your two alarm variables would also be rather easy.

 

I'm really hoping that MobiLinc adds variable support with their rumored soon to be released Android Update.

Posted

More or less what you seem to be doing here is creating a variable clock. This is not at all unlike what I created using variables as a calendar.

 

I would do this with 2 variables. $clockminute and $clockhour. I would write 24 programs that set clock hour to the current hour and set clock minute to 0. Then I would add one more program that counts clock minute up by 1 each minute.

 

If

time is 12am

Then

set $clockhour = 0

set $clockminute = 0

run "minute count" then path

Else

- - -

 

etc for 1am, 2am, and so on.

 

"Minute Count"

If

- -

Then

wait 1 minute

repeat every 1 minute

set $clockminute += 1

Else

- -

 

This would give you a clock using variables for the hours and minutes to which other variables could be compared (ie your alarm clock set time). It would also recover from a power failure in no more than 1 hour.

 

And, as far as setting a future time using varialbes to reactivate your hvac.

 

1) install the programs I wrote using variables as a calendar

2) Put your hvac program into a folder and put in the conditions

if

$iDay.of.Month >= $some variable you use to designate day you want to start hvac program

and

$iMonth >= $some variable you use to designate month you want to start hvac program

and

$iYear >= $some variable you use to designate year you want to start hvac program

and

$clockminute >= $some variable you use for minute you want hvac program to start

and

$clockhour >= $some variable you use to set hour you want hvac program to start

 

Now, when you leave on vacation, set your reactivation variables to your date and time of return, thus making the hvac program located in the folder inactive. At this point you can change your thermostat to whatever you want, and it should hold there until the folder reactivates at said time and date. You might also need a "run if" somewhere to force the hvac program to execute at the moment the folder reactivates. I don't use my ISY to run my thermostats so I am a little vague on how they handle things.

Posted
But... mobilinc currently does not let you even see your variables, which is a shame. If they did you could simply favorite your Hour and Minute variable. You could even combine the two into a single variable of 0915. You would just set a quick program to run on state change that subtracts 100 if >=100 and then adds the remaining minutes back in.
Is that MobiLinc for Android? I have it for iOS, and you can see/edit variables, and if you have MobiLinc Connect, get push notifications.
Posted
But... mobilinc currently does not let you even see your variables, which is a shame. If they did you could simply favorite your Hour and Minute variable. You could even combine the two into a single variable of 0915. You would just set a quick program to run on state change that subtracts 100 if >=100 and then adds the remaining minutes back in.
Is that MobiLinc for Android? I have it for iOS, and you can see/edit variables, and if you have MobiLinc Connect, get push notifications.

 

Correct, Android. It is possible that I missed it, but I'm getting a bunch of forced closed issues with it right now too that I've not had time to troubleshoot.

 

apostolakisl; threw these up as a proof of concept, but I certainly like your approach better for the recovery time. Mine just has the init to flag set so that it doesn't start over after power is restored.

 

And you would be that somewhere on these forums is a full set of date programs I was referencing!

 

I think we are just pushing past the OPs point now. It will still be nice when timers get variables directly. Will make me a bit sad as a lot of creative programing goes into making the ISY do things it "can't" do. :twisted:

Posted

I got fed up waiting for features that have long been on MobiLinc IOS to come to Android, so I rolled my own. I use Tasker and ISYs REST api for variable setting (and program running). Coupled with AutoRemote (so ISY can send status to Tasker variables), with PowerToggles to put actions on the notification bar. Geolocation is provided by AutoLocation. I've built essentially a replacement for MobiLinc - one that does not need to poll for device status, uses cloud to device messaging. Needs lots of polish yet though - I'm hoping to write it up soon.

 

I'd just like the ability to adjust a program trigger via REST. Otherwise, I can simply trigger via REST from Tasker on Android based on all kinds of events and schedules.

Posted

I went ahead and wrote the programs and they seem to work.

 

I would add one thing, have the variables "init" themselves. That way if the power goes out, the variables will only fall behind by the number of minutes the power went out, then at the next top of the hour they will correct to the actual time. If there is a short power failure, it would better to be a few minutes behind then to have the clock completely wrong.

Posted
I got fed up waiting for features that have long been on MobiLinc IOS to come to Android, so I rolled my own. I use Tasker and ISYs REST api for variable setting (and program running). Coupled with AutoRemote (so ISY can send status to Tasker variables), with PowerToggles to put actions on the notification bar. Geolocation is provided by AutoLocation. I've built essentially a replacement for MobiLinc - one that does not need to poll for device status, uses cloud to device messaging. Needs lots of polish yet though - I'm hoping to write it up soon.

 

I'd just like the ability to adjust a program trigger via REST. Otherwise, I can simply trigger via REST from Tasker on Android based on all kinds of events and schedules.

 

I'm slowly working through this exact thing. Ish.

 

I've got my basic framework setup in tasker for updating Tasker Widgets on one of my home screens with the current status of lights and fans. Click on them toggles or cycles through.

 

I'm actually going to be using Push Bullet for the notifications though. They have a nice REST interface that the ISY can push messages to you and all your devices.

Push Bullet integrates into Tasker as well and can auto accept/delete notifications and do actions. So as an example ISY can send a notification for motion detection with attached picture along with the link to the web server where you can see the live feed and have your normal controls there / activate alarms / call authorities.

 

You should also consider using Taskers API for location based on Cell Phone Tower Strength. It can auto scan the towers and use no extra battery compared to your cell signal.

 

 

I would be interested in your progress on this. Tasker has the functionality for Apps that I'll be playing around with soon. Essentially you can convert everything in tasker to a stand alone app. This is likely the way I'll distribute the packages to my wife and other devices.

Posted

Oh, and by push bullet to all your devices, that includes your computer. We get all our pushes to the PCs along with notification mirroring.

Posted

My programs can be downloaded here if you want them.

 

EDIT: I moved the attached file to UD's server now that they have that feature.

It uses integer variables 58 (hours) and 59 (minutes) and state variables 21 (minutes) and 22 (hours)

I set the program that advances the minutes to run at start up, so after a power failure it will resume. The "if" clause there is deigned to always be false, force execution of "else" on boot which immediately advances 1 minute since I assume any reboot will take at least one minute. Once the next top of hour is hit, the clock will be accurate again.

There are 24 programs like this
 

If

Time is 12:00:00AM



Then

$iHour.of.Day = 0

$iMinute.of.Hour = 0

Run Program 'Minute of Hour' (Then Path)



Else

- No Actions - (To add one, press 'Action')





And one of these
 

If

$iMinute.of.Hour < 0



Then

$sMinute = $iMinute.of.Hour

$sHour = $iHour.of.Day

$iHour.of.Day Init To $iHour.of.Day

$iMinute.of.Hour Init To $iMinute.of.Hour

Wait 1 minute

Repeat Every 1 minute

$iMinute.of.Hour += 1

$sMinute = $iMinute.of.Hour

$iMinute.of.Hour Init To $iMinute.of.Hour



Else

$iMinute.of.Hour += 1

Run Program 'Minute of Hour' (Then Path)





Hour Minute.v4.2.8__Wed 2014.09.24 04.22.34 PM.isy

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...