Camera snapshot via HTML5

Hi , please help me. Hassio send me always same camera snapshot (not latest) .
Node:

Take Snapshot data:

{
    "filename": "/config/www/snapshots/escam.jpg"
}

Send Snapshot data:

{
    "title": "ESCAM Snapshot",
    "message": "Snapshot of ESCAM attached",
    "data": {
        "image": "https://ipadress.com/local/snapshots/escam.jpg"
    }
}

This is a caching issue I believe - I encountered the same issue in the Android app notifications.
You need to generate the snapshots with a unique filename - normal practice seems to be to use a snapshot.
I generate my snapshots with a unique timestamp e.g. “Driveway_20200116081923.jpg” and send it.

Thanks for answer. When I try generate unique file name
Take Snapshot data:

{
    "filename": "/config/www/snapshots/{{now().strftime('%Y-%m-%d_%H.%M.%S')}}.jpg"
}

Send Snapshot data:

{
    "title": "ESCAM Snapshot",
    "message": "Snapshot of ESCAM attached",
    "data": {
        "image": "https://ipadress.com/local/snapshots/{{now().strftime('%Y-%m-%d_%H.%M.%S')}}.jpg"
    }
}

My snapshot file names is 2020-01-16_12.20.50 etc

But now snapshot is not received

Notify comes but without camera snapshot picture

Could it be that a second goes by between the two requests, then the file name would not be right in the second call.

Better practice would be to get the actual file name into the send snapshot call.

I pass the image directly to Telegram without creating a file on the filesystem first.

The set URL function contains:

if(msg.payload.includes("Clear")){
    return [null,null];
}

if(msg.message === 'Breached'){
    msg.payload = {}
    if(msg.topic.includes('sensor.backporch')){
        msg.payload.path = '/api/camera_proxy/camera.backporch';
    }
    if(msg.topic.includes('sensor.sidedoor')){
        msg.payload.path = '/api/camera_proxy/camera.sidedoor';
    }
    if(msg.topic.includes('sensor.driveway')){
        msg.payload.path = '/api/camera_proxy/camera.driveway';
    }
    if(msg.topic.includes('sensor.frontporch')){
        msg.payload.path = '/api/camera_proxy/camera.frontporch';
    }
    return [msg,null];
}
else { return [null,msg]; }

You could manually set your URL in the API service call node.

Then I just pass that through ChatBot and it goes to Telegram.

1 Like

Ok, my frends . Here is solution:

  1. this is totaly wrong for node red :
    {{now().strftime('%Y-%m-%d_%H.%M.%S')}}

  2. solution is moment node

Take snapshot data:

{
    "filename": "/config/www/snapshots/{{filename}}.jpg"
}

Snapshots. Works like a charm but filenames not ideal.

Hi,

Thanks for your solution! For the filename, I use the output from Date/Time Formatter so I have date and time as filename.

Can you give some more information on what’s in the date/time formatter ?
I cant seem to get it to work

thanks

EDIT -

Ok its working well for me now, my use case might be a bit niche but i want a daily snapshot for a home build to make a timelapse.

In my moment node i added

Output format - YYYY-MM-DD
output to - msg.payload1

In my create snapshot data field

{
    "filename": "/config/www/timelapse/timelapse-{{payload1}}.jpg"
}

This gives me filenames called timelapse-2021-10-11.jpg

1 Like

Hallo guys,
i can generate file but the file is empty, size 0 kb. Somebody can help me please? thanks

I have a tapo camera c100 perfeclty integrated.