Announcement

Collapse
No announcement yet.

Event Action Delayed but should be immediate

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

    Event Action Delayed but should be immediate

    Hey! I'm wondering if someone can help shed some light on something for me.

    I have a Sonos ZP90 connected to an amplifier and am using the Sonos Real Time Script to update the "Transport State" (play/stop/pause) in HSPRO to power up/down and adjust inputs on my amplifier as required.

    I have an event that is triggered when the Sonos Real Time Script changes this particular's zone to "Changed", it then executes, and changes the status back to "Unchanged". When the Sonos changes songs, stops, or pauses, it then again changes the status to "Changed" and the cycle begins again.

    I use this logic to check if the Sonos has started playing or has been stopped/paused for a given amount of time (at which point the receiver should turn off)

    My issue is that there is a good 40+ second delay between the HSPRO log showing the status change to "Changed" and the event being run. There are no delays setup in the event or script so I'm not certain what's causing it.

    I've included a small sample of the log to show this effect. The first time the event takes 48 seconds to run, the second 52.

    Any help would be greatly appreciated!

    Thanks

    Code:
    [COLOR=#000000]11/22/2009 9:17:12 PM [/COLOR] [COLOR=#000000]Sonos [/COLOR][COLOR=#000000]HS virtual device "Sonos Bonus Room Status Change" has been updated.[/COLOR][COLOR=#000000]
    11/22/2009 9:18:00 PM [/COLOR] [COLOR=#000000]Event [/COLOR][COLOR=#000000]Event Trigger "Sonos Power State"[/COLOR]
    [COLOR=#000000]11/22/2009 9:18:00 PM [/COLOR] [COLOR=#000000]Event [/COLOR][COLOR=#000000]Running script in background: SonosPower.vb[/COLOR]   
    [COLOR=#000000]11/22/2009 9:18:08 PM [/COLOR] [COLOR=#000000]Sonos [/COLOR][COLOR=#000000]Updating virtual device status of Bonus Room[/COLOR]
    [COLOR=#000000]11/22/2009 9:18:08 PM [/COLOR] [COLOR=#000000]Sonos [/COLOR][COLOR=#000000]All virtual device property monitors for Bonus Room have been updated.[/COLOR]
    [COLOR=#000000]11/22/2009 9:18:08 PM [/COLOR] [COLOR=#000000]Sonos [/COLOR][COLOR=#000000]HS virtual device "Sonos Bonus Room Status Change" has been updated.[/COLOR]
    [COLOR=#000000]11/22/2009 9:19:00 PM [/COLOR] [COLOR=#000000]Event [/COLOR][COLOR=#000000]Event Trigger "Sonos Power State"[/COLOR]   [COLOR=#000000]
    11/22/2009 9:19:00 PM [/COLOR] [COLOR=#000000]Event [/COLOR][COLOR=#000000]Running script in background: SonosPower.vb[/COLOR]

    #2
    Manxam,

    I don't use Sonos, so I can't answer for certain, but what does your "Sonos Power State" event look like? You don't have any "do not retrigger for xx seconds" options configured do you? Also, are you using a device status change trigger or conditional trigger for this event?

    Thanks,
    Don

    Comment


      #3
      Thanks for your response Don. I do not have any 'do not trigger..." options set (often times there is 4-5 minutes between status changes (avg length of song)).

      I have used both device status change and conditional with Status Change is Changed and both are delayed.

      Is it possible that while the Sonos script is changing the status to changed/unchanged, the script is not exiting at this time? That HS is waiting for for the script to complete before starting the event?

      Call me confused.

      Thanks!

      Comment


        #4
        Originally posted by manxam View Post
        Is it possible that while the Sonos script is changing the status to changed/unchanged, the script is not exiting at this time? That HS is waiting for for the script to complete before starting the event?
        Hmmm. How many scripts are involved in this? Are you possibly making multiple calls into the same script from different events and do you possibly have the option enabled to allow only one instance of the script to run?
        Just grasping here...

        Comment


          #5
          Only two scripts involved. One being the Sonons Real Time Script in question, and the second run by the event that is getting delayed. This "script" has a small case statement looking for STOP, PLAY, PAUSE and then triggers a the appropriate device.

          It's written in VB.net and is only a couple of lines. It shouldn't delay anything. Also, as the event that runs this script is getting delayed, I doubt that this is it.

          Thanks again for your help.

          Comment


            #6
            What's your CPU level when the "real time" script is running? I wonder if it could be CPU blocking causing delays.
            💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

            Comment


              #7
              Rupp, it barely registers. This is an intel quad core 2.4ghz, 4 gigs of ram, and running Vista, Homeseer Pro, and nothing else.

              Keep 'em coming

              Thanks!

              Comment


                #8
                Hum... Which of the event trigger types are only evaluated on the minute? Hopefully someone else can remember this. I'll bet this is the issue. Why not move the control logic to the script so it handles the device changes and triggers?
                💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                Comment


                  #9
                  Rupp,

                  It used to be that conditional events type was only evaluated 1 time per minute..

                  I think that is still true.. i know i have conditioal events that delay between 15-45 seconds between when the condition becomes true and event fires....
                  Regards,

                  Andrew B.

                  Comment


                    #10
                    In post #2 I asked if a status change or conditional event trigger was being used, and manxam indicated he actually tried both:

                    I have used both device status change and conditional with Status Change is Changed and both are delayed.

                    manxam, maybe you could post related parts of the script(s) and screen shots of the events?

                    Don

                    Comment


                      #11
                      Well, son of a ... Looking back through my logs, the event is only triggered on the minute. 7:27:00, 7:31:00, 7:37:00. So, regardless of what time the status changes, the event is only run on the next full minute.

                      The weird thing is that regardless of using "conditional with status change" or "device ... status changed to status *any*" this occurs.

                      Do both of these events only get evaluated one per minute?

                      Thanks for all of your help and suggestions guys and thanks especially to Don and Rupp for continually checking out this thread!

                      Cheers!

                      Comment


                        #12
                        Here is a copy of my script if anyone has an idea on how to make it more efficient. I don't like creating a manual event that is called from the script, nor do I like adding and deleting the delayed event.

                        What I'm doing is: checking if the Sonos Real Time Script has changed the status of the specific zone. If so, then check the transportstate (play/pause/stop) and if it's currently playing then turn on the amplifier and set the appropriate input. If it's stop/pause then create a delayed event that turns off the amp in 5 minutes IF the status doesn't change again (the reason for the removedelayedevent) and the amplifier's input doesn't move away from CD (if it does then I'm probably watching a movie or tv so don't do a thing).

                        Code:
                        Public Sub Main(ByVal parm As Object)
                        
                                Dim bonusroom_transportstate
                        
                                bonusroom_transportstate = hs.RunEx("Sonos.vbh", "GetProperty", "Bonus Room|transportstate")
                                
                                hs.SetDeviceString("S99", bonusroom_transportstate)
                                hs.SetDeviceLastChange("S99", Now())
                        
                                Select Case bonusroom_transportstate
                        
                                    Case "Play"
                                        hs.TriggerEvent("Onkyo Sonos Input")
                                        hs.RemoveDelayedEvent("", "Sonos Power Off")
                                    Case "Pause"
                                        hs.DelayTrigger(300, "Sonos Power Off")
                                    Case "Stop"
                                        hs.DelayTrigger(300, "Sonos Power Off")
                        
                                End Select
                            End Sub
                        Attached Files

                        Comment


                          #13
                          i m an amateur, but this kind of simple event works flawlessly for me

                          sonos power off for stopped Device 1st Family Room Family Room Transportstate has been Stopped for exactly 2:00 WHEN Everyday
                          Device Command: 1st Family Room Music system power Off
                          SONOS FAMILY ROOM POWER ON Device 1st Family Room Family Room Transportstate value becomes equal to Playing WHEN Everyday
                          Device Command: 1st Family Room Music system power On

                          Comment


                            #14
                            Haha, well that sure is simple and would appear to work How do you handle stopping sonos and then someone changing the stereo's source to that of say..a dvd player? Will your script still turn off the stereo or do you have logic checking for input?

                            Thanks!

                            Comment


                              #15
                              Originally posted by manxam View Post
                              The weird thing is that regardless of using "conditional with status change" or "device ... status changed to status *any*" this occurs.

                              Do both of these events only get evaluated one per minute?
                              No, device status (and device value) change triggers should be evaluated immediately. Conditional events are evaluated at least once per minute. See: About events from online help


                              Originally posted by manxam View Post
                              Thanks for all of your help and suggestions guys and thanks especially to Don and Rupp for continually checking out this thread!
                              Cheers!
                              Rupp is one of the biggest "helpers" on this forum. Most times, I'm the guy asking questions, but thanks

                              Don

                              Comment

                              Working...
                              X