Problem Sending photo with timestamp using Pushbullet

Hello!

I’ll try to send pictures from an D-Link wifi IP Camera to pushbullet with hassio. For now i trigger the automation with an input_boolean. I have partially success. The script saves an photo with a fixed name and pushbullet sends it. I can even name the photo with date and time, sort of. It works for date and hours and minutes, but it doesn’t work when adding seconds. I have to add an delay otherwise pushbullet tries to send the file before Hass have saved it. As far as i can tell pushbullet tries to send a file with another time stamp than is saved.

When triggered the file “2018-09-12_21.38.06_LR.jpg” is saved, but pushbullet looked for the file “2018-09-12_21.38.18_LR.jpg”

I want to date my pictures so that more than one picture can be stored each minute and so that pushbullet can send them. If i skip the seconds the pictures are saved over each other if the automation is triggered within the same minute.

Any suggestions?

My code is as below.

- id: ' '
  alias: camera_test
  trigger:
  - entity_id: input_boolean.test
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      entity_id: camera.livingroom_camera
      filename: "/config/tmp/{{now().strftime('%Y-%m-%d_%H.%M.%S')}}_LR.jpg"
  - delay: 
      seconds: 10
  - data_template:
      message: "Motion detected!"
      title: "Alert!"     
      data:
        file: "/config/tmp/{{now().strftime('%Y-%m-%d_%H.%M.%S')}}_LR.jpg"
    service: notify.pushbullet

Thanks in advance!

I have goten so far that I can set a variable called picture_date and use it to name the photo I’m taking. But how do I use the same variable when sending the file with Pushbullet?

My code is as below, but it doesn’t work, when pushbullet tries to send the file it can’t find it, it looks for a file named “_LR.jpg” instead of a file named “YYYY-MM-DD-HH.MM.SS_LR.jpg”

- id: '1537650449584'
  alias: Test Camera
  trigger:
  - entity_id: input_boolean.test
    platform: state
    to: 'on'
  condition: []
  action:
  - data_template:
      entity_id: camera.livingroom_camera
      filename: >
        {% set picture_date = now().strftime('%Y-%m-%d_%H.%M.%S') %}
        /config/tmp/{{ picture_date }}_LR.jpg
    service: camera.snapshot
  - delay:
      seconds: 10
  - data_template:
      message: Rörelse har detekterats!
      title: Rörelse!
      data:
        file: >
          /config/tmp/{{ picture_date }}_LR.jpg
    service: notify.pushbullet

Any ideas?

Solved it!

I made a script out of it which I triggered from an automation where the variabel I send with it is the time and date.

The automation:

- id: '1537650449584'
  alias: Test Camera
  trigger:
  - entity_id: input_boolean.test
    platform: state
    to: 'on'
  condition: []
  action:
    service: script.turn_on
    entity_id: script.motion_livingroom
    data_template:
      variables:
        picture_date: "{{now().strftime('%Y-%m-%d_%H.%M.%S')}}"

The script:

motion_livingroom:
  alias: Livingroom motion detector
  sequence:
    - data_template:
        entity_id: camera.livingroom_camera
        filename: /config/tmp/{{ picture_date }}_LR.jpg
      service: camera.snapshot
    - delay:
        seconds: 10
    - data_template:
        message: Rörelse har detekterats!
        title: Rörelse!
        data:
          file: /config/tmp/{{ picture_date }}_LR.jpg
      service: notify.pushbullet

The time maybe doesn’t get exactly correct since it’s a little bit of an delay from the automation to the script but it’s okay I think.

2 Likes