Announcement

Collapse
No announcement yet.

Volume control script

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

    Volume control script

    I think I'm about to jump into HomeSeer scripting. I am attempting to create a volumn control Event for my bose plugin.
    When triggered it would
    Set volume = 4 if volume < 4
    Set volume + 2 if volume between 4 and 8
    Set volume + 5 if volume between 9 and 24
    Set volume + 10 if volume between 25 and 90

    My issue is that it seems i would actually have to write 4 events and one of those events would include 10 "+" action. This appears to a function that ups the volume by one. I think really want to send 10 commands to the Bose when I could just sent one.

    I'm thinking there is no way to make this happen without jumping into scripting. Is that correct?

    #2
    Unfortunately this can be a little difficult unless you use the plugin (I don't) but this should be something to get started. You would need to change 1234 to your volume device (I am assuming it sets the value when you change the volume).

    Code:
    Sub Main(ByVal Parms As Object)
    
    Dim NewVolume As Integer = 0
    Dim CurrentVolume As Integer = hs.devicevalueex(1234) 'change this to your volume device
    
    Select Case CurrentVolume 
    
    Case 0 to 3 : NewVolume = 4
    Case 4 to 8 : NewVolume = CurrentVolume  + 2
    Case 9 to 24 : NewVolume = CurrentVolume  + 5
    Case 25 to 90 : NewVolume = CurrentVolume + 10
    
    End Select
    
    hs.writelog("Volume","Volume To Set: " & NewVolume)
    
    End Sub
    The issue at the end is that I don't know the CAPI control for your volume device (as I don't use the plugin). If the script does what you are after you could post back with a screenshot of the status/graphics page of your volume device and I should be able to figure out the CAPI control method from that.

    Comment


      #3
      Nice code....
      Don

      Comment


        #4
        Thanks that did give me a huge jump start on the project. I need to figure out this whole CAPI thing. I tried a simplate hs.SetDeviceValue and that doesn't work. It sets it back as I look in the log carefully. I suspect i need to understand and use CAPI. I put my info in the picture below maybe I'll figure it out before you reply

        Don I grew up in Hardin, MT and had a friend who grew up in Corvallis. Not sure if your icon is some sort of firefighter but his father was fire chief in Corvallis so I thought of hime when I saw your picture and location.

        I don't see that image link when i look. If you don't it is at https://ibb.co/kSG9y6

        Comment


          #5
          here is an alternative solution using the EasyTrigger: Set Device to Expression action.

          Click image for larger version

Name:	expression.png
Views:	1
Size:	18.9 KB
ID:	1192850

          here my volume device has a reference id = 2634. The expression uses 4 nested if conditions.

          Code:
          if($$DVR:2634: < 4, 4, 
          	if($$DVR:2634: < 8, $$DVR:2634: + 2, 
          		if($$DVR:2634: < 24, $$DVR:2634: + 5, 
          			if($$DVR:2634: < 90, $$DVR:2634: + 10, 100))))
          The syntax of a if condition is
          if(condition, value if condition is true, value if condition is false)

          This solution avoid to have to deal with CAPI

          Comment


            #6
            I'll consider that spud. I do think I'm getting closer to making this work. When I set the volume in the homeseer UI it logs this.

            Device Control Device: AV Bose Bose Kitchen Volume to Volume (value) (19) by/from: CAPI Control Handler

            So now I am convinced that I need to understand CAPI.

            EasyTrigger looks interesting and I'll probably go to it at some point. But I'll have to switch to PRO before doing so. Since I've limited myself out on the 5 plugins active on my Zee S2.


            Also Spud that is some sweet code. Being able to use EasyTrigger is probably going to push me over to PRO sooner than later. I might even disable BLDenon and control all my AV via Harmony in order to squeeze in EasyTrigger now.

            Comment


              #7
              Thanks for the shout out. I live in Hamilton, so Hardin and Corvallis are quite close. No firefighter, and if I was, I would have died the last couple of years.
              We have had some miserable fire seasons.

              If you haven't been exposed to Ed's utility tenScriptAid, you should give it a look. Makes dealing with CAPI almost easy.

              Originally posted by ryanoly View Post
              Don I grew up in Hardin, MT and had a friend who grew up in Corvallis. Not sure if your icon is some sort of firefighter but his father was fire chief in Corvallis so I thought of hime when I saw your picture and location.
              Don

              Comment


                #8
                Originally posted by ryanoly View Post
                I'll consider that spud. I do think I'm getting closer to making this work. When I set the volume in the homeseer UI it logs this.

                Device Control Device: AV Bose Bose Kitchen Volume to Volume (value) (19) by/from: CAPI Control Handler

                So now I am convinced that I need to understand CAPI.

                EasyTrigger looks interesting and I'll probably go to it at some point. But I'll have to switch to PRO before doing so. Since I've limited myself out on the 5 plugins active on my Zee S2.


                Also Spud that is some sweet code. Being able to use EasyTrigger is probably going to push me over to PRO sooner than later. I might even disable BLDenon and control all my AV via Harmony in order to squeeze in EasyTrigger now.
                Try something like this;

                Code:
                hs.CAPIControlHandler(hs.CAPIGetSingleControl(1234, True, "Volume " & NewVolume, False, False))
                I'm afraid some of the parameters for CAPI are not well explained, change the 1234 for your volume device and give it a go.

                Comment


                  #9
                  Thanks Mr Happy that helped alot. I got it running.

                  I also got the EasyTrigger to make it work as well. I'm going to buy EasyTrigger because it is definitely easier in some situations and will help as I learn scripting. I also want to support spuds awesome plugin.

                  Comment

                  Working...
                  X