Announcement

Collapse
No announcement yet.

DeviceButtonsAdd

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

    DeviceButtonsAdd

    Continuing the theme of "HS3 is the time for big changes" - I want to gather some quick feedback about buttons.

    Buttons, through the above subject script command can be set up to run a script, or they will cause ButtonPress to be called in the plug-in that owns that device.

    Do we still need this? Buttons can be added using value/status pairs, and we have added the ability to specify row and column positioning, so eliminating this would result in two changes: 1. No ability to run a script when a button is pressed (other than running it when the value changes to the value associated with that button) and 2. No buttons without values associated with them.

    The alternative, if this feature is still heavily used and cannot be replaced with value/status pairs, is to get away from the Chr separated string and go with a structure to be passed instead of a string. The structure would then have a separate field for the script name, and we could even then support a function and parameters, and we could include row and column fields.

    My preference is to simplify and get rid of it, but I need to hear if people still use it or plan on using it with HS3 plug-ins.

    Thoughts?
    6
    Get rid of it - value/status pairs work for me.
    50.00%
    3
    Keep it, but give it new functionality.
    50.00%
    3
    Keep it and do not change it as change freaks me out.
    0.00%
    0
    I do not have an opinion.
    0.00%
    0

    The poll is expired.

    Regards,

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

    #2
    I use buttons to run scripts in several of my applications.

    I know the forum is dedicated to HS3 plugins, however devicebuttonadd is currently available to both plugins and via scripting. Over the years I have seen many people use buttons in scripts and it's removal would be a downgrade step IMO. How would this work for them?

    I think what I am saying is that dropping functionality (for any decision you make with commands) is not just related to plugin authors but to the much larger base of script writers as well.
    Jon

    Comment


      #3
      I'm using only VSP from here on out...
      HS4Pro Running on a Raspberry Pi4
      68 Z-Wave Nodes, 175 Events, 359 Devices
      UPB modules via OMNI plugin/panel
      Plugins: Z-Wave, OMNI, HSTouch, weatherXML, EasyTrigger
      HSTouch Clients: 3 Android, 1 Joggler

      Comment


        #4
        DeviceButtonsAdd

        I'm not ready get rid of this. It adds functionality to insteon devices that aren't standard on-off but maybe I don't understand the alternative well enough
        Mark

        HS3 Pro 3.0.0.534
        Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
        Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
        Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

        Comment


          #5
          Originally posted by mnsandler View Post
          I'm not ready get rid of this. It adds functionality to insteon devices that aren't standard on-off but maybe I don't understand the alternative well enough
          You definitely have to understand the alternative before you vote!

          The alternative is that you create a value/status pair and tell HomeSeer to render it as a button. A value/status pair has a value attached to it, so let's say you give it the value 5555. When your plug-in gets the SetIOMulti from that device and the value is 5555, you will know in your plug-in which button they pressed so that you can then launch a script if you like. More conventionally for your plug-in, the value 0 might indicate OFF, 1-99 are DIM levels, and 100 is ON. The way I set these up in HomeSeer is that On and Off are buttons, but the dim values are in a range represented by a drop-down list, but they all arrive in (for example) the Z-Wave plug-in the same way - as a call to SetIOMulti. (Same as using hs.SetDeviceValue)

          So no functionality is being lost by plug-ins, and the only loss would be the ability for a script to be run by a button press when no plug-in is associated with it.
          Regards,

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

          Comment


            #6
            Originally posted by Rick Tinker View Post
            You definitely have to understand the alternative before you vote!

            The alternative is that you create a value/status pair and tell HomeSeer to render it as a button. A value/status pair has a value attached to it, so let's say you give it the value 5555. When your plug-in gets the SetIOMulti from that device and the value is 5555, you will know in your plug-in which button they pressed so that you can then launch a script if you like. More conventionally for your plug-in, the value 0 might indicate OFF, 1-99 are DIM levels, and 100 is ON. The way I set these up in HomeSeer is that On and Off are buttons, but the dim values are in a range represented by a drop-down list, but they all arrive in (for example) the Z-Wave plug-in the same way - as a call to SetIOMulti. (Same as using hs.SetDeviceValue)

            So no functionality is being lost by plug-ins, and the only loss would be the ability for a script to be run by a button press when no plug-in is associated with it.
            what's the approach for end users adding custom buttons to an existing hs device? I use this extensively myself and encourage my users to do the same to add custom functionality
            Mark

            HS3 Pro 3.0.0.534
            Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
            Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
            Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

            Comment


              #7
              Originally posted by mnsandler View Post
              what's the approach for end users adding custom buttons to an existing hs device? I use this extensively myself and encourage my users to do the same to add custom functionality
              +1
              Jon

              Comment


                #8
                Originally posted by mnsandler View Post
                what's the approach for end users adding custom buttons to an existing hs device? I use this extensively myself and encourage my users to do the same to add custom functionality
                THAT is the reason for the poll. How much of an effect would it have if end users could not do that?

                Remember, you can always run a script with an event set to run the script whenever the device changes value, and you can even set it for "ANY VALUE" too. Doing it that way also gives you the ability to add criteria on when NOT to run the script, which you cannot do when a script is added to a device - you have to do additional tests in the script if you need them.
                Regards,

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

                Comment


                  #9
                  Solution!!

                  Hey all,

                  We did not want to support DeviceButtonAdd because it uses string concatenation (stupid way of doing things) and because there was no way to specify a row-column for placement of the button.

                  So, I have come to the conclusion that we are eliminating DeviceButtonAdd.







                  OK, now that I have freaked out many of you... I found a solution to the issues without having to modify it to have new functionality too!

                  If you add value/status pairs to a device you have more flexibility over how they appear - you can specify buttons, drop-down lists, text boxes, radio buttons (some of these are not implemented yet, but they will be). The value/status pairs also have the row and column implemented now. So, taking this - since it has everything we want - and combining it with a new special device type, we can keep the functionality and do it in a new way.

                  With the next HS3 release, there will be a new Device_Type API value - Script. So a device not owned by a plug-in can set the Device_API to Script (value 128) and set the Device_Type to one of the Enum values in eDeviceType_Script which is:
                  Code:
                  Disabled = 0
                  Run_On_Any_Change = 1
                  Run_On_Value_Change = 2
                  Run_On_String_Change = 3
                  As the values imply, they define how you want a handler script to run - when the device value changes, the string changes, or either of those change.
                  Two new properties in the DeviceClass have been added:
                  Code:
                  ScriptName
                  ScriptFunc
                  Set the name to the name of the script file to be executed, and ScriptFunc to the procedure (sub or function) to be called - if ScriptFunc is blank, Sub Main will be run.
                  When the script is run, it will be passed parameters which are:
                  Code:
                  Parms(0) = dv.Ref
                  
                  Parms(1) = Enums.DeviceScriptChange.Both
                      or
                  Parms(1) = Enums.DeviceScriptChange.DevValue
                      or 
                  Parms(1) = Enums.DeviceScriptChange.DevString
                  
                  Parms(2) = dv.devValue
                  
                  Parms(3) = dv.devString
                  So Parm(0) tells you which device caused the script to be run, Parm(1) tells you what changed on the device that caused the script to be run, and then Parms(2) and (3) provide the new value and string from the device (saves you having to go get it).


                  What do you think?
                  Regards,

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

                  Comment


                    #10
                    I think that's a great solution to the problem, Rick. It gets rid of the old confusing string concatenation stuff and still allows users to create buttons. Perfect.
                    HS Pro 3.0 | Linux Ubuntu 16.04 x64 virtualized under Proxmox (KVM)
                    Hardware: Z-NET - W800 Serial - Digi PortServer TS/8 and TS/16 serial to Ethernet - Insteon PLM - RFXCOM - X10 Wireless
                    Plugins: HSTouch iOS and Android, RFXCOM, BlueIris, BLLock, BLDSC, BLRF, Insteon PLM (MNSandler), Device History, Ecobee, BLRing, Kodi, UltraWeatherWU3
                    Second home: Zee S2 with Z-Wave, CT101 Z-Wave Thermostat, Aeotec Z-Wave microswitches, HSM200 occupancy sensor, Ecolink Z-Wave door sensors, STI Driveway Monitor interfaced to Zee S2 GPIO pins.

                    Comment


                      #11
                      so how do i add a control button to a PI device? the sample plugin code doesn't seem to help me
                      Mark

                      HS3 Pro 3.0.0.534
                      Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
                      Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
                      Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

                      Comment


                        #12
                        Originally posted by mnsandler View Post
                        so how do i add a control button to a PI device? the sample plugin code doesn't seem to help me
                        This adds a reset control button on a PI's device:

                        PHP Code:
                        Dim Pair As VSPair
                        Pair 
                        = New VSPair(HomeSeerAPI.ePairStatusControl.Both)
                        Pair.PairType VSVGPairType.SingleValue
                        Pair
                        .Value 100
                        Pair
                        .Status "Reset"
                        Pair.Render VSVGPairRender.Button
                        hs
                        .DeviceVSP_AddPair(refPair
                        HS4Pro Running on a Raspberry Pi4
                        68 Z-Wave Nodes, 175 Events, 359 Devices
                        UPB modules via OMNI plugin/panel
                        Plugins: Z-Wave, OMNI, HSTouch, weatherXML, EasyTrigger
                        HSTouch Clients: 3 Android, 1 Joggler

                        Comment


                          #13
                          Originally posted by mnsandler View Post
                          so how do i add a control button to a PI device? the sample plugin code doesn't seem to help me
                          Seem to remember when you set the misc flags to dv.MISC_Set(hs, Enums.dvMISC.STATUS_ONLY), the buttons wouldn't show so misc_status_only needs to be cleared.

                          Dirk

                          Comment


                            #14
                            Ok, i got this to work but what a PITA to figure out...

                            I had to add the following to the device definition to get the buttons to show
                            dv.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES)

                            so then how do i create a status only device with control buttons?


                            here is the scenario...

                            I have a status device that tracks a Low Battery warning.

                            The status device value will go On when the battery is low.

                            i want to be able to add a "Reset" btn to this status device. So the user can
                            click the Reset btn to turn the status value Off once the battery is replaced.

                            I don't want an On or Off btn on this status device only Reset.

                            do i need to remove these default btns and then add my Reset back in?

                            I am trying to keep the UI/functionality in my hs2 & hs3 plugins the same.
                            Mark

                            HS3 Pro 3.0.0.534
                            Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
                            Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
                            Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

                            Comment


                              #15
                              Originally posted by mnsandler View Post
                              I had to add the following to the device definition to get the buttons to show
                              dv.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES)
                              Oops, I knew it was the misc settings, thought it was the Status_only that had to be cleared but you are right, it is the show_values that must be set or no buttons show.

                              Never seen any default buttons show up here. Here is a snippet of what I do.

                              dv.Location(hs) = "Sonos" 'IFACE_NAME
                              dv.Location2(hs) = ZoneName 'IFACE_NAME & InstanceFriendlyName.ToString
                              dv.Device_Type_String(hs) = SonosHSDevices.Player.ToString
                              dv.MISC_Set(hs, Enums.dvMISC.SHOW_VALUES)
                              dv.Can_Dim(hs) = False
                              dv.Image(hs) = ""
                              dv.Buttons(hs) = ""
                              dv.OLD_Values(hs) = ""
                              Dim DT As New DeviceTypeInfo
                              DT.Device_API = DeviceTypeInfo.eDeviceAPI.Media
                              DT.Device_Type = DeviceTypeInfo.eDeviceType_Media.Root
                              DT.Device_SubType_Description = "Sonos Player Master Control"
                              dv.DeviceType_Set(hs) = DT
                              dv.Status_Support(hs) = True
                              hs.SetDeviceString(HSRef, "", False)
                              hs.DeviceVSP_ClearAll(HSRef, True)

                              Dim Pair As VSPair
                              Pair = New VSPair(HomeSeerAPI.ePairStatusControl.Control)
                              Pair.PairType = VSVGPairType.SingleValue
                              'Pair.ProtectionSet = ePairProtection.Do_Not_Delete
                              Pair.Value = 1
                              Pair.Status = "Play"
                              Pair.Render = VSVGPairRender.Button
                              Pair.ButtonRender_Row = 0
                              Pair.ButtonRender_Column = 0
                              hs.DeviceVSP_AddPair(HSRef, Pair)


                              Dirk

                              Comment

                              Working...
                              X