[SOLVED]Access Variable for Thermostat Setpoint?

Posted on
Wed Dec 25, 2013 2:17 pm
markf424 offline
Posts: 58
Joined: Dec 25, 2013

[SOLVED]Access Variable for Thermostat Setpoint?

Currently, Indigo handles my heat and cool setbacks for my Z-Wave thermostat. I have a combination of Schedule and Trigger items that adjust the thermostat based on time of day and occupancy. One thing that would be really useful is for me to insert a variable into the action for "Set Heat Setpoint" or "Set Cool Setpoint", instead of entering the value. This way I can manipulate the variables instead of the action.

I am about to embark on solving my particular case with Python, but before doing so, figured I'd ask if I can somehow reference those variables in the "Set [Heat/Cool] Setpoint" action field. If so, I can avoid an external script altogether.. for now.

Thanks.

Posted on
Thu Dec 26, 2013 11:25 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Access Variable for Thermostat Setpoint?

You'll need to use a tiny python script (which can be an embedded action; just copy/paste into the action panel) to do this. Something like:

Code: Select all
coolSetpoint = indigo.variables[1234].value
heatSetpoint = indigo.variables[5678].value
indigo.thermostat.setCoolSetpoint(7777, coolSetpoint)
indigo.thermostat.setHeatSetpoint(8888, heatSetpoint)

Image

Posted on
Thu Dec 26, 2013 11:37 am
markf424 offline
Posts: 58
Joined: Dec 25, 2013

Re: Access Variable for Thermostat Setpoint?

Aha. Makes total sense, and keeps me from having to maintain an external script. That should work perfectly. Thanks.

Posted on
Wed Jan 01, 2014 4:54 pm
mike_c offline
Posts: 37
Joined: Oct 03, 2013

Re: Access Variable for Thermostat Setpoint?

my python is rusty beyond belief ... Is there a similar mechanism for appleScript?

I want to store 'daytemp', 'nighttemp' etc... into variables and be able to set the heatpoint of the thermostat (at certain times of the day / night) to those variable values?

thanks,

Posted on
Wed Jan 01, 2014 4:57 pm
markf424 offline
Posts: 58
Joined: Dec 25, 2013

Re: Access Variable for Thermostat Setpoint?

What matt posted works with a slight change for me. I just used the embedded python and mine looks like this (for instance, for my wakeHeat variable):

Code: Select all
heatSetpoint = int(indigo.variables["wakeHeat"].value)
indigo.thermostat.setHeatSetpoint(623632202, heatSetpoint)


I just had to cast it to an integer to get it to work.

Posted on
Thu Jan 02, 2014 3:23 am
mike_c offline
Posts: 37
Joined: Oct 03, 2013

Re: Access Variable for Thermostat Setpoint?

Thanks ... (need to improve python knowledge).

For those interested in the applescript route, I found this thread worked:
viewtopic.php?f=4&t=7934

Posted on
Thu Jul 02, 2015 1:50 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: [SOLVED]Access Variable for Thermostat Setpoint?

I am trying to implement this my self.
But I get the following error when I try to run the script. Any ideas?

Håvard

coolSetpoint = indigo.variables[95531057] .value
indigo.thermostat.setCoolSetpoint(899700318, value=coolSetpoint)


Code: Select all
Script Error                    embedded script: Python argument types in
    ThermostatDeviceCmds.setCoolSetpoint(ThermostatDeviceCmds, int)
did not match C++ signature:
    setCoolSetpoint(CDeviceThermostat::_ThermostatDeviceCmds {lvalue}, boost::python::api::object device, double value, bool suppressLogging=False, bool updateStatesOnly=False)
  Script Error                    Exception Traceback (most recent call shown last):

     embedded script, line 2, at top level
ArgumentError: Python argument types in
    ThermostatDeviceCmds.setCoolSetpoint(ThermostatDeviceCmds, int)
did not match C++ signature:
    setCoolSetpoint(CDeviceThermostat::_ThermostatDeviceCmds {lvalue}, boost::python::api::object device, double value, bool suppressLogging=False, bool updateStatesOnly=False)


Håvard

Posted on
Thu Jul 02, 2015 2:56 am
Chameleon offline
Posts: 611
Joined: Oct 04, 2014

Re: [SOLVED]Access Variable for Thermostat Setpoint?

haavarda wrote:
I am trying to implement this my self.
But I get the following error when I try to run the script. Any ideas?

