Announcement

Collapse
No announcement yet.

get value, change value, then go back to original value

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

    get value, change value, then go back to original value

    Trying to setup a mute button for my audio system. The Plugin I'm using doesn't have a built-in mute.
    The problem I'm having is I want the mute to be a toggle.
    So I need to get the current volume level, hit the mute and the volume will change, then I want to hit the mute again and go back to the original volume.
    How can I do that in a script?

    This is what I have so far:
    Code:
    Sub MuteTog (ByVal Parms() As String)
        Dim theDevice As Double
        Dim curVol As Double
            theDevice = parms(0)
            curVol = hs.DeviceValueEx(theDevice)
                if curVol > 0 then
                    Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(theDevice, True, "(value)", False, False)
                    cc.ControlValue = 0
                    Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)
                End if
    End Sub
    How can I get the current volume, save it and go back on the second press of the mute button?

    #2
    Disregard.
    I ended up saving it to a global variable and it's working fine

    Comment


      #3
      One thing to note about global variables is that the value stored in them is not maintained when HS restarts. For this application that’s likely not a big deal, but in case where that’s important, just create a HS device manually and store the value in it. That type of device is commonly referred to as a “virtual device”.
      HS 4.2.8.0: 2134 Devices 1252 Events
      Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

      Comment


        #4
        Doesn't matter. I'm actually deleting the GV at the end of the function.

        But I keep seeing posts of using Virtual devices instead of GV's, I need to get a volume level text box to show the level of a given music zone.
        Can I use a virtual device for something like that? I can't find a way to have the text box change with the change in volume.

        as an aside, I can't believe how long Homeseer has been around and it still can't just pass a simple variable from one screen to another.
        HS Support, if you are watching this post, why not just add a field to the "screens" actions that allow variables to be passed???

        Comment


          #5
          No reason you can't reference the same Virtual Device & change its value in both screens.
          Real courage is not securing your Wi-Fi network.

          Comment


            #6
            Originally posted by Wadenut View Post
            No reason you can't reference the same Virtual Device & change its value in both screens.
            ok,How?

            Comment


              #7
              I've never done it with a text box, generally just incremented/decremented values but your case shouldn't be much more complicated...
              As a button action, just run an immediate script.
              For some reason here the board isn't allowing me to upload a pic of an example.

              This immediate increments the value of a VD by 1

              & hs.SetDeviceValueByName "Garage Thermostat",hs.DeviceValueByName("Garage Thermostat")+1
              Real courage is not securing your Wi-Fi network.

              Comment


                #8
                For others who may find this in the future, a non-scripting solution would be EasyTrigger's push/pop functions.
                -Wade

                Comment


                  #9
                  Originally posted by Wadenut View Post
                  I've never done it with a text box, generally just incremented/decremented values but your case shouldn't be much more complicated...
                  As a button action, just run an immediate script.
                  For some reason here the board isn't allowing me to upload a pic of an example.

                  This immediate increments the value of a VD by 1

                  & hs.SetDeviceValueByName "Garage Thermostat",hs.DeviceValueByName("Garage Thermostat")+1
                  I don't need it to control the volume, just display it. So when I cahnge the volume by any other means, the label should reflect he change.

                  Comment


                    #10
                    Originally posted by Demusman View Post

                    I don't need it to control the volume, just display it. So when I cahnge the volume by any other means, the label should reflect he change.
                    So just display it in both screens, or as many places as you want.

                    You can use the device value or the device text in a text box. Simple.

                    Again, the board won't allow me to post a screen shot today so I can't show you. Look at "Status Tracking Normal" in the properties for a text box, or button. Add your VD there. The rest should be clear from there.
                    Real courage is not securing your Wi-Fi network.

                    Comment


                      #11
                      Can't do that.
                      Been posting in a few threads trying to figure this out so I didn't realize this one doesn't have the details.
                      I'm setting up an audio screen with variables for the elements so there is no "both screens". Just one screen and it needs to display the volume from one of 6 audio zones depending on which is chosen.

                      Comment


                        #12
                        OK. So, as I understand you, a Zone will have it's value changed manually and HS knows about this (?). Are there separate HS devices for each Zone?

                        Option 1: You'll need to put the value of the last Zone in a Virtual Device. I'd use the Device Value for this. I'd also populate the same Virtual Device String with the name of that Zone.
                        Option 2: Depending on what you want to see in HS, you may need two virtual devices - one to display the name, the other the value in the devices' text fields.
                        Option 3: A single device with the Name and Value displayed in the Device Text (this would require some additional scripting). This likely would end up looking a mess in HST.

                        Then (Option 1/2), by using two text boxes, one for the name, the other for the value, you'll have what I believe you're looking for. The two boxes can be designed to look like a single item on the HST screen.
                        Or
                        One Text box (Option 3).

                        In any case, some HS scripting is going to be necessary; perhaps I can help with that. An event to run the script would be trigerred by a Zone Value change, possibly passing the necessary parameters to the script. There'll likely need to be a separate event for each Zone, calling the single script.

                        I don't know if you're able to post screen shots today... it hasn't been working for me.
                        Real courage is not securing your Wi-Fi network.

                        Comment


                          #13
                          Screenshots not working here either but I'll try to explain without pics.

                          I open my main audio page, it has the 6 zones as buttons on it.
                          I click a zone button, it opens a screen (AudioZone it's called) that has the zone controls (pwr, vol up , vol down, mute and a slider for volume) and it has six source buttons.
                          The zone button sends the refID of the appropriate zone for the controls to the control buttons on the AudioZone screen.
                          I then wrote a script that takes the refID and performs the correct action based on the refID. So on the main Audio, if I select zone1, the power button on the AudioZone will toggle power on zone1 only. as well as volume up/down and mute.
                          This is working for all 6 zones and 6 sources.
                          I cannot get the slider to work since there is no text entry on slider elements.
                          And I cannot get the volume level to display because I can't figure out how to get just status from a "variabled" label if that makes sense. I did get it to display for all 6 zones but it was static and didn't show volume changes while on that screen.
                          What I need to do is:

                          1. Get the volume slider to be dynamic with the zone chosen.
                          2. Get the volume level showing.
                          3. Get the Zone name showing ( this I haven't even played with yet and I think it should be easy to do in the script)

                          Once those 3 things are figured out I have a complete audio control with only 1 zone screen, and 6 source screens instead on well over a dozen screens total.
                          Is it worth it? Not sure but I'm gonna keep trying. It definitely should not be this difficult with any automation software. Just need to pass variables between screens and it's done. I've done this with two other programs and it was simple.

                          Comment


                            #14
                            Certainly would be easier with screenshots
                            Couple questions:
                            So, these screens you speak of are in HST already?
                            Is this all associated with some plugin? And if so, are there triggers associated with the various actions? What are the available triggers?

                            As I see it...
                            1. will be sourced from a Virtual Device or multiple VDs which will be populated via the script.
                            2. we should be able to source from the device value of the associated zones and store in the VD(s).
                            3. also will be part of our Virtual Device(s)
                            Once the VD is/are populated, you'll use that in your "common" screen (which I'm assuming at this point is for display purposes only)

                            Seems to me, it's a matter of copying the needed information from the last Zone into a Virtual Device. This will be scripted, and as I mentioned, a single script will do the trick provided we can pass the Zone number to it in order to use that data to act on. There will be separate events for each Zone/Action all running the single script with parameters.
                            Once you have the VD populated, you can use it in HST quite easily.

                            Since you already have some of the work scripted, perhaps post that (if the board will allow it) and I may have a better idea how to augment it to get the info into the VD to use in your common screen.

                            I think you can go ahead and design your HST screen at this point. Just create a Virtual Device to reference in it. That'll be half the battle done.

                            (I may not be able to check the board again now until morning).
                            Real courage is not securing your Wi-Fi network.

                            Comment


                              #15
                              Attachments are working again.
                              This is how it goes.
                              I open the main audio screen.
                              Click image for larger version

Name:	Audio.PNG
Views:	454
Size:	242.0 KB
ID:	1313204 It has the 6 zones on it.
                              The zone buttons do the following:
                              Click image for larger version

Name:	Audio Button.PNG
Views:	455
Size:	117.7 KB
ID:	1313201 Play a sound, open a new screen, send refID's for power (line2 and down to 11), vol up, vol down, mute then 6 sources. The refID's are for the plugin devices corresponding to each action. This is all working.

                              The next screen (by choosing a zone on the above) is the zone control.
                              Click image for larger version

Name:	AudioZoneSource.PNG
Views:	456
Size:	250.5 KB
ID:	1313200 On this one you can see a label with "Master Bedroom", that's a temporary label I'm using to try and get the zone name to populate. The "16" is the volume level. I can get it to show current volume but it doesn't change with a volume change.
                              So now I would power the zone on if it's off, and select a source.
                              The power action is this:
                              Click image for larger version

Name:	Power Button.PNG
Views:	442
Size:	107.1 KB
ID:	1313202 It runs this script:
                              Code:
                              '-------Audio Zone Script------------------------------
                              '
                              Sub PwrTog (ByVal Parms() As String)
                                  Dim theDevice As Double
                                      theDevice = parms(0)
                                          if hs.DeviceValueEx(theDevice) = 100 then
                                          hs.CAPIControlHandler(hs.CAPIGetSingleControl(theDevice,True,"Off",False,False))
                                          else hs.CAPIControlHandler(hs.CAPIGetSingleControl(theDevice,True,"On",False,False))
                                          end if
                              End Sub
                              '----------------
                              As do the other controls, again, all working fine except the slider.
                              Selecting a source would then open the appropriate screen.
                              Click image for larger version

Name:	Complete.PNG
Views:	443
Size:	476.6 KB
ID:	1313203

                              So your initial questions above are basically answered by the above I think.

                              Now, my problem is I don't know how to use a VD to control the slider, or display volume level and zone name.
                              Do I have to set the control use to dim in the status graphics tab maybe??

                              Again, this may be all for nothing right now anyway because I'm opening screens on top of the main screen to do this and, in the last attachment for instance, if I press the volume up button it then brings the main screen on top of the source screen defeating the purpose of this.
                              Is there a way to make "on top" screens stay on top even if I click on the bottom screen?

                              On that note, where do I send feature requests for HST?? Directly to support or is there somewhere else?
                              Attached Files

                              Comment

                              Working...
                              X