esphome / issues

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

Substitution seems not working with esp32_rmt_led_strip / rmt_channel #5236

Open Axeman72 opened 8 months ago

Axeman72 commented 8 months ago

The problem

When using a variable substitution in the "rmt_channel" property of a light using platform esp32_rmt_led_strip) the compilation fails because the substitution is handled as a string and not as a number. The same substitution works in the "channel" property of a light using neopixelbus platform and method esp32_rmt (See attached YAML)

This happens even using !include, where I can pass a integer variable

LedStrip1: !include {file: ./twinkler/ledstrip.yaml, vars: { Channel: '2', RmtChannel: 2, Pin: 'GPIO17' }}

but it's always handled as a string in the substitution, and I get the same error in the build log.

I haven't found a way to cast the value, and since there is no way to use a workaround with "ifs" in ESPHome YAMLs (like in Azure DevOps), the esp32_rmt_led_strip can't be used in a !include in the same way the neopixelbus can.

Which version of ESPHome has the issue?

2023.11.6

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?

ESP32

Board

esp32 generic dev board

Component causing the issue

light/esp32_rmt_led_strip

Example YAML snippet

substitutions:
  rmtChannel: '2'

light: 
  - platform: neopixelbus
    type: GRB
    variant: WS2812
    pin: GPIO16
    method:
      type: esp32_rmt
      channel: ${rmtChannel}   ## THIS WORKS (even in !include)
    num_leds: 25
    name: "Strip2 (25 LED)"
    id: strip2
    internal: false

  - platform: esp32_rmt_led_strip
    rgb_order: GRB
    chipset: WS2812
    pin: GPIO32
    rmt_channel: ${rmtChannel} ##  THIS FAILS WITH ERROR "RMT channel 2 is not supported for ESP32 variant ESP32."
    num_leds: 25
    name: "Strip3 (25 LED 6cm)"
    id: strip3
    internal: false

Anything in the logs that might be useful for us?

No response

Additional information

No response

Axeman72 commented 8 months ago

Looking at the esp32_rmt_led_strip code, I think that a "int(value)" instead of "value" in this line should fix the issue. Or, at least, it fixed the issue in my two esphome instances.

[https://github.com/esphome/esphome/blob/23ceddafed185ab38a8326782994b9c7e1f07f3c/esphome/components/esp32_rmt_led_strip/light.py#L75]

DISCLAIMER: I've never used Python before.

github-actions[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.