ESPHome API configuration

Howdy!
Because I want to use a Wemos D1 mini outside the local relay, more precisely HA is in one locality and this wemos in another location I want to insert in the YAML file that I will write on esp the api for the connection between esp and ha , but I get the following error

INFO ESPHome 2023.12.9

INFO Reading configuration /config/esphome/t.yaml...
Failed config

api: [source <unicode string>:13]
   password: hidden
  
   [server_port] is an invalid option for [api]. Please check the indentation.
   server_port: 8126
  
   [server_address] is an invalid option for [api]. Please check the indentation.
   server_address: sss.duckdns.org

the code in the file is the following:

esphome:
  name: t
  friendly_name: t

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "hidden"
  server_port: 8126
  server_address: "sss.duckdns.org"

ota:
  password: "hidden"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "T Fallback Hotspot"
    password: "hidden"

captive_portal:
    

Exactly what it says. These are not valid options.

Are you trying to talk to a remote ESPHome over the internet? If so you cannot use the native API. You can use the web server API assuming you open the relevant ports and are willing to accept the security risk.

EDIT: re-read you post and see that you have a remote ESPHome and want to talk to HA. The most secure way to achieve this is using MQTT.

There are probably some posts in the forum that discuss this…

Or maybe this WireGuard Component — ESPHome

1 Like