ESPHome and MQTT Publish + HA Automation + Counter Reset

Hi everyone,
maybe I’m a bit too stupid, I want to achieve the following:

  1. I have a mailbox sensor. ESPHome should automatically publish the value 1 when the slot is opened. Previously I did this directly in HA via an automation, now it should run via ESP. Now I have tried the following:
      - mqtt.publish:
          topic: "homeassistant/persistence/briefkasten"
          payload: "{{ states('sensor.briefkasten') | int + 1 }}" 

Unfortunately, this only leads to him posting this text “{{states(‘sensor.mailbox’) | int 1}}” as status. Where did I get the thinking error?

  1. Secondly, I wanted ESPHome to automatically activate and deactivate an automation in HA as well as trigger it, so I tried this:
      - homeassistant.action:
          action: counter.reset
          data:
            entity_id: counter.waschmaschine
      - homeassistant.action:
          action: automation.turn_on
          data:
            entity_id: automation.zahler_waschmaschine

So reset a counter and start the automation.
Unfortunately, I couldn’t find out if this is possible via ESPHome in Homeassistant. Does anyone know?

Big thanks!

This just enables a HA automation. To run it, use automation.trigger: Link to Developer tools: perform action – My Home Assistant