we5ty
(We5ty)
March 30, 2022, 1:37pm
1
I’m trying to set up a simple light switch, using a relay, connected to D2 (GPIO 04), but am unable to get it to show in Lovelace UI. The device shows as online in the ESPHome dash, but I can’t add it to Lovelace, I get an error “Can’t connect to ESP. PLease make sure you YAML file contains an ‘api’ file”.
Any help greatly appreciated.
To start with, it would be very helpful to see your config.
Or check that you have the api enabled in your config, see here .
api:
1 Like
koying
(Chris B)
March 30, 2022, 1:51pm
3
Assuming it has, I see a lot of complains regarding “.local” addresses, which esphome uses IIRC, not reliably working in HAOS / supervised environments recently…
1 Like
we5ty
(We5ty)
March 30, 2022, 2:00pm
4
This is the latest attempt:
esphome:
name: patio-lights
esp8266:
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "8fbc44c3ba1c76a510e49fdf719c8dd3"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Patio-Lights Fallback Hotspot"
password: "cAzE564dUUTE"
captive_portal:
output:
- platform: gpio
id: "patio_lights"
pin: D2
tom_l
March 30, 2022, 2:23pm
5
Read the warning:
Use a switch instead of an output. Also give it a name. Components without names are hidden from home assistant.
1 Like
Looks good, not very helpful, but I actually just copied your config and uploaded it to one my nodes, and it worked, no issues, maybe an IP Address conflict?, try assigning a static address?
1 Like
I don’t think he is able to get it added to HA
1 Like
we5ty
(We5ty)
March 30, 2022, 2:41pm
8
You got further than I did, it didn’t show in the ESPHome integration card.
Just trying the suggestion about using light and name etc.
Thanks all for your help so far.
aceindy
(Aceindy)
March 30, 2022, 2:41pm
9
# Enable Home Assistant API
api:
password: !secret api_password
you can either use a secret, or just type something.
Since i use the same for all my esp’s i find using the secret easier
and when adding it to esphome it will ask you for the api password.
After that it will be added to ha
1 Like
Works with or without api password.
1 Like
we5ty
(We5ty)
March 30, 2022, 2:49pm
11
Still get the same error with this config: using patio-lights as host when adding the integration, leaving the port as 6053
esphome:
name: patio-lights
esp8266:
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "8fbc44c3ba1c76a510e49fdf719c8dd3"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Patio-Lights Fallback Hotspot"
password: "cAzE564dUUTE"
captive_portal:
light:
- platform: binary
name: "Patio Lights"
output: light_output
output:
- id: light_output
platform: gpio
patio-lights.local?
Which board/node are you using?
1 Like
Not a requirement for either, I just did it a couple times as above without, and added to HA each time.
password (Optional, string): The password to protect the API Server with. Defaults to no password.
Configuration Variables
1 Like
we5ty
(We5ty)
March 30, 2022, 5:05pm
15
Success! The final issue seem to be wrong/incompletehost name. Noob stuff huh!
Thank you very much to everyone who helped.