Announcement

Collapse
No announcement yet.

Script Thermostat Temp as Virtual Device

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Script Thermostat Temp as Virtual Device

    Shane,

    Sorry but I accidentally deleted the entire topic. I created this with the same topic heading, so I hope you see it.

    I tried to add the script to my reply after I posted it, and I could not, so then I clicked the Delete Message button but the reality was made visible to me quickly that Delete Message is really Delete Topic!!!

    Sorry...


    I am posting the script you wanted and also attaching it to this message since the formatting of scripts here is not always the best...

    Sub Main()

    ' Replace A1 with the address of a virtual
    ' device that you want to use to display
    ' the temperature information.
    ' Uncomment the lines that use A2, etc. and
    ' create other virtual devices if you want
    ' more information displayed.
    '
    ' In the script commands, where you see (1),
    ' you can replace it with (2) for the 2nd
    ' thermostat, (3) for third, etc.

    dim sp ' Current Setpoint
    dim ct ' Current Temperature
    dim cm ' Current thermostat mode
    dim tname ' Thermostat name
    dim hai

    set hai = hs.Plugin("HAI_System") ' Use OnQ_System for an OnQ plug-in.

    ' Get thermostat name
    tname = hai.ThermostatName(1)

    ' Get the current thermostat mode
    cm = hai.GetMode(1)

    ' Allow some other HS processing to take place.
    hs.WaitEvents
    hs.WaitEvents

    ' Get the setpoint depending on what the mode is (HAI has two setpoints)
    if lcase(left(cm,1)) = "a" then ' Therm in Auto mode - don't know which setpoint to get.
    sp = "Cool:" & cstr(hai.HAI_WhatIsSetpoint(1,"c")) & " Heat:" & cstr(hai.HAI_WhatIsSetpoint(1,"h"))
    elseif lcase(left(cm,1)) = "c" then
    sp = cstr(hai.HAI_WhatIsSetpoint(1,"c"))
    else
    sp = cstr(hai.HAI_WhatIsSetpoint(1,"h"))
    end if

    ' Get the current temperature
    ct = cstr(hai.HAI_WhatIsTemp(1))


    ' Now put it all together and set it to the device
    ' string of our virtual device A1.
    hs.SetDeviceString "A1", tname & " temperature is " & ct & " with a setpoint of " & sp & " and the stat is currently in the " & cm & " mode."

    end Sub

    Rick Tinker
    HomeSeer Technologies

    Attached Files
    Regards,

    Rick Tinker (a.k.a. "Tink")

    #2
    Thanks Rick,
    Just what I was looking for. While we're on this subject, can you show me how to script a virtual device for a remote temperature sensor? I have the device showing on the HVAC already, I just want to add it to a device so I can view the temperature along with the status of all my other devices.
    Thanks,
    -Shane

    Comment

    Working...
    X