Author Topic: Canceling Scene with Delays?  (Read 996 times)

Offline callen

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Canceling Scene with Delays?
« on: December 06, 2013, 02:53:55 pm »
I have a geothermal heat pump in a weekend house and created a scene with 10 delays which ramps up the heat 2 degrees every 1hr.  The goal is heat the house over 10 hrs with out having the electric heat come on (its set to 50 degrees in the winter).  I also have it on schedules as well. 

The issue i have is i decided not to go to the house for a weekend and don't know how to abort the scene.  Is there a simple way to do this?

I suppose I could write a scene that sets the temp back to 50 degrees every 1hr and 5 seconds however there must be an easier way.

If you have any advice please let me know.

Charlie

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9816
  • Karma: +742/-136
    • RTS Services Plugins
Re: Canceling Scene with Delays?
« Reply #1 on: December 06, 2013, 03:03:34 pm »
If you do a scene with delays there is no way to stop it after it starts.
Also if Vera restarts during the scene ... it will not continue.

For better control you might consider using PLEG.

Offline callen

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Canceling Scene with Delays?
« Reply #2 on: December 06, 2013, 03:20:12 pm »
Thanks I have PLEG installed but have not yet learned how to use it.  I'll experiment with it.


Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9816
  • Karma: +742/-136
    • RTS Services Plugins
Re: Canceling Scene with Delays?
« Reply #3 on: December 06, 2013, 03:45:59 pm »
Let me help you get started ...

Install a Virtual Switch to control the process.
Call the Virtual Switch something like Occupied.
Then from any 3rd Party app you can just turn on the Occupied switch.

Then in PLEG you will have a Trigger Input:
Occupied    When the Occupied Virtual Switch is On
Also you need a two hour timer.
Bump         Interval Timer for every 2:00:00

Conditions:
_SetPoint    Occupied ? (SetPoint < 60 ? (Bump ? _SetPoint + 2  : _SetPoint): _SetPoint) : 50

Then you need an Action on _SetPoint:
Use the devices tab to set the temperature to any setting.
Then go into the Advanced Tab for the Action and change the hard coded setting to {_SetPoint}

NOTE: The leading character in the name is an underscore ... and that is important!

How this works.
The _SetPoint  is 3 level of conditional Statements.
A condition statement is of the form:
    SomeExpression ?  TrueValue : FalseValue

So the above in pseudo code can be though of as follows:
      if (Occupied) then
         if (SetPoint < 60) then
            if (Timer) then
               SetPoint = Setpoint + 2
            else
               SetPoint = SetPoint
            end
         else
            SetPoint = SetPoint
         end
      else
          Setpoint = 50
      end




 




Offline callen

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Canceling Scene with Delays?
« Reply #4 on: December 07, 2013, 10:56:01 am »
Richard,
Thanks so much for your input, I really appreciate it.  I actually wrote the logic below this morning prior to seeing your post.  The main change is that instead of increasing the temp based on time intervals I would ramp as fast as possible so long as the difference between the setpoint and the current temperature never exceeds 1 degree which would keep the electric heat from coming on (a 2-3 degree step may work but i would need to check the breakpoints for my heating stages). 

I was also considering having a notification of how long it took to heat.  Once i know the approximate heat time i could just hard code the time.  Or in the future when i get a lot of free time and get the data logging app working I could do a regression on heat time versus temperature difference and outside temperature and use an equation to determine the heat start time based on the input of my arrival time at the house.

Anyway I'll try to tweak your process to work with the logic below.

Device Settings:
   CurrentTemp  ?Temperature of thermostat
   Setpoint         ? Thermostat setpoint

Variables:
StartTime

Logic:
?Goal:  Ramp house temp to the Setpoint in 1 degree increments so electric heat is never engaged.

StartTime = Now
If CurrentTemp < TargetTemp
   Setpoint  = CurrentTemp + 2
End If

Loop Code Below every Minute
If CurrentTemp= TargetTemp or TargetTemp < CurrentTemp then
Notify with Now ? StartTime  ?this is how long the ramp took, should add outside temp in future
Exit program
End if

If  Setpoint ? CurrentTemp = 1  then
   Setpoint=CurrentTemp + 2
End If

Loop

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9816
  • Karma: +742/-136
    • RTS Services Plugins
Re: Canceling Scene with Delays?
« Reply #5 on: December 07, 2013, 11:12:41 am »
If you use "CurrentTemp" as your thermostat temperature:
It Should be easy changes for using the Current Temp in the ramp.

I recommend you also have an Input of "CurrentSetpoint"
This will keep the logic from turning it down to 60 if you set the thermostat to 70 for part of the day while occupied.

There is no way to grab the delta time and put it in a message. You can send a message
when you turn the Occupied Switch on and another when it reaches temp. You will have
to do the difference in your head :(

To get a Notification you might do the following:

StartTemp         (CurrentTemp; Occupied) ? CurrentTemp : Occupied
Notify               Occupied and (StartTemp < 60) and (CurrentTemp > 59)

And to do a continuous ramp instead of a time based ramp:
_SetPoint           Occupied ? (CurrentTemp < 60 ? CurrentTemp+2: CurrentSetPoint) : 50
« Last Edit: December 07, 2013, 11:29:17 am by RichardTSchaefer »

Offline callen

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Canceling Scene with Delays?
« Reply #6 on: December 08, 2013, 08:40:55 pm »
Thanks for the advice.  However if your willing I could really use some more help.  I've spend hours working on this and can't seem to get the syntax and setup right.  Below are the main steps and what I've accomplished:

- Created virtual switch called "Heat House"
- Created "Heat Ramp Logic" PLEG
-  When I switch Heat House -->  Heat Ramp turns on
- I hard coded a temperature for the setpoint and the notifications worked and temperature worked.

I've tried all sorts of combinations of syntax and options and can't seem to get the code to work.  I've attached a report as a PDF from the PLEG instance.

Are there some code coding examples that could help?

Would appreciate any help.