Use Variable as set point for temperature

Posted on
Mon Apr 18, 2016 4:37 am
mlew offline
Posts: 33
Joined: Jan 08, 2016
Location: Lincs UK

Use Variable as set point for temperature

Hi All hopefully quick easy questions!

I am looking to set trigger that turns my heating down if the outside doors (front or back) are left open for a certain amount of time. That part i have no issue with but what i want to do is return the heating to last know set point, so i can see how to move current Temp set point into a variable but cant see how i move it back after. Is there a simple way to transfer a variable to a heating set point?

thank you

Mark

Posted on
Mon Apr 18, 2016 11:06 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Use Variable as set point for temperature

You'll need a script for that. Something like this should work:

Code: Select all
try:
    previousSetpoint = int(indigo.variables[VARIDHERE].value)
    indigo.thermostat.setHeatSetpoint(THERMOSTATIDHERE, value=previousSetpoint)
except ValueError:
    indigo.server.log("Couldn't get a valid setpoint from the variable")
except:
    indigo.server.log("Error setting the setpoint to %s" % str(previousSetpoint))


Substitute the actual variable ID and the thermostat ID and that should be close.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Apr 18, 2016 12:03 pm
mlew offline
Posts: 33
Joined: Jan 08, 2016
Location: Lincs UK

Re: Use Variable as set point for temperature

Thanks Jay will give that a try

Posted on
Sun May 01, 2016 11:49 am
aderrington offline
Posts: 116
Joined: Feb 03, 2015

Re: Use Variable as set point for temperature

Just wanted to say Thanks Jay,

This works great for me.

Cheers!!
Andrew

Posted on
Sun Nov 01, 2020 2:39 pm
sfcreatus offline
Posts: 10
Joined: Oct 31, 2020

Re: Use Variable as set point for temperature

I would like to use a variable value to set the heat point of a thermostat. I'm totally new to scripts. I've tried using the script above (see post 4/18/16 from Jay) in an action (server action/script and file actions/execute script) pasting into the Embedded Python box. I've changed the varidhere to the variable name and the thermastatidhere to the device ID. On compiling I get an error: "embedded script:unexpected indent... around line 2 - "indigo.thermostat.setHeatSetpoint(128048856, value=Setpoint)". Any ideas? thanks.

Posted on
Sun Nov 01, 2020 2:56 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Use Variable as set point for temperature

Copy/paste into a forum reply the entire embedded script for us to see.

Image

Posted on
Sun Nov 01, 2020 3:21 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Use Variable as set point for temperature

And please use the CODE formatting tags when you do that.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Nov 01, 2020 3:42 pm
sfcreatus offline
Posts: 10
Joined: Oct 31, 2020

Re: Use Variable as set point for temperature

Thanks to you both for a quick reply. Cutting and pasting from the previous post using code selection style...

Code: Select all
previousSetpoint = int(indigo.variables[VARIDHERE].value)
    indigo.thermostat.setHeatSetpoint(THERMOSTATIDHERE, value=previousSetpoint)
except ValueError:
    indigo.server.log("Couldn't get a valid setpoint from the variable")
except:
    indigo.server.log("Error setting the setpoint to %s" % str(previousSetpoint))

Posted on
Sun Nov 01, 2020 3:48 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Use Variable as set point for temperature

Is that your actual code, or did you edit it to remove the IDs of the Variable and Thermostat?

Also, you're missing the "try" keyword, and missing indentation:

Code: Select all
try:
    previousSetpoint = int(indigo.variables[VARIDHERE].value)
    indigo.thermostat.setHeatSetpoint(THERMOSTATIDHERE, value=previousSetpoint)
except ValueError:
    indigo.server.log("Couldn't get a valid setpoint from the variable")
except:
    indigo.server.log("Error setting the setpoint to %s" % str(previousSetpoint))

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Nov 01, 2020 4:31 pm
sfcreatus offline
Posts: 10
Joined: Oct 31, 2020

Re: Use Variable as set point for temperature

Thanks FlyingDiver. I didn't realize "try" was a part of the code. I've corrected that. The following is the current script:
Code: Select all
try:
    previousSetpoint = int(indigo.variables[Therm].value)
    indigo.thermostat.setHeatSetpoint(128048856, value=previousSetpoint)
except ValueError:
    indigo.server.log("Couldn't get a valid setpoint from the variable")
except:
    indigo.server.log("Error setting the setpoint to %s" % str(previousSetpoint))


It compiles without error, however on running it, an error returns:
"Script Error Exception Traceback (most recent call shown last):

embedded script, line 7, at top level
UnboundLocalError: local variable 'previousSetpoint' referenced before assignment"

Thanks again.

Posted on
Sun Nov 01, 2020 4:42 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Use Variable as set point for temperature

That means the line:

Code: Select all
    previousSetpoint = int(indigo.variables[Therm].value)


Is failing. What is "Therm"? If that's the name of the variable, put it in quotes. But it's better to use the ID number of the variable, which is what the original code had.

This code is a little safer:

Code: Select all
try:
    previousSetpoint = int(indigo.variables[VARIABLEID].value)
except:
    indigo.server.log("Couldn't get a valid setpoint from the variable")
    return

try:
    indigo.thermostat.setHeatSetpoint(128048856, value=previousSetpoint)
except:
    indigo.server.log("Error setting the setpoint to %s" % str(previousSetpoint))
Last edited by FlyingDiver on Sun Nov 01, 2020 4:43 pm, edited 1 time in total.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Nov 01, 2020 4:42 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Use Variable as set point for temperature

Everywhere it says *IDHERE should be the ID (number) of the device. You can easily get that by right clicking on the the device or variable in the appropriate list and select the Copy ID menu item.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Nov 01, 2020 5:50 pm
sfcreatus offline
Posts: 10
Joined: Oct 31, 2020

Re: Use Variable as set point for temperature

Gentlemen, thank you. Very much appreciated.
Is there a URL in indigodomotics' library that would have basic instruction on scripting?
Neal

Posted on
Sun Nov 01, 2020 7:08 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Use Variable as set point for temperature


joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests