Announcement

Collapse
No announcement yet.

Controlling a SmartThings device via script

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

    Controlling a SmartThings device via script

    I apologize in advance because this issue is so simple, it must be elsewhere on the forums, but I can't find it.

    I have a Centralite thermostat which is not yet supported in Homeseer so it is still connected to my old SmartThings system and being presented in Homeseer via the SmartThings plugin.

    I want to add Increment and Decrement setpoint functionality so I can use up/down buttons in HS4Touch.

    The script below runs and thinks it is incrementing the setpoint, but the setpoint on the device never actually changes.

    Is there an extra step that I need to go through to send the change back through the plugin?

    I appreciate any suggestions.

    Code:
    Sub IncrementSetpoint(parms As Object)
    Dim CurrentValue, NewValue, SetpointRef
    
    If hs.DeviceValueByName("Thermostat Mode") = 5 'Heat
    hs.WriteLog("Info", "Thermostat Mode is Heat")
    SetpointRef = hs.GetDeviceRefByName("Thermostat Heating Setpoint")
    Elseif hs.DeviceValueByName("Thermostat Mode") = 1 'Cool
    SetpointRef= hs.GetDeviceRefByName("Thermostat Cooling Setpoint")
    End If
    
    CurrentValue = hs.DeviceValue(SetpointRef)
    NewValue = CurrentValue + 1
    hs.WriteLog("Info", "Current Value: "&CStr(CurrentValue)&", NewValue: "&CStr(NewValue))
    hs.SetDeviceValueByRef(SetpointRef, NewValue, FALSE)
    CurrentValue = hs.DeviceValue(SetpointRef)
    hs.WriteLog("Info", "FinalValue: "&CStr(CurrentValue))
    End Sub​
    TIA
Working...
X