Hi Nick thanks for your reply…I have followed the above, I have substituted switch.turn_on with my sonoff switch but initially followed the example
wifi:
# ...
on_connect:
- switch.turn_on: Test (My friendly name for my switch.sonoff_10023c9d7f_1)
on_disconnect:
- switch.turn_off: Test (My friendly name for my switch.sonoff_10023c9d7f_1)
The error seems clear to me. It says it can’t find something (that is supposed to be defined in the YAML file). That something doesn’t exist in the YAML snippet you provided. It might exist in the full file, but the syntax/spacing could be just slightly incorrect and that could cause the error you are getting (but not seeing).
I think you are right the esp32 is looking for a device connected to it, there is no reference to it. I assumed I could use entities from home assistant without the need to define inputs. Am I right?
Thanks Tom for your help.
This time I flashed the esp32 successfully and the log said it is connected to my network.
To test, I physically disconnected the esp32 and then reconnected, should my device switch on as per config below? if so it doesn’t. I did allow the device to perform home assistant actions in the config for my device. Is there anything else I can look into?
Tom I cant see anything obvious in the HAS logs but the bootup logs for my ESP32 doesnt show any reference starting the home assistant service. Here is my log, the warning you see at the end is when I disconnected from my USB. Is there any configurations that need editing in the config.yaml or additional integrations that I may need. I cant find anything on how to use the correct syntax but is there an action service instead of service?
- homeassistant.service:
service: switch.turn_on (Is there such a thing as action instead of service)
data:
entity_id: switch.sonoff_10023c9d7f_1
I’d love to figure this out.
Thanks in advance.
INFO ESPHome 2024.12.4
INFO Reading configuration /config/esphome/wifi.yaml...
INFO Starting log output from 192.168.1.151 using esphome API
INFO Successfully connected to wifi @ 192.168.1.151 in 0.083s
INFO Successful handshake with wifi @ 192.168.1.151 in 0.065s
[11:54:58][I][app:100]: ESPHome version 2024.12.4 compiled on Mar 12 2025, 11:53:05
[11:54:58][C][wifi:600]: WiFi:
[11:54:58][C][wifi:428]: Local MAC: CC:BA:97:15:4E:78
[11:54:58][C][wifi:433]: SSID: [redacted]
[11:54:58][C][wifi:436]: IP Address: 192.168.1.151
[11:54:58][C][wifi:440]: BSSID: 28:EE:52:C0:D2:CE[redacted]
[11:54:58][C][wifi:441]: Hostname: 'wifi'
[11:54:58][C][wifi:443]: Signal strength: -61 dB ▂▄▆█
[11:54:58][C][wifi:447]: Channel: 4
[11:54:58][C][wifi:448]: Subnet: 255.255.255.0
[11:54:58][C][wifi:449]: Gateway: 192.168.1.1
[11:54:58][C][wifi:450]: DNS1: 192.168.1.1
[11:54:58][C][wifi:451]: DNS2: 0.0.0.0
[11:54:58][C][logger:185]: Logger:
[11:54:58][C][logger:186]: Level: DEBUG
[11:54:58][C][logger:188]: Log Baud Rate: 115200
[11:54:58][C][logger:189]: Hardware UART: USB_CDC
[11:54:58][C][captive_portal:089]: Captive Portal:
[11:54:58][C][mdns:116]: mDNS:
[11:54:58][C][mdns:117]: Hostname: wifi
[11:54:58][C][esphome.ota:073]: Over-The-Air updates:
[11:54:58][C][esphome.ota:074]: Address: wifi.local:3232
[11:54:58][C][esphome.ota:075]: Version: 2
[11:54:58][C][esphome.ota:078]: Password configured
[11:54:58][C][safe_mode:018]: Safe Mode:
[11:54:58][C][safe_mode:020]: Boot considered successful after 60 seconds
[11:54:58][C][safe_mode:021]: Invoke after 10 boot attempts
[11:54:58][C][safe_mode:023]: Remain in safe mode for 300 seconds
[11:54:58][C][api:140]: API Server:
[11:54:58][C][api:141]: Address: wifi.local:6053
[11:54:58][C][api:143]: Using noise encryption: YES
WARNING wifi @ 192.168.1.151: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for wifi @ 192.168.1.151
WARNING Disconnected from API
INFO Successfully connected to wifi @ 192.168.1.151 in 0.008s
INFO Successful handshake with wifi @ 192.168.1.151 in 0.093s
I would expect after your power was re-applied to the device it would run through the entire initialisation log again, including successfully connecting to the API.
I think it is working yeah? theres reference to api integration (https://developers.home-assistant.io/docs/api/rest/) I'm assuming adding this to config.yaml ap: is all thats required.
[safe_mode:020]
Boot considered successful after 60 seconds
12:23:55 [C] [safe_mode:021]
Invoke after 10 boot attempts
12:23:55 [C] [safe_mode:023]
Remain in safe mode for 300 seconds
12:23:55 [C] [api:140]
API Server:
12:23:55 [C] [api:141]
Address: wifi.local:6053
12:23:55 [C] [api:143]
Using noise encryption: YES
[D][api.connection:1446]: Home Assistant 2025.3.2 (192.168.1.105): Connected successfully