Announcement

Collapse
No announcement yet.

Scripting Help?

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

    Scripting Help?

    I'm trying to write a simple script to change the CSP & HSP by 5 degrees. Following the examples in the documentation, this is what I have come up with:

    sub main()

    set rcmgr = hs.plugin("HAI RC Thermostat")
    Set thermostats = haiplugin.thermostats
    haiThermo.heatsetpoint = haiThermo.HeatSetpoint + 5
    haiThermo.CoolSetpoint = haiThermo.CoolSetpoint - 5

    end sub


    I'm getting an error message:
    Script error in file: HVAC_set_temp.txt: 424 Object required: 'haiplugin' in line 5.

    I only have one thermostat, so I disregarded the 'For Each... Next' routine in the example.

    I also tried changing rcmgr to haiplugin, thinking that's why haiplugin showed up in the error message. When I did that, the error message changed to 'haiThermo' instead (same error message...)

    Help! (Thanks in advance!)

    #2
    AJ,
    Even though you only have one thermostat, the plug-in still defines a collection of thermostats. The line:

    Set thermostats = haiplugin.thermostats

    obtains a reference to the collection. To access an individual thermostat you need a:

    set haiThermo = thermostats.item(1)

    Now you can use the rest of your statements without any problem.

    Your complete funciton would look like:

    set rcmgr = hs.plugin("HAI RC Thermostat")
    Set thermostats = haiplugin.thermostats
    set haiThermo = thermostats.item(1)
    haiThermo.heatsetpoint = haiThermo.HeatSetpoint + 5
    haiThermo.CoolSetpoint = haiThermo.CoolSetpoint - 5

    You could shorten it by saying:

    set haiThermo = hs.plugin("HAI RC Thermostat").thermostats.item(1)

    Also, even with only one thermostat, the for each loop would have worked fine.

    Alan

    Comment


      #3
      Thanks, Alan... When I run the script you have there, I still get the Object required error in line 5. As I guessed, if I change rcmgr to haiplugin, all is fine.

      Is that a typo that needs to be addressed in the documentation?

      Comment


        #4
        AJ,
        Sorry for the confusion. I did not even notice the discrepency. I have fixed it in the manual. Just to clarify the correct script should be:

        set haiplugin = hs.plugin("HAI RC Thermostat")
        Set thermostats = haiplugin.thermostats
        set haiThermo = thermostats.item(1)
        haiThermo.heatsetpoint = haiThermo.HeatSetpoint + 5
        haiThermo.CoolSetpoint = haiThermo.CoolSetpoint - 5

        Alan

        Comment

        Working...
        X