Help needed with custom template

Hi all, I’m trying to create a custom that tells me whether the dog has been fed today. It will change state to “Fed” if the food bin has been opened at any time during the day, then stays in that state until it resets to “Not Fed” at midnight. This is what I came up with (in my template.yaml file):

# Has dog been fed?
- trigger:
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d00070074ca
      to: 'on'
  sensor:
    - name: "Dog Fed Today"
      state: "Fed"
      icon: mdi:dog

# Resets at midnight
- trigger:
    - platform: time
      at: '00:00:00'
  sensor:
    - name: "Dog Fed Today"
      state: "Not fed"

Unfortunately this ends up creating 2 different sensors. How do I combine both functions into one?

- trigger:
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d00070074ca
      to: 'on'
      id: "Fed"
    - platform: time
      at: '00:00:00'
      id: "Not Fed"
  sensor:
    - name: "Dog Fed Today"
      state: "{{ trigger.id }}"
      icon: mdi:dog

Thanks, I’ll give that a go

It worked! Appreciate the help

1 Like