Esphome action doesn't show up in Home Assistant

I’d expect the MH-Z19 calibration action to show up in Home Assistant, but it doesn’t.

api:
  encryption:
    key: "xxx"
  actions:
    - action: mhz19_calibrate_zero
      then:
        - mhz19.calibrate_zero: my_mhz19_id

sensor:
  - platform: mhz19
    id: my_mhz19_id
    co2:
      name: MH-Z19 CO2 Value
    temperature:
      name: MH-Z19 Temperature

Thanks in advance!

I just set up some actions in ESPHome (or services in my case) and it worked as intended. I actually forgot about the change to actions and copy/pasted some YAML from an old project that used the services nomenclature. Maybe try that?

I also assume you’re looking in Developer Tools - Actions?

This is completely anecdotal evidence but for me, ive noticed that a lot of times ive added api actions or services and then flash the board, they dont always appear right away and have a delay. IDK if im alone on this but its been a thing that happens to me sometimes.

There are other ways to achieve the same result too. You could do something like this and then instead of calling an esphome action, you can just do a call service and press your new button which triggers the exact same action from your api action.

There’s really no difference between the two methods and i’d even argue the button is better because it keeps all of the functions on the esp, making it 100% able to run independent of HA. Creating the calibrate_zero action as an api doesnt allow you to then trigger that action from the esp device, for example web_server you couldnt call that api action but, the button you absolutely can call.

button:
  - platform: template
    name: "mhz19 calibrate zero"
    id: calibrate_zero
    on_press:
      then:
        - mhz19.calibrate_zero: 
            id: my_mhz19_id

Thanks, guys! You helped me figure this out.

The zero calibration action was already available via Developer Tools → Actions, and adding the provided configuration fragment made the calibration button appear on the device’s page.

Personally, I would switch it from an api action to native esphome button, switch, script, etc for reasons mentioned previously…