Wget not always saving image correctly

I have a rule which is triggered when someone pushes the doorbell. The rule grabs a snapshot of my camera and sends a notification via Pushover and e-mail. This worked fine until some weeks ago. Sometimes (half of the time), I don’t see any image in Pushover and the image in the e-mail is not able to open. When I go to the location of the jpg which needs to be send, it’s 0kb…

This is the part where the image is saved:

var FrontDoorCam = “FrontDoor.jpg”
var LocationSS = “/etc/openhab2/html/cam/”
executeCommandLine("wget http://user:password@192.168.0.50:88/Streaming/Channels/1/picture -O " + LocationSS + FrontDoorCam)

Result in the logs:

executed commandLine ‘wget http://user:password@192.168.0.50:88/Streaming/Channels/1/picture -O /etc/openhab2/html/cam/FrontDoor.jpg’

I don’t know why it’s working one time and not the other.
Does someone has a clue?

I don’t know but you don’t need to call external programs to fetch web data, there’s builtin http commands. Probably easier to debug so give that a try.

I am using a simple bash script that stores the images with a time stamped filename.
And it works all the time

If you would run it from the command line several times you always get a picture that is ok ?
There is enough free disk space ?

Make the call to executeCommandLine a variable and log the result of its output, and add the timeout argument to executeCommandLine.

2 Likes

But then what do you do with it … or more importantly, when do you do it? It takes time to write the file away, you might need a short wait before trying to use it.

I have a timer (createTimer) of 1 second before sending the picture. I’m gonna try all the above suggestions.

I also just manually triggered the same rule 6 times after eachother, and they all want fine :thinking:

Some cameras will when busy reply with a http 503 and not send the jpg. If that is the cause the ipcamera binding will solve the issue as it stores and sends the last good jpg from ram instantly when asked.

If you did what @5iver suggested you would see the 503 reply and it is best to diagnose an issue first.

EDIT:

I happen to have an example in my rules you can adapt…

val String result=executeCommandLine("mv /tmpfs/Doorbell/"+TimeStamp.toString+".mp4 /etc/openhab2/html/Doorbell/"+TimeStamp.toString+".mp4", 500)
	logInfo("MovingFile", "Command line result: {}",result)

The above will only create a log when something goes wrong with the move command which can be very handy.

2 Likes