Jump to content

Network Resources delay?


Bill Morrow

Recommended Posts

Posted

Pardon me if this is not in the right forum.

I have been using my UDI to make motion triggered voice announcements through a Network Resource to my Raspberry Pi. This works, but the delay is so bad that the motion detection occurs long before the voice announcements.

I recently spent the time to get this working on my Alexa using the portal and the delay is much less. I can actually see the perpetrators on the cameras when Alexa is speaking.

I still have the Raspberry Pi connected, so I am still getting both announcements. The Raspberry Pi is typically delayed by 30 seconds to a minute or more. Today the Raspberry Pi actually spoke right after Alexa, but that was a one off. I'm thinking there is either a delay in the UDI sending the network command or there is some kind of network polling delay on the Raspberry Pi?

Does anyone have any idea what is causing this delay?

TIA

Posted
6 hours ago, Bill Morrow said:

I'm thinking there is either a delay in the UDI sending the network command or there is some kind of network polling delay on the Raspberry Pi?

Network resources fire out of the ISY immediately.  Not sure what you've got going in the rPi side, but the delay has to be there.

Posted

Hello.  Currently I have an Freetronics Ether Ten (Arduino look alike) with a DF Mini MP3 player.  The ISY sends an HTTP POST message to the device telling it which message to play.  The MP3's sound messages are located on a  32gb TF card.  My software is nothing more than a modified web server.  The DF Mini handles all the sound.

In designing this device  my goal was to voice annunciate my doors, gates and motions without Alexa or the internet.  In testing, using Wire Shark, I found that my HTTP POST messages were always instantly sent from the ISY upon the instance being set.  Not having the internet or a lot of software/sound processing generates a sound message in less than a couple of seconds.  Best of luck...

Posted

I'm doing something similar; I have a RPi with a HiFiBerry amp that plays various wav files stored on the RPi. If I test the Network Resource I get an instant response, so the delay must be in my code that launches the Network Resource. The weird thing is that the delay is not consistent, the odd time the RPi speaks before Alexa, but mostly it's about a minute behind. 

My Network Resource looks like this:

 

Quote

GET /jsonrpc?request={%22jsonrpc%22:%222.0%22,%22id%22:%221%22,%22method%22:%22Player.Open%22,%22params%22:{%22item%22:{%22file%22:%22storage/music/FrontDoor.wav%22}}} HTTP/1.1
Host: 192.168.10.279:80
User-Agent: Mozilla/4.0
Connection: Close
Content-Type: application/x-www-form-urlencoded
Content-Length: 0

 

Posted

Try throwing an extra carriage return at the end of each http GET call packet.

Writing some webpage code a few years ago I found that chrome and edge browsers would not trigger some get packages in my software. However the next get call would show up double then after it was sent. I found Firefox never did this but I then found many servers just acted immediately when I sent them a second blank line at the end of get calls and data responses.

CR = EoL = 0x0D


Sent from my SM-G781W using Tapatalk

Posted

I had an on/off variable in all of my announcement programs, so I could disable them all at once. It seems to be this variable that was causing the delays. The other issue I had was that I had to put a delay before the resource call or the resource call would get stuck in an endless loop. I did not have this issue when I first wrote the programs, it showed up later. Teken suggested adding the delay to stop the stutter. Two seconds seemed to be the minimum required.

Posted

OK, things are working a bit too well now. The RPi is very chatty now, I'm getting Garage, Garage, Garage multiple times. I tried inserting a Wait after the resource call, but this does nothing. I assume the events are still getting queued.  I thought separating the status from the resource all might solve my problem, but I don't think so. The first wait is to stop the RPi from stuttering; not sure what causes this.

The first program is the original, the next three are my Status program, the Status Update program and the Resource call program. I'm trying to make it wait before calling the resource again. I think I really need a countdown timer with a second condition of the Resource call program.

The old stuff

Quote

 

Sound Garage Motion - [ID 000B][Parent 0001][Not Enabled]

If
        Control 'EZIO SA - 9' is switched On
    And From     8:30:00AM
        To      11:59:00PM (same day)
 
Then
        Wait  0 seconds
        Resource 'Garage'
        Wait  5 seconds
 
Else
   - No Actions - (To add one, press 'Action')

 

The new stuff

Quote

 

Sound Garage Motion Status - [ID 0026][Parent 0001][Not Enabled]

