Announcement

Collapse
No announcement yet.

Can't change thermostat SetPoint from scripting.

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

    Can't change thermostat SetPoint from scripting.

    Hello Guys, new forum user here.

    Been running an OmniPro IIe for several years with HiFi, two OmniStat 2's, 50 or so HAI light switches, bunch of motion sensors, about 200 lines of script. Works great.

    Recently got a few Amazon Tap's and stumbled over HomeSeer and had to experiment. Purchased a HomeTroller Zee S2 with the HAI plugin and got everything going pretty easily. Still working out the nuances and names of things with Alexa, but it works as advertised.

    I wanted to program a statement for the wife who is either too warm or too cold with a statement to Alexa like, "Alexa, turn the downstairs air conditioning on". To try to accomplish that I had the following strategy:

    1. Grab the current temperature and stick it in a counter.
    2. Subtract 1 from it using a counter.
    3. Inject that value into the heating setpoint.

    I quickly realized I couldn't accomplish that via eventing alone and needed to open the manual for scripting. Being a C# developer for 12 years, cracked open the script editor.

    Quickly knocked out the following:


    public Object Main(Object[] parm)
    {
    var dv = hs.DeviceValueByName("Downstairs Temperature");
    dv--;
    hs.SetDeviceValueByName("Downstairs Cooling Setpoint", dv);
    hs.WriteLog("Down AC On", dv.ToString());

    return null;
    }


    Ran it and it properly injected the expected value into the Thermostat's setpoint and can see the value change automatically in the HomeSeer web UI. Walk over to the thermostat, still old value on the screen. Weird. Walk back to the web UI and simply hit the [Submit] button which has the new value in it already, and the thermostat immediately updates.

    Dug around the API's a bit more and found:


    hs.ControlThermostat("Downstairs Thermostat", "SetSetPoint", dv);


    (Which does the heat SP) but same result. HomeSeer shows the new value in the web UI, but doesn't push it to the thermostat. Hitting the [Submit] button in the web UI pushes the value properly and the thermostat clicks on.

    Is this just a limitation from scripting, or a bug?

    Thanks.

    #2
    Originally posted by ChrisCoble View Post
    Hello Guys, new forum user here.

    Been running an OmniPro IIe for several years with HiFi, two OmniStat 2's, 50 or so HAI light switches, bunch of motion sensors, about 200 lines of script. Works great.

    Recently got a few Amazon Tap's and stumbled over HomeSeer and had to experiment. Purchased a HomeTroller Zee S2 with the HAI plugin and got everything going pretty easily. Still working out the nuances and names of things with Alexa, but it works as advertised.

    I wanted to program a statement for the wife who is either too warm or too cold with a statement to Alexa like, "Alexa, turn the downstairs air conditioning on". To try to accomplish that I had the following strategy:

    1. Grab the current temperature and stick it in a counter.
    2. Subtract 1 from it using a counter.
    3. Inject that value into the heating setpoint.

    I quickly realized I couldn't accomplish that via eventing alone and needed to open the manual for scripting. Being a C# developer for 12 years, cracked open the script editor.

    Quickly knocked out the following:


    public Object Main(Object[] parm)
    {
    var dv = hs.DeviceValueByName("Downstairs Temperature");
    dv--;
    hs.SetDeviceValueByName("Downstairs Cooling Setpoint", dv);
    hs.WriteLog("Down AC On", dv.ToString());

    return null;
    }


    Ran it and it properly injected the expected value into the Thermostat's setpoint and can see the value change automatically in the HomeSeer web UI. Walk over to the thermostat, still old value on the screen. Weird. Walk back to the web UI and simply hit the [Submit] button which has the new value in it already, and the thermostat immediately updates.
    Yeah, setting the device value just sets the value. HS does not 'control' the device just by setting the device value. For actual control of a device, search the board on CAPI.

    Originally posted by ChrisCoble View Post
    Dug around the API's a bit more and found:


    hs.ControlThermostat("Downstairs Thermostat", "SetSetPoint", dv);


    (Which does the heat SP) but same result. HomeSeer shows the new value in the web UI, but doesn't push it to the thermostat. Hitting the [Submit] button in the web UI pushes the value properly and the thermostat clicks on.

    Is this just a limitation from scripting, or a bug?

    Thanks.
    hs.controlthermostat is a legacy function call back when all thermostats were controlled by a HomeSeer script. I'm not surpised it doesnt work on HS3. For granular thermostat control, you will need the thermostat API/SDK and I can tell you that it is a lesson in pure patience trying to get it to work

    You might be better off trying the CAPI approach...
    HS4Pro on a Raspberry Pi4
    54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
    Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

    HSTouch Clients: 1 Android

    Comment


      #3
      That's really bizarre as I can manually plug in a value in the HS Web UI, press [Submit] and it sets the thermostat heat and cool set point just fine to the physical thermostat. So at present, with only the HAI plugin enabled, I can control the physical thermostat. Just the script method doesn't work.

      Comment


        #4
        Can't change thermostat SetPoint from scripting.

        Originally posted by ChrisCoble View Post
        That's really bizarre as I can manually plug in a value in the HS Web UI, press [Submit] and it sets the thermostat heat and cool set point just fine to the physical thermostat. So at present, with only the HAI plugin enabled, I can control the physical thermostat. Just the script method doesn't work.


        It's by design. As Rob indicated, search the board for CAPI (use Google to search) and you should find some good examples (although most will be in VB.NET so you'll need to convert to C# syntax).

        Cheers
        Al


        Sent from my Phone using Tapatalk
        HS 4.2.8.0: 2134 Devices 1252 Events
        Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

        Comment


          #5
          Yeah I found a bunch of things and the rationale on why it's the way it is.

          That being said, it would have been nice if they kept at least a single call which did poke the value, even if it was restricted to 0-100. Make it easier to do something simple.

          VB makes mommy cry.

          I'll try and do some reverse engineering here to tease out the set points from a temperature device.

          Comment


            #6
            It should look something like this (in VB.NET):

            Code:
            hs.CAPIControlHandler(hs.CAPIGetSingleControl(targetDevice,false,targetValue,false,true))
            where:

            targetDevice is the reference id of the setpoint device as an Integer
            targetValue is the value you want to set it to. It should be a Double, but can likely be passed as an Integer as well.

            See this page in the help file for info on what the Boolean values are used for: http://homeseer.com/support/homeseer...getcontrol.htm

            Cheers
            Al
            HS 4.2.8.0: 2134 Devices 1252 Events
            Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

            Comment


              #7
              Thanks, that seems pretty simple actually.

              I was reading Rick Tinker's defense of the complexity of CAPI and why it made sense to remove the previously simple way of doing it. I had to chuckle.

              For the past 13 years I've worked for a software company which builds SCADA software for industrial automation. It's like IoT for big systems, not unlike HomeSeer except on an enterprise/industrial scale. The solution we deliver today allows you to build anything and everything, great power!!! Aaaaand, it's hard to use. Satisfying those 20% of power users kills the productivity of 80% of your customers. The argument for CAPI is very similar here.

              "But, you can do anything!" (customer), "But, we can't figure out how to do anything!".

              I've spent the last several years beating that concept out of people's heads.

              Comment


                #8
                Originally posted by ChrisCoble View Post

                "But, you can do anything!" (customer), "But, we can't figure out how to do anything!".

                I've spent the last several years beating that concept out of people's heads.
                You have much more work to do, I fear.

                Comment


                  #9
                  Originally posted by ChrisCoble View Post
                  Thanks, that seems pretty simple actually.

                  I was reading Rick Tinker's defense of the complexity of CAPI and why it made sense to remove the previously simple way of doing it. I had to chuckle.

                  For the past 13 years I've worked for a software company which builds SCADA software for industrial automation. It's like IoT for big systems, not unlike HomeSeer except on an enterprise/industrial scale. The solution we deliver today allows you to build anything and everything, great power!!! Aaaaand, it's hard to use. Satisfying those 20% of power users kills the productivity of 80% of your customers. The argument for CAPI is very similar here.

                  "But, you can do anything!" (customer), "But, we can't figure out how to do anything!".

                  I've spent the last several years beating that concept out of people's heads.
                  You're welcome. Yes, it's relatively straight-forward once you get used to it. Yes, the whole premise seems kind of odd to me as well, especially the part where they are indicating that basically everything can be done with events. There are many examples where things are much better with scripts rather than many events or very complex events.

                  Cheers
                  Al
                  HS 4.2.8.0: 2134 Devices 1252 Events
                  Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                  Comment


                    #10
                    Totally agree. While I don't write code daily anymore as I'm now a Program Manager, using API's have been part of much of my adult life. What makes it super easy is having a compiler, debugger, and autocomplete!

                    I feel like I'm back in the dark ages writing code in notepad. It's possible I'm spoiled now though.

                    Comment


                      #11
                      Originally posted by ChrisCoble View Post
                      Totally agree. While I don't write code daily anymore as I'm now a Program Manager, using API's have been part of much of my adult life. What makes it super easy is having a compiler, debugger, and autocomplete!

                      I feel like I'm back in the dark ages writing code in notepad. It's possible I'm spoiled now though.
                      There are better options than Notepad though I use EditPlus. If you were using vb.net, then there's a great option to use the free version of Visual Studio along with TenScripting: http://www.tenholder.net/tenWare2/te...3/default.aspx.

                      Cheers
                      Al
                      HS 4.2.8.0: 2134 Devices 1252 Events
                      Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                      Comment


                        #12
                        Originally posted by sparkman View Post
                        There are better options than Notepad though I use EditPlus. If you were using vb.net, then there's a great option to use the free version of Visual Studio along with TenScripting: http://www.tenholder.net/tenWare2/te...3/default.aspx.

                        Cheers
                        Al

                        I have a licensed version of Visual Studio Enterprise sitting on my computer here, and writing in VB is against my religion. That plugin looks pretty cool though and would for sure make things far easier.

                        This script did the trick just now to pull the current temp, increase it by one and push into the thermostat's heat setpoint to 'warm it up a little'. This script activates via Alexa with, "Alexa, turn the downstairs heat on":

                        Code:
                        public Object Main(Object[] parm) 
                        {
                             var dv = hs.DeviceValueByName("Downstairs Temperature");
                             dv++;
                        
                             var targetDevice = hs.GetDeviceRefByName("Downstairs Heating Setpoint");
                        
                             var control = hs.CAPIGetSingleControl(targetDevice,false,"0",false,true);
                             control.ControlValue = dv;
                             hs.CAPIControlHandler(control);
                        
                             return null;
                        }
                        As I want to do this for the off version except "dv--" I guess I need to look at how parameters are passed now to start getting fancy and not have so much duplicate code.

                        Comment


                          #13
                          Kaboom!

                          LOL, I was experimenting with passing parameters into a C# script and crashed the entire HomeSeer box. It went offline, hopefully it's rebooting.

                          So much for exception handling.

                          Comment


                            #14
                            Yeah, that has been reported a few times over the years. I think if you only run a single entry point, like main(), it works ok, but if you use your own function, it dies. hard.
                            HS4Pro on a Raspberry Pi4
                            54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                            Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                            HSTouch Clients: 1 Android

                            Comment


                              #15
                              Originally posted by rmasonjr View Post
                              Yeah, that has been reported a few times over the years. I think if you only run a single entry point, like main(), it works ok, but if you use your own function, it dies. hard.
                              I'm not sure the exact thing I did as I didn't realize it was dead right away. I think I stuck "Main" in the 'sub or function' area of the event as the parameters were not behaving as I expected. Params are typically separated by a space from a command line perspective, but I wanted to group them with text in quotes. Something went sideways.

                              Sadly it didn't reboot and apparently needs a power cycle.

                              Comment

                              Working...
                              X