Announcement

Collapse
No announcement yet.

Convert from Fahrenheit to Celsius in speak event

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Convert from Fahrenheit to Celsius in speak event

    Hi,
    I've been lurking around this board for a long time,both before and after my homeseer purchase, and you guys have helped me allot during the couple of month I've been into HA. Thanks!

    The other day i bought a HSM100 and my first problem was that the temperature was displayed in Fahrenheit, witch i solved after a quick search in this forum. (added HSM100FORMAT = C to 2nd line of settings.ini)
    But in a speak event it would still announce it as Fahrenheit (times 10). My solution to this was to write a script.
    My first ever, so please be gentle if it looks bad: (took me a couple of hours of playing around, searching this board and google )

    Code:
     
    Sub Main()
    Dim Celsius
    Celsius = round((((hs.Devicevalue("Q2")/10) - 32) / 1.8),0)
    hs.speak "Inside temperature is " & Celsius & " degrees"
    End Sub
    The script above will give you the temperature in whole numbers, so if you want decimals, change the last zero in:

    Code:
    Celsius = round((((hs.Devicevalue("Q2")/10) - 32) / 1.8),[B]0[/B])
    to the amount of decimals you would like.

    I hope that this could be of help for other scripting illiterates like me

    Markus
    Last edited by markus.bergvoll; October 28, 2008, 10:53 AM. Reason: Spelling error in heading
Working...
X