Håvard

coolSetpoint = indigo.variables[95531057].value
indigo.thermostat.setCoolSetpoint(899700318, value=coolSetpoint)


Code: Select all
Script Error                    embedded script: Python argument types in
    ThermostatDeviceCmds.setCoolSetpoint(ThermostatDeviceCmds, int)
did not match C++ signature:
    setCoolSetpoint(CDeviceThermostat::_ThermostatDeviceCmds {lvalue}, boost::python::api::object device, double value, bool suppressLogging=False, bool updateStatesOnly=False)
  Script Error                    Exception Traceback (most recent call shown last):

     embedded script, line 2, at top level
ArgumentError: Python argument types in
    ThermostatDeviceCmds.setCoolSetpoint(ThermostatDeviceCmds, int)
did not match C++ signature:
    setCoolSetpoint(CDeviceThermostat::_ThermostatDeviceCmds {lvalue}, boost::python::api::object device, double value, bool suppressLogging=False, bool updateStatesOnly=False)



Haarvard

Took me a little while to spot the problem :D

Variables in indigo are stored as strings not numbers (regardless of what they look like)

so your code will have to look like this:

Code: Select all
coolSetpoint = int(indigo.variables[95531057] .value)
indigo.thermostat.setCoolSetpoint(899700318, value=coolSetpoint)


Notice the int() function around the indigo.variables part. The error is telling you that one of the two parameters for the indigo.thermostat is the wrong type. I've fallen for this little issue many times.

BTW - when you put a variable back into indigo it's important to convert it back to a string using str()

Hope that helps

Mike

Posted on
Thu Jul 02, 2015 6:05 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: [SOLVED]Access Variable for Thermostat Setpoint?

Works perfect!
Thank you for your help.

Håvard

Håvard

Posted on
Sat Jul 04, 2015 10:19 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: [SOLVED]Access Variable for Thermostat Setpoint?

I am trying to take this a bit further, but I am stuck in another error message.

Trying to run the following script:

Code: Select all
coolSetpoint = int(indigo.variables[95531057] .value)
indigo.thermostat.setCoolSetpoint(899700318, value=coolSetpoint)


But Indigo gives me the following erro:
Script Error embedded script: invalid literal for int() with base 10: '17.0'
Script Error Exception Traceback (most recent call shown last):

embedded script, line 1, at top level
ValueError: invalid literal for int() with base 10: '17.0'

I think the reason is that when I insert device state as variable it is stored as 17.0. This does not work when I try to set this vale back to the device. Then it should be just 17.
Any suggestions?

Håvard

Håvard

Posted on
Sat Jul 04, 2015 12:26 pm
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: [SOLVED]Access Variable for Thermostat Setpoint?

If the variable value contains a decimal place, then it's not an int (integer) but rather a float. So first convert the string to a float, then the float to an int:

Code: Select all
coolSetpoint = int(float(indigo.variables[95531057].value))
indigo.thermostat.setCoolSetpoint(899700318, value=coolSetpoint)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Jul 04, 2015 1:52 pm
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: [SOLVED]Access Variable for Thermostat Setpoint?

Thank you Jay.
That solved it. Actually the variable was a float, so I could skip the init part.

My AC boost function works perfectly now.

1 Set a desired boost temp by setting a variable.
2 Select how long time boost temp should last by setting a variable.
3 Start a timer. Current AC temp is stored, and the temp is changed to boost temp.
4 Timer expires. Temperature is changed back to the stored temperature.

So in short. When I start my timer my boost program starts.

Håvard

Håvard

Posted on
Sun Jul 05, 2015 8:47 am
markf424 offline
Posts: 58
Joined: Dec 25, 2013

Re: [SOLVED]Access Variable for Thermostat Setpoint?

Great. Glad you got it worked out. I think you could also achieve what you are doing without using a timer. You could use a trigger with a delayed action as well. Triggered by whatever you want to make it boost (control page, double tap of light, your presence but not your wife's - which would be my case!, etc). The actions would be the same but the return setpoint would be the delayed action after your desired timeframe.

Posted on
Sun Jul 05, 2015 10:29 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: [SOLVED]Access Variable for Thermostat Setpoint?

Good point.
But I use the timer so I can vary the duration by just changing the variable on a control page.
I have a trigger that change the duration of the timer based on the value of the variable.

Håvard

Håvard

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 13 guests