Stray Cat Status - Need Help Thinking This Through

Hello everyone. New to HA (well, been fiddling for a month). This is my first post here. I’m kind of stuck and hoping for some help. Here’s what I’m trying to do:

We have a stray cat. I want a display on the dashboard that shows, starting at 8 AM that the stray cat is out and about. I currently have DOODS AI watching our outdoor camera and checking for cats. As soon as it detects a cat, I want that display to change to “Cat is home; needs food.” At that point, one of us will feed the cat, and then manually press the display, which will change it to “Cat fed.” It should remain that way until 8 AM.

I’ve got most of this figured out. I created a sensor in my YAML for this purpose:

  - sensor:
    - name: "Black Kitty"
      state: away

I also created a Mushroom Template card that mostly works:

      - type: custom:mushroom-template-card
        primary: |-
          {% if is_state('sensor.black_kitty', 'away') %}
          {% elif is_state('sensor.black_kitty', 'hungry') %}
          Awaiting noms...
          {% else %}
          Home and fed!
          {% endif %}
        picture: >-

        badge_icon: |-
          {% if is_state('sensor.black_kitty', 'away') %}
          {% elif is_state('sensor.black_kitty', 'hungry') %}
          {% else %}
          {% endif %}
        badge_color: |-
          {% if is_state('sensor.black_kitty', 'away') %}
          {% elif is_state('sensor.black_kitty', 'hungry') %}
          {% else %}
          {% endif %}
          action: none
          action: none
          action: none
        icon: ''
        secondary: last-changed
        entity: sensor.black_kitty
        multiline_secondary: false

What I don’t know how to do is configure the tap_action event to change the sensor from “hungry” to “fed”. In my Googling I’m starting to thing doing this with a “sensor” is not the right way to do it. Is there a better way of accomplishing what I’m trying to do here? I haven’t gotten to the other two automations (one triggered at 8 AM, and one triggered by the AI) which will also need to change the state of the sensor, but I assume this is all possible - but maybe not in the manner in which I’m trying to accomplish it?

Many thanks in advance!


Rather than using a template sensor, you could use a dropdown helper (input_select) that accepts values “away”, “hungry”, “fed” (etc). Then the tap_action would call the “input_select.set_option” service to select “fed”. Another automation would need to set it back to “away” at 8am. You would also need to ensure you only set it to “hungry” if it’s currently “away” so you don’t end up with a fat cat.

Alternatively, if you’re already using MQTT, you could create an MQTT sensor and publish a message with the appropriate state (and using retain to cope with HA restarts).

Thank you so much! That was all I needed to get everything working!

I have one final question. In my Mushroom Template code, everything works fine, except for my secondary information line. As you can see from my screenshot, it just says “last-changed” rather than the actual timestamp of the last time the state of the helper changed. Can you possibly lend me any clarity on how to get that working?

The last changed property would be “last_changed” (underscore rather than hyphen). However, I think on this card it needs to be coded as a template:

{{ states.input_select.black_kitty.last_changed }}

However, that’s going to look pretty ugly, so you could format it better with:

{{ | as_timestamp | timestamp_custom('%Y-%m-%d') }}

Unfortunately none of those seem to work. It seems to refuse to accept anything that isn’t simply a string. If I do anything else, the preview either disappears entirely, or you get an endless “spinning wheel of thought.”