View unanswered posts | View active topics It is currently Tue May 21, 2013 12:24 am



Reply to topic  [ 6 posts ] 
 Need help to convert Celsius to Fahrenheit 
Author Message

Joined: Dec 26, 2007
Posts: 486
Location: British Columbia
Post Need help to convert Celsius to Fahrenheit
I thought I saw a sampling some time ago, but am not having any luck to find it now that I need it :)

I want to convert an Indigo_var_celsius to Indigo_var_fahrenheit

I used to convert in my App but since I moved away from that I want to do it in an action using applescript or python.

A pointer to where I can find a sampling or a sampling is very much appreciated.

Heinz


Mon Jul 02, 2012 1:07 am
Profile WWW
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6651
Location: Austin, Texas
Post Re: Need help to convert Celsius to Fahrenheit
I found this python code with a quick search:

Code: Select all
fah = (cel * (9.0/5.0)) + 32

_________________
Jay (Indigo Support)
Image


Mon Jul 02, 2012 9:01 am
Profile WWW

Joined: Dec 26, 2007
Posts: 486
Location: British Columbia
Post Re: Need help to convert Celsius to Fahrenheit
Thanks Jay,

Time to jump into the Python pond :)


Mon Jul 02, 2012 9:37 am
Profile WWW
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6651
Location: Austin, Texas
Post Re: Need help to convert Celsius to Fahrenheit
C'mon in - the water's fine.

_________________
Jay (Indigo Support)
Image


Mon Jul 02, 2012 10:19 am
Profile WWW

Joined: Aug 05, 2011
Posts: 230
Post Re: Need help to convert Celsius to Fahrenheit
Actually, that line of code would work in either Python or Applescript; the differences are all in getting "cel" out of a variable string or device state and then trimming/rounding "fah" and getting it back into a string to store and/or display.


Mon Jul 02, 2012 11:25 am
Profile

Joined: Dec 26, 2007
Posts: 486
Location: British Columbia
Post Re: Need help to convert Celsius to Fahrenheit
Survived my first "swim".
Perhaps not the most stylish, but it works :)
Code: Select all
celsiusVar = indigo.variables[26618308]
tempVar = celsiusVar.getValue(float, default=75.0) # Alarms as HOT if it can't be converted
indigo.variable.updateValue(836995441,str(tempVar * 9/5 + 32))
indigo.variable.updateValue(894772009,str(tempVar * 9/5 + 32))


Thanks for the "push" Jay.


Mon Jul 02, 2012 9:28 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.