Announcement

Collapse
No announcement yet.

Controlling a Device in a script

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

    Controlling a Device in a script

    I thought it was about time that I delved into HS3...and I get around the system without too much hassle. The scripts on the other hand are another question.

    I can't work out for the life of me how to control a device:

    hs.ExecX10ByName("General SummerTime", "on")

    would be the old way of doing it.

    What's the equivalent?

    Thanks

    Darren

    #2
    Darren,

    This was my first attempt at explaining how to control devices from scripts in HS3: http://board.homeseer.com/showthread.php?t=161009

    I've learned more since then, and there have been some changes made that will eventually make it easier. I need to go back and update it, but it will get you started.

    Bill

    Comment


      #3
      Thanks Bill...darn confusing!

      Comment


        #4
        Nope I still don't get it...

        How the heck do I do something simple like...

        Code:
         
        Sub Main (parm as object)
        If hs.DayLightSavings then
        hs.WriteLog ("Info", "Daylight Check: Summer Time")
        
        If hs.IsOffByName("General SummerTime") Then
        hs.ExecX10ByName("General SummerTime", "on")
        hs.RunEx("MessOutbound.vb", "main", "System - SummerTime On")
        End If
        Else
        hs.WriteLog ("Info", "Daylight Check: Winter Time")
        If hs.IsOnByName("General SummerTime") Then
        hs.ExecX10ByName("General SummerTime", "off")
        hs.RunEx("MessOutbound.vb", "main", "System - SummerTime Off")
        End If
        End If
        End sub

        All I want to do is write some simple scripts!

        Comment


          #5
          These wrapper functions (IsOffByName, IsOffByName, etc) do not exist at this time so Bill posted code that will mimic the old wrappers. Bottom line is many of the old wrappers do not exist yet and will not for a while. Remember HS3 is in early beta and it could be a while if these get ported over if ever.
          💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

          Comment


            #6
            OK thanks..can someone help me out and do a quick conversion as example of my simple script and I'll probably be able to get started after that. I am not really a programmer these days nor do I really want to take it all up again.

            I suspect that if this really is the future of HS then it won't be for me....but we'll see its early days I suspect.

            I think the problem that this has unearthed is that if I have to spend a vast amount of time learning HS3 (time which I don't have these days) then it brings into question the competition (vera 3, Fibaro etc) which certainly seem better options on the face of it...if I have to learn the world again, pay for all my plugins...work around the ones are not being converted etc etc ......sigh sorry HS3 has been a real shock....and the scripting could be the nail in the coffin.

            Really didn't mean this as a rant and is certainly not meant as one...just a very long term user in deep shock.

            Comment


              #7
              If you are only going to reference "virtual" devices that you create, then there is a simpler way to do this. By default, a device that you create from scratch on the device management page, will have On defined as value=100 and Off defined as value=0. If you have any device control plug-ins (like X10 or Z-wave) do not click on those tabs when creating the device. Just use all the defaults (except for the floor/room/name). You do not need to assign it a device code or address if you are referencing it by name (as in your example script).

              Here is your example modified to use On=100 Off=0.

              Code:
              Sub Main (parm as object)
              If hs.DayLightSavings then
              hs.WriteLog ("Info", "Daylight Check: Summer Time")
              
              If hs.DeviceValueByName("General SummerTime") = 0 Then
              hs.SetDeviceValueByName("General SummerTime", 100)
              hs.RunScriptFunc("MessOutbound.vb", "main", "System - SummerTime On", True, False)
              End If
              Else
              hs.WriteLog ("Info", "Daylight Check: Winter Time")
              If hs.DeviceValueByName("General SummerTime") = 100 Then
              hs.SetDeviceValueByName("General SummerTime", 0)
              hs.RunScriptFunc("MessOutbound.vb", "main", "System - SummerTime Off", True, False)
              End If
              End If
              End sub
              Note that the second parameter of RunScriptFunc (which replaces RunEx) is case sensitive. So you might have to change it to "Main".

              I hope this helps. HS3 can be a little intimidating at first, but it is a significant improvement over HS2. And remember, still in early beta.

              Bill

              Comment


                #8
                Good info, Bill. I do wish that HST would change their minds on providing a single scripting function to turn basic devices ON/OFF. That was uber-powerful in HS2.
                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


                  #9
                  For those of us that have used virtual devices with ON/OFF to mean one thing and the device value to mean something else, it appears HS3 has done a serious value-subtracted. Very, very sad. I have a hard time believing there was a point where they decided they simply had to drop something that was in HS2 in order to make HS3 work, and this was it. Sigh...

                  Steve

                  Comment

                  Working...
                  X