I am having trouble connecting my ESP device to Homeassitant.
I am using an ESP32_DevkitC_V4 with an ESP32-WROOM-32D Chip.
The Board is connected to a Ubiquity DreamRouter using a fixed IP and fixed AP.
Im using the following code for my board.
esphome:
name: esp-vitrine-v6
friendly_name: ESP_Vitrine_V6
esp32:
board: nodemcu-32s
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "9am/TrVuWl2oWkrUviRDukY0oQpRpALcgS9tnN5hiFU="
ota:
password: "081907e3bbe2d034cd86d62bf9c5018b"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
# Set this to the IP of the ESP
static_ip: 192.168.1.86
# Set this to the IP address of the router. Often ends with .1
gateway: 255.255.255.1
# The subnet of the network. 255.255.255.0 works for most home networks.
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp-Vitrine-V6 Fallback Hotspot"
password: "MUVeObp6LcAq"
captive_portal:
light:
- platform: neopixelbus
type: RBG
variant: WS2811
pin: GPIO23
num_leds: 30
name: "Arbeitszimmer_Board_V4_D10"
- platform: neopixelbus
type: RBG
variant: WS2811
pin: GPIO22
num_leds: 30
name: "Arbeitszimmer_Board_V4_D9"
- platform: neopixelbus
type: RBG
variant: WS2811
pin: GPIO21
num_leds: 30
name: "Arbeitszimmer_Board_V4_D8"
- platform: neopixelbus
type: RBG
variant: WS2811
pin: GPIO19
num_leds: 30
name: "Arbeitszimmer_Board_V4_D7"
- platform: neopixelbus
type: RBG
variant: WS2811
pin: GPIO18
num_leds: 30
name: "Arbeitszimmer_Board_V4_D6"
- platform: neopixelbus
type: RBG
variant: WS2811
pin: GPIO5
num_leds: 30
name: "Arbeitszimmer_Board_V4_D5"
- platform: neopixelbus
type: RBG
variant: WS2811
pin: GPIO17
num_leds: 30
name: "Arbeitszimmer_Board_V4_D4"
- platform: neopixelbus
type: RBG
variant: WS2811
pin: GPIO16
num_leds: 30
name: "Arbeitszimmer_Board_V4_D3"
- platform: neopixelbus
type: RBG
variant: WS2811
pin: GPIO4
num_leds: 30
name: "Arbeitszimmer_Board_V4_D2"
- platform: neopixelbus
type: RBG
variant: WS2811
pin: GPIO2
num_leds: 30
name: "Arbeitszimmer_Board_V4_D1"
Loading of the code via USB is possible and the device shows up in my unify dasboard (connected to wifi). Im also able to ping the device via cmd and read the latency in the unify dashboard.
But when trying to update the firmware or revice the logs via WiFi I always get the following Error:
ERROR Connecting to 192.168.1.86:3232 failed: [Errno 113] No route to host
Furhermore the HA auto dicovers the device, but is unable to connect to it, resulting in the following error:
Canât connect to ESP. Please make sure your YAML file contains an âapi:â line.
I already tried to connect to it with and without any devices connected to the gpio pin, thinking that maybe im using a wrong pin, but the result keeps being the same.
theres really no reason to be using static IPâs unless you are having problems to begin with.
As you guys already said, router address is very wrong, agreedâŚ
But, as far as static IP goes, iâd say that itâs pretty much âextremly good ideaâ, if not âa mustâ. mdns can be unreliable (at least from my experience), as a result it FW update will fail occasionally, moduels will go offline for a whileâŚ
If/when you will have many of these modules itâs nice to have them sorted, otherwise youâll get âlost in spaceâ pretty soon. Actually, each and every device in my HA network has either static IP od reservation in router (if static is not possible in device itself). Not to mention that HA /esp devices are all in itâs own segment.
DHCP is, apart from âcasualâ devices nothing but trouble in installations like this. Another example would be IP cameras with NVR recorder: you set all up, all is running - but only until first power outage. After power restore cameras get a different IPâs and nothing works anymore (tested more than once). Similar can happen with esp modulesâŚ
Yes, the GateWay address is wrong, but since it is only addressed when the device is trying to reach IPâs outside your subnet (f.e. the internet), it should not prevent it from connecting to the local network.
When an ESPHome device doesnât connect to a wifi network within a certain time, it will activate itâs fallback hotspot.
The gateway was already fixed when i posted this topic, but i must have copied the old code here.
In the end I didnt get it to work with my esp32, so i went back to the esp8266 (D1 mini) and had the same problem.
What i did in the end to make it work was to get rid of the static IP code in the ESP firmware
manual_ip:
# Set this to the IP of the ESP
static_ip: 192.168.1.86
# Set this to the IP address of the router. Often ends with .1
gateway: 255.255.255.1
# The subnet of the network. 255.255.255.0 works for most home networks.
subnet: 255.255.255.0
and instead assigned a static IP directly in unify.
I dont know what exactly changed since i am using other esp8266 on other parts of my smarthome and i never had any trouble with the static IP code.
Good to know. I provide static IPs to most of my smarthome devices anyways since I find it convinient and easy to keep an overview of everything that in my wifi.
I tend to assign fixed IPâs to my stuff, but it is normally done in the dhcp server not on the esp. I always let the dhcp assign the ip then fix it, this saves any conflicts which may arise.
That being said I have set static IPâs on a few of my espâs but only the same as the dhcp. It has helped with connection issues.
Although I suck at networking so couldnât explain if/why this is good practice. DHCP server level was mainly to manage centrally and make it easy to ping devices and see what is on my network. And then on my esp too for reasons lost which may or may not make sense. Maybe for faster connection or because the docs recommend it.
Something I picked up along the way when I was debugging things and reading the forum I think.
I used to reserve IPâs in DHCP server, too. Until router died on me and i lost all my fixed IPâs. From there on i rather set static IP on devices. It can also happen (although rare) that router crashes and looses itâs settings, or something âdoesnât work rightâ, so best solution is factory reset or the router⌠so, not very safe solution, and if anything goes wrong thereâs a lot of work (again).
If you keep notes and if youâre organized thereâs no worry of IP conflict. Just set dhcp server range from, say 10 to 150 (or 200) and have static IPâs from 201 to 254 . I used to have that, until my devices count went up, so i ended up with /22 subnet, so now static IPâs are at 0.x, dhcp server runs at 1.x, HA devices are at 3.x (2.x is some sort of reserve, so to speakâŚ)
Note that some routers may have problems if you set static IP in itâs dhcp range, so donât forget to shrink this range.
Itâs not that i didnât have data, itâs that Iâve had to input aaaaalll that data manually once again⌠and if you have 50+ devices itâs not a small amount of work.
And, sure, old model is still available, but since iâve had a chance i decided to upgrade to a better (more powerful) model.
The changing routers stuff is why I run DHCP on pihole rather than on a router. Easy backup and restore. I run it on a seperate container under Proxmox.
Aaa⌠you have pihole⌠i have AdGuard directly on my Asus (RT-AX88U pro, merlin FW). But now i have addon installed on my Asus which is basically an enhanced DHCP, so i can export/import backup only dhcp part and itâs independent of router model. But i still prefer static IP on devices.
I would run openwrt if I happened to have router it would run on. I believe you can run it as itâs own server but could not really see an advantage to that.