Saving the doorbell visitor history to a file and displaying it

Hi All

This is my current rule which works, most of the time.

What occurs is it retrieves the image from the Doorbell and places it into the visitor-history folder just fine. What it fails to do reliably is copies the latest file from the at folder into /html and calls it lastvisitor.jpg

When I open the file using a browser http://IP/html/latestvisitor.jpg its quite old.

Any suggestions?

Thanks guys!

rule "Save Local Visitors History on Door Bell"
        Item DoorBird_DoorBell received command ON
        if(gPresenceSensors.state == ON){
        Echo_LivingRoom_TTS.sendCommand('Theres someone at your Front Gate')
        if(gPresenceSensors.state == OFF){
        sendBroadcastNotification("Theres someone at your Front Gate")
        logInfo("DoorBird", "DoorBell pressed by Visitor")

        var t = now
        var cmd = 'wget http://user:pass@ -O ' + OPENHAB_DIR + 'vistors-history/'
        cmd = cmd + t.getYear
        if (t.getMonthOfYear < 10) cmd = cmd + '0'
        cmd = cmd + t.getMonthOfYear
        if (t.getDayOfMonth < 10) cmd = cmd + '0'
        cmd = cmd + t.getDayOfMonth
        if (t.getHourOfDay < 10) cmd = cmd + '0'
        cmd = cmd + t.getHourOfDay
        if (t.getMinuteOfHour < 10) cmd = cmd + '0'
        cmd = cmd + t.getMinuteOfHour
        if (t.getSecondOfMinute < 10) cmd = cmd + '0'
        cmd = cmd + t.getSecondOfMinute
        cmd = cmd + '.jpg'

        if(vTimeOfDay.state != "DAY") {

       executeCommandLine('wget http://user:pass@ -O ' + OPENHAB_DIR + 'html/latestvisitor.jpg')

I’d suggest breaking the rule into parts and testing with a lot of logging:

  • Test the OpenHAB part separately - replace the sendHttpGetRequest and executeCommandLine with ‘logInfo(“YourRuleName”, “Test <” + cmd + “>”)’ to prove the command, and add similar logging to the GetRequest.
  • Test both parts from the command line via wget.

Without logging, all code works perfectly! :wink:

1 Like

Don’t forget you may be fighting browser caching too

1 Like

True rossko, but I never have cache issues when just opening the URL/File

Thanks James, ill give that a go