esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
288 stars 34 forks source link

Template switch causes non-booting devices #5817

Open ksya opened 2 weeks ago

ksya commented 2 weeks ago

The problem

One of my devices does not boot (or is in bootloop) after uploading the following code: Unfortunately I also could not get serial log working.

The problem is on the addition of line 121 and the interlock for this switch. The goal was to use this as a "block" to not lower the screen when the window is open. This switch was supposed to be enabled using home assistant.

Which version of ESPHome has the issue?

2024.5.0

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP8266

Board

Sonoff Dual-R3

Component causing the issue

No response

Example YAML snippet

substitutions:
  devicename: screen-keuken
  long_devicename: Screen Keukenraam

esphome:
  name: $devicename
  platform: ESP32
  board: esp32dev

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Screen-Keuken Fallback Hotspot"
    password: "OHxPoT0UpDIp"

# Enable Home Assistant API
api:
  encryption:
    key: ""

ota:
  safe_mode: True
  password: "629eae8216e1e88bbc11476be3abb1a3"

web_server:
  port: 80

logger:
  baud_rate: 0

captive_portal:

# remove # below to enable ble tracking
#esp32_ble_tracker:
uart:
  tx_pin: GPIO25
  rx_pin: GPIO26
  baud_rate: 4800
  parity: NONE
  stop_bits: 2

sensor:
  - platform: wifi_signal
    name: "$long_devicename WiFi Signal"
    update_interval: 60s
  - platform: bl0939
    update_interval: 1s
#    voltage:
#      name: "$long_devicename Voltage"
    current_1:
      name: "$long_devicename Current Open"
      id: open_current_sensor
      internal: True
    current_2:
      name: "$long_devicename Current Close"
      id: close_current_sensor
      internal: True
    active_power_1:
      name: "$long_devicename Power Open"
    active_power_2:
      name: "$long_devicename Power Close"
#    energy_1:
#      name: '$long_devicename Energy Open'
#    energy_2:
#      name: '$long_devicename Energy Close'
    energy_total:
      name: '$long_devicename Energy Total'

cover:
  - platform: current_based
    device_class: shutter
    id: shutter
    name: "Screen Keuken"

    open_sensor: open_current_sensor
    open_moving_current_threshold: 0.35
    open_obstacle_current_threshold: 0.8
    open_duration: 32s
    open_action:
      - switch.turn_on: open_cover_switch

    close_sensor: close_current_sensor
    close_moving_current_threshold: 0.35
    close_obstacle_current_threshold: 0.8
    close_duration: 31s
    close_action:
      - switch.turn_on: close_cover_switch

    stop_action:
      - switch.turn_off: close_cover_switch
      - switch.turn_off: open_cover_switch

    obstacle_rollback: 30%
    start_sensing_delay: 2s

    malfunction_detection: true
    malfunction_action:
      then:
        - logger.log: "Malfunction detected. Relay welded."

switch:
  - platform: gpio
    pin: GPIO27
    name: "$long_devicename - Open"
    id: open_cover_switch
    restore_mode: RESTORE_DEFAULT_OFF
    interlock: [close_cover_switch] #ensure only one relay active at a time
    interlock_wait_time: 200ms
    internal: True
  - platform: gpio
    pin: GPIO14
    name: "$long_devicename - Close"
    id: close_cover_switch
    restore_mode: RESTORE_DEFAULT_OFF
    interlock: [open_cover_switch, window_unsafe] #ensure only one relay active at a time
    interlock_wait_time: 200ms
    internal: True
  - platform: template
    id: window_unsafe
    name: "Unsafe to close"
    turn_on_action:
      - switch.turn_on: window_unsafe
    turn_off_action:
      - switch.turn_on: window_unsafe

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO32
      mode: INPUT_PULLUP
      inverted: True
    name: $long_devicename Open Button
    on_press:
      then:
        cover.open: shutter

  - platform: gpio
    pin:
      number: GPIO33
      mode: INPUT_PULLUP
      inverted: True
    name: $long_devicename Close Button
    on_press:
      then:
        cover.close: shutter

Anything in the logs that might be useful for us?

No response

Additional information

No response

ksya commented 2 weeks ago

I'm pretty sure this is because it is going in an endless loop due to this:

    turn_on_action:
      - switch.turn_on: window_unsafe
    turn_off_action:
      - switch.turn_on: window_unsafe

I have changed this and now it's functioning. You can close this... Although, maybe it can somehow be prevented to lock up the ESP