[ANSWERED]How to set a variable with the result of an operat

Posted on
Thu Mar 09, 2017 1:12 pm
Will offline
Posts: 5
Joined: Jul 19, 2015
Location: Madrid, Sapin

[ANSWERED]How to set a variable with the result of an operat

Hello,
I'm trying to create a variable that contains the difference between the outdoors temperature and the in house temperature in order to decide whether I switch on the heating system:

delta_temp = inhouse_temp - outdoors_temp

I will create this as a trigger when either the outdoors ot the indoors temperature changes and then I will execute an script in Python to set the delta_temp value.

The problem is that I know nothing about Python...... :-(

Could you help me with this simple question?

Many thanks.

Guillermo.

Posted on
Fri Mar 10, 2017 9:54 am
jay (support) offline
Site Admin
User avatar
Posts: 15270
Joined: Mar 19, 2008
Location: Austin, Texas

Re: How to set a variable with the result of an operation

There's not enough information to fully answer your question since we don't know where you're getting inhouse_temp and outdoors_temp. Are they device states? Variables?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Mar 10, 2017 12:42 pm
Will offline
Posts: 5
Joined: Jul 19, 2015
Location: Madrid, Sapin

Re: How to set a variable with the result of an operation

Hello Jay, thanks for your response.
"inhouse_temp" and "outdoors_temp" are both variables that store the value of temperature sensors placed inside and outside home respectively. This variables are updated via a "Trigger", as well as the difference between them (delta_temp) should be, each time either sensor value change. Then another trigger based on the change of this "delta_temp" will decide whether to switch on or off the heater depending on certain conditions.

Guillermo.

Posted on
Fri Mar 10, 2017 5:44 pm
jay (support) offline
Site Admin
User avatar
Posts: 15270
Joined: Mar 19, 2008
Location: Austin, Texas

Re: How to set a variable with the result of an operation

Ok, so something like this should work:

Code: Select all
inhouse_temp = float(indigo.variables[12345].value) # insert ID of inhouse_temp variable
outdoors_temp = float(indigo.variables[54321].value) # insert ID of outdoors_temp variable
temp_difference = inhouse_temp - outdoors_temp
indigo.variable.updateValue(98765, value=temp_difference)  #insert ID of your delta_temp variable


Right-click on the variable in the Variables Window to copy the ID of the variable.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Mar 12, 2017 2:17 am
Will offline
Posts: 5
Joined: Jul 19, 2015
Location: Madrid, Sapin

Re: How to set a variable with the result of an operation

Hello Jay,
many thanks for the response.
this code worked but I had to change it slightly in the fourth line due to an error received while trying to run it.

inhouse = float(indigo.variables[388313023].value) # insert ID of inhouse_temp variable
outdoor = float(indigo.variables[1288399788].value) # insert ID of outdoor_temp variable
delta = inhouse - outdoor
indigo.variable.updateValue(932135071, str(delta)) #insert ID of delta_temp variable

Thanks again.

Guillermo.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests