Déconnexion en utilisant esphome

Bonjour,

je souhaite intégrer un sonoff 4CH pro sous ESPHome.
HA reconnais bien le sonoff, je clique sur adopt puis Install. Les lignes de codes commencent puis ca se bloque et j’ai une perte d connexion avec HA j’imagine donc qu’il reboot.
Je n ois pas d’ou vient le problème.
Merci

Renseigner votre problème

Ma configuration

System Information

version core-2024.7.3
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.4
os_name Linux
os_version 6.6.33-haos
arch aarch64
timezone Europe/Paris
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 5000
Installed Version 1.34.0
Stage running
Available Repositories 1391
Downloaded Repositories 2
HACS Data ok
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 12.4
update_channel stable
supervisor_version supervisor-2024.06.2
agent_version 1.6.0
docker_version 26.1.4
disk_total 27.9 GB
disk_used 6.7 GB
healthy true
supported true
host_connectivity null
supervisor_connectivity true
ntp_synchronized true
virtualization
board khadas-vim3
supervisor_api ok
version_api ok
installed_addons Z-Wave JS UI (3.9.2), Z-Wave JS (0.6.2), Terminal & SSH (9.14.0), File editor (5.8.0), Mosquitto broker (6.4.1), ESPHome (2024.7.2)
Dashboards
dashboards 2
resources 0
views 0
mode storage
Recorder
oldest_recorder_run 22 juillet 2024 à 10:29
current_recorder_run 25 juillet 2024 à 19:37
estimated_db_size 34.67 MiB
database_engine sqlite
database_version 3.45.3

Hello,

Sauf erreur, il faut le flasher avant de l’intégrer, car ESP ne sait pas piloter directement un sonoff sans que tu ai changé le firmware auparavant.
perso, c’est comme ça que j’ai fait avec mon 4CH de sonoff.

Salut

au cas ou voila mon code pour un modèle non pro

esphome:
  name: sonoff4chr2
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "wifi_ssid"
  password: "wifi_pwd"


  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Sonoff 4Ch R2 Fallback Hotspot"
    password: "hotspot_pwd"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  - platform: esphome

time:
  - platform: sntp
    id: sntp_time
    timezone: Europe/Paris

external_components:
  - source: github://dentra/esphome-components
backup:

web_server:
  port: 80

binary_sensor:
  - platform: status
    name: "Sonoff 4ch R2 Status"


  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    name: "Sonoff 4CH Button 1"
    on_press:
      then:
        - switch.toggle: relay1
        
        
  - platform: gpio
    pin:
      number: GPIO9
      mode: INPUT_PULLUP
      inverted: True
    name: "Sonoff 4CH Button 2"
    on_press:
      then:
        - switch.toggle: relay2

  - platform: gpio
    pin:
      number: GPIO10
      mode: INPUT_PULLUP
      inverted: True
    name: "Sonoff 4CH Button 3"
    on_press:
      then:
        - switch.toggle: relay3
        

  - platform: gpio
    pin:
      number: GPIO14
      mode: INPUT_PULLUP
      inverted: True
    name: "Sonoff 4CH Button 4"
    on_press:
      then:
        - switch.toggle: relay4

switch:
  - platform: restart
    name: "sonoff-4ch-r2 restart"


  - platform: gpio
    id: relay1
    name: "Sonoff 4CH Relay 1"
    pin: GPIO12
  - platform: gpio
    id: relay2
    name: "Sonoff 4CH Relay 2"
    pin: GPIO5
  - platform: gpio
    id: relay3
    name: "Sonoff 4CH Relay 3"
    pin: GPIO4
  - platform: gpio
    id: relay4
    name: "Sonoff 4CH Relay 4"
    pin: GPIO15



light:
  
  - platform: status_led
    id: wifi_status_led

    pin:
      number: GPIO13
      inverted: True

interval:
  - interval: 30s
    then:
      if:
        condition:
          wifi.connected:
        then:
          - light.turn_on: wifi_status_led
        else:
          - light.turn_off: wifi_status_led


sensor:
  - platform: uptime
    id: uptime_seconds
    name: "Uptime Sensor"
    update_interval: 60s
    unit_of_measurement: s
    accuracy_decimals: 0
    force_update: false
    icon: mdi:timer
    internal: True  # Hide to HA
  - platform: wifi_signal
    name: "sonoff 4ch r2 WiFi Signal Sensor"
    update_interval: 60s


    
