Sonoff r2 pw relay on au reboot esphome

Bonjour,
je n’arrive pas a configurer l’activation du relay au démarrage d’esphome
j’ai parcouru les forum mais rien ne fonctionne au démarrage d’esphome le relay reste a OFF
embêtant car il y a un congélateur sur le sonoff R2 voici mon code

esphome:
  name: buandrie
  platform: ESP8266
  board: esp01_1m
  board_flash_mode: dout
wifi:
  ssid: 'hyrule'
  password: '4e3f7443'
logger:
  baud_rate: 0
# Example configuration entry
substitutions:
  update_interval: 15s  
uart:
  rx_pin: RX
  baud_rate: 4800
api:
ota:
# Serveur Web
web_server:
  port: 80     
binary_sensor:
  - platform: gpio
    id: button
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    on_press:
      - switch.toggle: fakebutton
switch:
  - platform: template
    name: "Sonoff POW on/off"
    optimistic: true
    id: fakebutton
    turn_on_action:
    - switch.turn_on: relay
    - light.turn_on: led
    turn_off_action:
    - switch.turn_off: relay
    - light.turn_off: led
  - platform: gpio
    id: relay
    pin: GPIO12
output:
  - platform: esp8266_pwm
    id: pow_blue_led
    pin:
      number: GPIO13
      inverted: True
light:
  - platform: monochromatic
    output: pow_blue_led
    id: led
sensor:
  - platform: wifi_signal
    name: "Sonoff buandrie WiFi Signál"
    update_interval: 60s
  - platform: uptime
    name: "Sonoff POW Doba běhu"
  - platform: cse7766
    current:
      name: "Sonoff Pow R2 Current"
      filters:
        - throttle_average: ${update_interval}
    voltage:
      name: "Sonoff Pow R2 Voltage"
      filters:
        - throttle_average: ${update_interval}
    power:
      name: "Sonoff Pow R2 Power"
      filters:
        - throttle_average: ${update_interval}
    energy:
      name: "Sonoff Pow R2 Energy"
      filters:
        - throttle: ${update_interval}
    apparent_power:
      name: "Sonoff Pow R2 Apparent Power"
      filters:
        - throttle_average: ${update_interval}
    power_factor:
      name: "Sonoff Pow R2 Power Factor"
      filters:
        - throttle_average: ${update_interval}    
text_sensor:
  - platform: version
    name: "Sonoff POW Verze"

j’ai essayé:

restore_mode: RESTORE_DEFAULT_ON

et

restore_mode: ALWAYS_ON
  on_boot:
    priority: 700
    then:

merci pour votre aide
lucien

bonjour, et en faisant un automatisme qui se déclanche quant il est a off et si off → on
voir mettre un drapeau si tension passe de 0 à >1

le on_boot ne marchera jamais lors d’un reboot et comme le on_reboot n’existe pas, il faudra faire sans.

par contre, je ne comprend pas bien le but du boitier ???

Bonjour,
ca fonctionne pour moi , le restore_mode: RESTORE_DEFAULT_ON.

light:
  - platform: monochromatic
    output: gpio38
    name: Backlight
    id: light_s3
    restore_mode: RESTORE_DEFAULT_ON

tu peu essayer avec c’est syntaxe:

  - platform: gpio
    pin:
      number: GPIO12
      restore_mode: RESTORE_DEFAULT_ON

comme c’est un esp8266, faut ajouter la ligne restore_from_flash: 'True' dans la partie esphome:

restore_mode (Optional ): Control how the switch attempts to restore state on bootup. NOTE : Not all components consider restore_mode . Check the documentation of the specific component to understand how this feature works for a particular component or device. For restoring on ESP8266s, also see restore_from_flash in the esp8266 section.


au boot, si ton relay est bien celui la:

  - platform: gpio
    id: relay
    pin: GPIO12
esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}
  ...
  on_boot:
    - priority: 800
      then:
        - switch.turn_on: relay

le priority a 800
image

Mreci pour vos réponses, mais cela ne fonctionne pas
je vais continuer a chercher, je voudrais éviter de passer par une automation