Announcement

Collapse
No announcement yet.

hs.DeviceButtonAdd question

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

    hs.DeviceButtonAdd question

    I've just been playing around with this scripting function for the first time.

    As a test, I created 2 buttons that can run a script:

    hs.DeviceButtonAdd ("T1","Test.vb(""Main"",""Up"")","Up")
    hs.DeviceButtonAdd ("T1","Test.vb(""Main"",""Down"")","Down")

    I may have missed it in the docs but how do you get the status page to update a virtual device graphic and device string in real time (like if you pressed a normal "on or off on an X10 device) when you push the generated up/down buttons?

    I've quickly tried hs.devicevaluesadd and hs.DeviceValuesGraphicsAdd within the test.vb script but that does not seem to work.
    Jon


    #2
    Jon,
    I have spent many hours/days trying to solve the same problem with no luck. Basically HST said the script (run via custom buttons) will not complete before the refresh, thus the graphic does not get updated as you wish.

    i never pursued a javascript onclick to update the span associated with a device, but that would be an alternative. the javascript would replace the entire contents of the span. the problem is how to trigger the javascript.

    I did submit a feature request a while back to allow html within a custom button definition, but i don't they hst every implemented. maybe your second request would increase the likelyhood of getting this implemented.
    Mark

    HS3 Pro 4.2.19.5
    Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
    Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
    Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

    Comment


      #3
      Thanks for that Mark. If you have spent hours on this already then it's not worth my time on this.

      It would be possible to do this with java script as you state - you can now transfer information from server to client side using XML but it would be a bit of work.

      Perhaps Rich would entertain 2 additional optional parameters to hs.DeviceButtonAdd which you could define the graphic and device string when pressed. I know it's not perfect but better than nothing.
      Jon

      Comment


        #4
        we should definitely ask for this, i am very interested.

        i typically use the devicevaluesadd and DeviceValuesGraphicsAdd functions to change the device graphics based on values. i don't care for the devicevaluestring because it is mutually exclusive to the graphic and status.

        as you know, you can get some strange results when you use both methods.

        as far as additional optional parameters, i think a third might be the device value to set (when the btn is clicked) so HS can use its regular method for updating the graphics/status.

        maybe the two parameters are {devicestring} or {devicevalue}

        i was rather hoping HST would just fix the timing issue so we didn't have to program around this, but i guess that is low priority right now.
        Mark

        HS3 Pro 4.2.19.5
        Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
        Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
        Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

        Comment


          #5
          Mark,

          FYI, Rick T is (hopefully) looking at this via a help desk ticket I submitted.
          Jon

          Comment


            #6
            While on the subject. I've been trying to use DeviceValuesAdd to display the status of my motion sensors.

            hs.DeviceValuesAdd "A12","Motion" & chr(2) & "1" & chr(1) & "No Motion" & chr(2) & "0", False

            The Off state ("0") displays fine, but the On state ("1") just won't display. Shows nothing at all in fact. I've tried reversing the order, adding a third null state, tried "ON", "TRUE" and "-1" as well. Just nothing.

            Any ideas?
            Real courage is not securing your Wi-Fi network.

            Comment


              #7
              Never mind guys. I knew I'd choke on this as soon as I asked a dumb question. 100 = On. Must be the new binary math.
              Real courage is not securing your Wi-Fi network.

              Comment


                #8
                DeviceValue is the value stored for the device, which is usually the dim level.
                💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                Comment


                  #9
                  Yeah. I figured as much. It actually opens a whole realm of possibilities.
                  Real courage is not securing your Wi-Fi network.

                  Comment


                    #10
                    Just thought I would give an update on my problem...

                    Not good. The issue has been understood but HST cannot do anything with the current HS2 design to fix this even with my suggestion

                    Oh well.
                    Jon

                    Comment


                      #11
                      Not sure...

                      I worked around the issue by forcing a page refresh by adding a dropdown control and some javascript to the device string. In my plugin, I wanted users to be able to change a "partition" which changed the hs devices they would see.

                      You could potentially accomplish what you want but you would have your button on the left rather than on the right. And you would have to be ok with the entire page being refreshed. Let me know if you want an example and I will post it.
                      James

                      Running HS 3 on Win10 .

                      Comment


                        #12
                        Originally posted by jon00 View Post
                        Just thought I would give an update on my problem...

                        Not good. The issue has been understood but HST cannot do anything with the current HS2 design to fix this even with my suggestion

                        Oh well.
                        sounds about like the response i got to this issue.

                        jasv, i am interested in your javascript solution.

                        could we use javascript to put a custom btn in the span tag the contains the stnd Control btns?

                        i guess the problem is if you have several devices that need the same btn; keeping track of the different spans would be difficult
                        Mark

                        HS3 Pro 4.2.19.5
                        Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
                        Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
                        Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

                        Comment


                          #13
                          Yes, I would be interested in the code too.
                          Jon

                          Comment


                            #14
                            Here is the code..

                            I've attached the code. I haven't been successful at adding javascript to anything other than the devicestring because HS controls everything else and your javascript will get wiped out. If you have trouble interpreting the code please ask (I will have to refresh my memory but I should be able to answer).

                            The code I've attached creates a drop down control to the a1 device and refreshes the page using the onchange function. I've also added a function that creates a slight delay before it triggers the refresh because I needed to give my plugin time to react. You can easily change the dropdown to a button (I believe I started playing with it as a button). I suggest that you read the vb.net code execute it and look at the and the resulting HS page source for you understand it.
                            Attached Files
                            James

                            Running HS 3 on Win10 .

                            Comment


                              #15
                              Not exactly..

                              Jon,

                              I know that my example isn't exactly what you need but I think I can (for the challenge) make it happen. To be sure I understand this is what you want

                              1. A custom button up that will execute a script with "up" as a parm
                              2. the Graphic in the device string to be immediately updated showing the up graphic
                              3. The same for down

                              I will play with it tonight to see if I can come up with an example to do that.
                              James

                              Running HS 3 on Win10 .

                              Comment

                              Working...
                              X