text_sensor:
  - platform: template
    name: sonoff-4ch-r2 - Uptime
    update_interval: 60s
    icon: mdi:clock-start
    lambda: |-
      int seconds = (id(uptime_seconds).state);
      int days = seconds / (24 * 3600);
      seconds = seconds % (24 * 3600);
      int hours = seconds / 3600;
      seconds = seconds % 3600;
      int minutes = seconds /  60;
      seconds = seconds % 60;
      if ( days ) {
        return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
      } else if ( hours ) {
        return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
      } else if ( minutes ) {
        return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
      } else {
        return { (String(seconds) +"s").c_str() };
      }

sinon
https://reid-projects.com/how-to-install-esphome-on-sonoff-4ch-pro-r2/

faudra juste adapter le code suite a une des dernière mise a jour concernant le OTA

ota:
  - platform: esphome

J’ai bien flashé le sonoff avec web.esphome.io
HA le reconnait bien dans ESPHome mais qd je fais install j’ai ce code :

INFO ESPHome 2024.7.2
INFO Reading configuration /config/esphome/esphome-web-a81d4b.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esphome-web-a81d4b (board: esp01_1m; framework: arduino; platform: platformio/espressif8266@4.2.1)
--------------------------------------------------------------------------------
Library Manager: Installing esphome/ESPAsyncTCP-esphome @ 2.0.0
INFO Installing esphome/ESPAsyncTCP-esphome @ 2.0.0
Unpacking  [####################################]  100%
Library Manager: ESPAsyncTCP-esphome@2.0.0 has been installed!
INFO ESPAsyncTCP-esphome@2.0.0 has been installed!
Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 3.2.2
INFO Installing esphome/ESPAsyncWebServer-esphome @ 3.2.2
Unpacking  [####################################]  100%
Library Manager: ESPAsyncWebServer-esphome@3.2.2 has been installed!
INFO ESPAsyncWebServer-esphome@3.2.2 has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
Library Manager: Installing bblanchon/ArduinoJson @ 6.18.5
INFO Installing bblanchon/ArduinoJson @ 6.18.5
Unpacking  [####################################]  100%
Library Manager: ArduinoJson@6.18.5 has been installed!
INFO ArduinoJson@6.18.5 has been installed!
Library Manager: Installing esphome/Improv @ 1.2.3
INFO Installing esphome/Improv @ 1.2.3
Unpacking  [####################################]  100%
Library Manager: Improv@1.2.3 has been installed!
INFO Improv@1.2.3 has been installed!
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
Dependency Graph
|-- ESPAsyncTCP-esphome @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.2.2
|-- DNSServer @ 1.1.1
|-- ESP8266WiFi @ 1.0
|-- ESP8266mDNS @ 1.2
|-- ArduinoJson @ 6.18.5
|-- Improv @ 1.2.3
Compiling .pioenvs/esphome-web-a81d4b/src/esphome/components/api/api_connection.cpp.o
Compiling .pioenvs/esphome-web-a81d4b/src/esphome/components/api/api_frame_helper.cpp.o
Compiling .pioenvs/esphome-web-a81d4b/src/esphome/components/api/api_pb2.cpp.o
Compiling .pioenvs/esphome-web-a81d4b/src/esphome/components/api/api_pb2_service.cpp.o
Compiling .pioenvs/esphome-web-a81d4b/src/esphome/components/api/api_server.cpp.o
Compiling .pioenvs/esphome-web-a81d4b/src/esphome/components/api/list_entities.cpp.o

puis j’ai le message Connexion perdue. Déconnexion en cours toujours au meme moment.

tu as bien défini une adresse ip dans ta conf ?

C’est à dire ? Je ne sais pas.

poste ton ficher de conf ici
on va vérifier

hello tu ne serais pas sur un raspberry PI 3 par hasard ?
dans ce cas la tu dois rajouter une ligne dans ton fichier yaml
en effet le PI 3 n’est pas assez puissant pour assurer la compilation
voir ce sujet

J’ai un kadhas vim3.
Je vais regarder le sujet. Merci

Merci pour cette solution @jrvrcd ca a fonctionné.