Calling HA services from within esphome lambda functions

In the yaml file define the id like this:

api:
  id: api_id
1 Like

Thanks, but I think I’m still misunderstanding. I have this in my ESPHome device code, and it will not compile:

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_encryption_key
  id: api_id

Which error message do you have when compiling?
Could you please share that and also your whole yaml, please?
Please remove any sensitive information before sharing.

Wow - it must have been a temporary thing – I compiled again today, and it worked and installed. And, it does what I want it to do: I can control my house lights using the buttons on the m5stack.

1 Like