Camera.record with timestamp -- Timestamp is not the same when sending it over notification

Hello,

i made a automation where he records a stream for 30 seconds, and saved it with timestamp,

“haustuere_{{ now().strftime(”%Y%m%d-%H%M%S")}}"

and there is the problem.

The Timestamp is not the same when sending the video, because its 40 seconds after record.

is it somewhere possible over a “recorded filename” or “triggered filename” to get the saved filename in the notify action?

i need the timestamp, because i want to save the files for a later watch when something is happen

Here is my Code

alias: Bewegung an der Haustüre - erstelle Video
description: ''
trigger:
  - type: motion
    platform: device
    device_id: 941d002b67d7183bf91dfbff1f4d6bc3
    entity_id: binary_sensor.motion_sensor_outdoor_hausture_motion
    domain: binary_sensor
condition:
  - condition: state
    entity_id: binary_sensor.someone_home
    state: 'off'
action:
  - service: camera.record
    target:
      entity_id: camera.kamera_frontdoor
    data:
      duration: 30
      filename: /config/www/video/haustuere_{{ now().strftime("%Y%m%d-%H%M%S")}}.mp4
  - wait_for_trigger:
      - platform: event
        event_type: folder_watcher
        event_data:
          event_type: closed
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: notify.mobile_app_iphone_von_marc
    data:
      data:
        video: '/local/video/haustuere_{{ now().strftime("%Y%m%d-%H%M%S")}}.mp4'
      message: Bewegung an der Haustüre
      title: Bewegungsalarm
mode: single

here is the way I handle that:

  - alias: AS Deck Cam Motion Notifications
    id: as_deck_cam_motion_notifications
    trigger:
      - platform: state
        entity_id: binary_sensor.deck_camera_motion
        to: 'on'
    action:
      - service: input_text.set_value
        entity_id: input_text.as_deck_snap_timestamp
        data: 
          value: '{{ now().strftime("%Y%m%d_%H%M%S") }}'
      - service: camera.snapshot
        entity_id: camera.deck
        data:
          filename: /config/www/snapshots/deck_{{ states.input_text.as_deck_snap_timestamp.state }}.jpg
      - delay: 00:00:02
      - service: persistent_notification.create
        data:
          message: 'Deck Camera Motion Detected: [deck photo](https://yuigkljlkhuh;uh;oh.ui.nabu.casa/local/snapshots/deck_{{ states.input_text.as_deck_snap_timestamp.state }}.jpg)'
          title: Deck Camera Motion
      - service: notify.pushbullet_notify
        data:
          message: Motion detected on deck
          title: Deck Cam Motion Detected
          data:
            file: "/config/www/snapshots/deck_{{ states('input_text.as_deck_snap_timestamp') }}.jpg"

you need to create the appropriate input_text first.

it’s a snapshot but it should work the same for a recording I think.

2 Likes

okay, what is this for a entity ?

input_text.as_deck_snap_timestamp

can i choose what ever i want there?

this…

Thank You

for example in my configuration.yaml

input_text:
  camera_timestamp:
    name: camera timestamp

this is correct?

looks ok to me.

yeah that works well.

special thanks to you, i tried it for days :partying_face:

1 Like