If
        Control 'EZIO SA - 9' is switched Off
 
Then
        Disable Program 'Sound Garage Motion Status'
 
Else
   - No Actions - (To add one, press 'Action')

 

Quote

 

Sound Garage Motion Update - [ID 0027][Parent 0001]

If
        Control 'EZIO SA - 9' is switched On
    And From     8:30:00AM
        To      11:59:00PM (same day)
 
Then
        Enable Program 'Sound Garage Motion Status'
 
Else
   - No Actions - (To add one, press 'Action')

 

Quote

 

Sound Garage Motion Resource - [ID 0028][Parent 0001]

If
        Program 'Sound Garage Motion Status' is True
    And $Counter is 0
 
Then
        Wait  0 seconds - Required to stop the RPi from going BS Crazy
        Resource 'Garage'
        $Counter  = 5
        Wait  5 seconds
        $Counter  = 0
 
Else
   - No Actions - (To add one, press 'Action')

 


Any thoughts? The Resource program with just the Wait 5 did not seem to work, I got fewer announcements, but they were not 5 seconds apart. The original program with the Wait 5 did nothing to reduce the multiple announcements. Five seconds is just a placeholder BTW, I may change it dependent upon the complaint level.

 

Posted

OK, the above code doesn't work because the Resource program is getting triggered again before the wait completes. Makes sense when I think about it, the Wait would have to be asynchronous. 

This doesn't work either, the code after the Wait does not execute, the program does not get re-enabled and the variable does not get reset. If I run the Then a second time the code after the Wait does execute, the program does get re-enabled and the variable does get reset. ?

Quote

 

Sound Garage Motion Resource - [ID 0028][Parent 0001]

If
        Program 'Sound Garage Motion Status' is True
    And $Counter is 0
 
Then
        Disable Program 'Sound Garage Motion Resource'
        Resource 'Garage'
        $Counter  = 5
        Wait  5 seconds
        $Counter  = 0
        Enable Program 'Sound Garage Motion Resource'
 
Else
   - No Actions - (To add one, press 'Action')

 

 

Posted

OK, I'm talking to myself at this point, but maybe it will help someone else, although I found illumination from searching the forums.

Apparently simple is better, who knew. ?

I went back and corrected my original program after reading some posts. This seems to work, but I had to do a walkabout and record it, as there's never a dog walker when you need one.

My two major takeaways from this experience:

  • The ISY programs run asynchronously (makes sense), so don't count on the statements after your Wait statement being executed, as your program may get retriggered before your post Wait statements ever get executed
  • Don't mess with the criteria in your If statement in the Then/Else, as the If statement is event driven (always being checked), so your program will stop executing, even if you change the criteria to the same value
  • Someone else has probably run into your problem, so do some creative Googling

These are the two programs that seem to solve my problem. The first is my original program with the Wait removed. The second is my Timer program that disables my original program until the Wait completes and then re-enables my original program. The Timer program has no If statement. I probably could have disabled the Timer, as it only gets called by the parent program. 

My original Motion Sensor program

Quote

 

Sound Garage Motion - [ID 000B][Parent 0001]

If
        Control 'EZIO SA - 9' is switched On
    And From     8:30:00AM
        To      11:59:00PM (same day)
 
Then
        Resource 'Garage'
        Run Program 'Sound Garage Motion Timer' (Then Path)
 
Else
   - No Actions - (To add one, press 'Action')

 

My Timer program that disables Mama for a period of time to eliminate multiple triggers
 

Quote

 

Sound Garage Motion Timer - [ID 0029][Parent 0001]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        Disable Program 'Sound Garage Motion'
        Wait  5 seconds
        Enable Program 'Sound Garage Motion'
 
Else
   - No Actions - (To add one, press 'Action')

 

I likely missed something, so feel free to suggest improvements.
 

 

Posted
15 hours ago, Bill Morrow said:

so your program will stop executing, even if you change the criteria to the same value

To make a wait complete even if the criteria changes it's possible to use two programs

Program One

If

    $sVariable = 1

then

    Run Program Two (then)

else

    (none)

----

Program Two

If

    (none)

then

    Disable Program One

    Wait (however long)

    (Do whatever must be done)

    Enable Program One

else

    (none)

In this scenario the wait will complete, even if sVariable changes while waiting.

Guest
This topic is now closed to further replies.

×
×
  • Create New...