Sensor - timestamp last sent image

I have a esp32-camera (ttgo esp-wrover with PIR) that sends images to HA. It works well, but from time to time it stops sending images, while the sensors keep sending data to HA.

The restart switch fixes this problem every time and makes it send images again.

I want to automate restart of the camera if HA doesn’t receive an image in a given time.

Is there a way to include a sensor in the ESPhome-YAML that sends timestamp for the last image to HA?

I cannot find anything about this on

I just tried this:

value_template: "{{ }}"

But the template only seems to change when a view containing the camera is loaded.

How are you sending the image to home assistant?

If it is an image sent to a folder you could use this:

Hi and thanks for looking at this :slight_smile:

The folder watcher is a good idea, but it doesn’t seem to send images to a folder. Not that I know of.

I have this ESPhome Yaml for the device:

  devicename: ttgocam_1
  friendly_name: ttgocam_1

  name: $devicename
  platform: ESP32
  board: esp-wrover-kit

  ssid: ***
  password: ***

# Enable logging

# Enable Home Assistant API


  - platform: restart
    name: $friendly_name Restart

  - platform: gpio
    pin: GPIO33
    name: $friendly_name PIR
    device_class: motion

  - platform: gpio
      number: GPIO34
      mode: INPUT_PULLUP
      inverted: True
    name: $friendly_name Button

  - platform: status
    name: $friendly_name Status

  - platform: wifi_signal
    name: $friendly_name WiFi Signal
    update_interval: 10s
  - platform: uptime
    name: $friendly_name Uptime

  name: $friendly_name Camera
    pin: GPIO32
    frequency: 20MHz
    sda: GPIO13
    scl: GPIO12
  data_pins: [GPIO5, GPIO14, GPIO4, GPIO15, GPIO18, GPIO23, GPIO36, GPIO39]
  vsync_pin: GPIO27
  href_pin: GPIO25
  pixel_clock_pin: GPIO19
  power_down_pin: GPIO26
  resolution: 800x600
  jpeg_quality: 10
  vertical_flip: false
  horizontal_mirror: false

  sda: GPIO21
  scl: GPIO22

  - file: "fonts/times-new-roman.ttf"
    id: tnr1
    size: 12

  - platform: ssd1306_i2c
    model: "SSD1306 128x64"
    address: 0x3C
    lambda: |-
      it.print(64, 32, id(tnr1), TextAlign::CENTER, "Power ON");

It sends images to camera.ttgocam_1_camera like this:

Device log in ESPhome:

[12:42:11][D][esp32_camera:157]: Got Image: len=53392
[12:42:11][D][binary_sensor:033]: 'ttgocam_1 PIR': Sending state ON
[12:42:15][D][sensor:092]: 'ttgocam_1 WiFi Signal': Sending state -21.00000 dB with 0 decimals of accuracy
[12:42:16][D][binary_sensor:033]: 'ttgocam_1 PIR': Sending state OFF

I don’t think it is an image file sent to HA, but I don’t really know :slight_smile: Where would I find it then?

I took it via MQTT and made a template binary sensor that picks up the word “Image:” in the mqtt-message to set it to True.

Solution found here: