diff --git a/esphome/components/neopixelbus/_methods.py b/esphome/components/neopixelbus/_methods.py index 77baa89011..74bf89f17f 100644 --- a/esphome/components/neopixelbus/_methods.py +++ b/esphome/components/neopixelbus/_methods.py @@ -126,6 +126,7 @@ NeoEsp32RmtMethodBase = neo_ns.class_("NeoEsp32RmtMethodBase") NeoEsp32RmtSpeedBase = neo_ns.class_("NeoEsp32RmtSpeedBase") NeoEsp32RmtSpeed = neo_ns.class_("NeoEsp32RmtSpeed") + def _bit_bang_to_code(config, chip: str, inverted: bool): # https://github.com/Makuna/NeoPixelBus/blob/master/src/internal/NeoEspBitBangMethod.h # Some chips are only aliases @@ -279,7 +280,7 @@ def _esp32_rmt_to_code(config, chip: str, inverted: bool): # Resolve chip aliasing and use default speed settings if necessary chip = { CHIP_WS2813: CHIP_WS2812X, # Alias WS2813 to WS2812X - CHIP_LC8812: CHIP_SK6812, # Alias LC8812 to SK6812 + CHIP_LC8812: CHIP_SK6812, # Alias LC8812 to SK6812 CHIP_WS2812: CHIP_800KBPS, # Use generic 800Kbps for WS2812 }.get(chip, chip) @@ -306,7 +307,9 @@ def _esp32_rmt_to_code(config, chip: str, inverted: bool): } if (chip, inverted) not in lookup: - raise cv.Invalid(f"Unsupported chip {chip} with inverted={inverted} for RMT method.") + raise cv.Invalid( + f"Unsupported chip {chip} with inverted={inverted} for RMT method." + ) speed = lookup[(chip, inverted)] return neo_ns.NeoEsp32RmtMethodBase.template(speed, channel) @@ -327,7 +330,7 @@ def _esp32_i2s_to_code(config, chip: str, inverted: bool): chip = { CHIP_WS2811: CHIP_WS2812X, # Alias WS2811 to WS2812X CHIP_WS2813: CHIP_WS2812X, # Alias WS2813 to WS2812X - CHIP_LC8812: CHIP_SK6812, # Alias LC8812 to SK6812 + CHIP_LC8812: CHIP_SK6812, # Alias LC8812 to SK6812 CHIP_WS2812: CHIP_800KBPS, # Use generic 800Kbps for WS2812 }.get(chip, chip) @@ -357,7 +360,9 @@ def _esp32_i2s_to_code(config, chip: str, inverted: bool): False: neo_ns.NeoEsp32I2sNotInverted, True: neo_ns.NeoEsp32I2sInverted, }[inverted != inv_inverted] - return neo_ns.NeoEsp32I2sMethodBase.template(speed, bus, inv, neo_ns.NeoEsp32I2sCadence) + return neo_ns.NeoEsp32I2sMethodBase.template( + speed, bus, inv, neo_ns.NeoEsp32I2sCadence + ) def _spi_to_code(config, chip: str, inverted: bool): diff --git a/tests/components/neopixelbus/common_i2s.yaml b/tests/components/neopixelbus/common_i2s.yaml new file mode 100644 index 0000000000..fd468586e0 --- /dev/null +++ b/tests/components/neopixelbus/common_i2s.yaml @@ -0,0 +1,17 @@ +light: + - platform: neopixelbus + id: addr3 + name: Neopixelbus Light + gamma_correct: 2.8 + color_correct: [0.0, 0.0, 0.0, 0.0] + default_transition_length: 10s + effects: + - addressable_flicker: + name: Flicker Effect With Custom Values + update_interval: 16ms + intensity: 5% + type: GRBW + variant: SK6812 + method: ESP32_I2S_0 + num_leds: 5 + pin: 4 diff --git a/tests/components/neopixelbus/test.esp32-ard.yaml b/tests/components/neopixelbus/test.esp32-ard.yaml index fd468586e0..2d42b51933 100644 --- a/tests/components/neopixelbus/test.esp32-ard.yaml +++ b/tests/components/neopixelbus/test.esp32-ard.yaml @@ -1,17 +1 @@ -light: - - platform: neopixelbus - id: addr3 - name: Neopixelbus Light - gamma_correct: 2.8 - color_correct: [0.0, 0.0, 0.0, 0.0] - default_transition_length: 10s - effects: - - addressable_flicker: - name: Flicker Effect With Custom Values - update_interval: 16ms - intensity: 5% - type: GRBW - variant: SK6812 - method: ESP32_I2S_0 - num_leds: 5 - pin: 4 +<<: !include common_i2s.yaml diff --git a/tests/components/neopixelbus/test.esp32-c3-ard.yaml b/tests/components/neopixelbus/test.esp32-c3-ard.yaml index f2b53ab1e9..2d42b51933 100644 --- a/tests/components/neopixelbus/test.esp32-c3-ard.yaml +++ b/tests/components/neopixelbus/test.esp32-c3-ard.yaml @@ -1,19 +1 @@ -light: - - platform: neopixelbus - id: addr3 - name: Neopixelbus Light - gamma_correct: 2.8 - color_correct: [0.0, 0.0, 0.0, 0.0] - default_transition_length: 10s - effects: - - addressable_flicker: - name: Flicker Effect With Custom Values - update_interval: 16ms - intensity: 5% - type: GRBW - variant: SK6812 - method: - type: esp32_rmt - channel: 0 - num_leds: 5 - pin: 4 +<<: !include common_i2s.yaml diff --git a/tests/components/neopixelbus/test.esp32-s2-ard.yaml b/tests/components/neopixelbus/test.esp32-s2-ard.yaml index f2b53ab1e9..2d42b51933 100644 --- a/tests/components/neopixelbus/test.esp32-s2-ard.yaml +++ b/tests/components/neopixelbus/test.esp32-s2-ard.yaml @@ -1,19 +1 @@ -light: - - platform: neopixelbus - id: addr3 - name: Neopixelbus Light - gamma_correct: 2.8 - color_correct: [0.0, 0.0, 0.0, 0.0] - default_transition_length: 10s - effects: - - addressable_flicker: - name: Flicker Effect With Custom Values - update_interval: 16ms - intensity: 5% - type: GRBW - variant: SK6812 - method: - type: esp32_rmt - channel: 0 - num_leds: 5 - pin: 4 +<<: !include common_i2s.yaml diff --git a/tests/components/neopixelbus/test.esp32-s3-ard.yaml b/tests/components/neopixelbus/test.esp32-s3-ard.yaml index f2b53ab1e9..2d42b51933 100644 --- a/tests/components/neopixelbus/test.esp32-s3-ard.yaml +++ b/tests/components/neopixelbus/test.esp32-s3-ard.yaml @@ -1,19 +1 @@ -light: - - platform: neopixelbus - id: addr3 - name: Neopixelbus Light - gamma_correct: 2.8 - color_correct: [0.0, 0.0, 0.0, 0.0] - default_transition_length: 10s - effects: - - addressable_flicker: - name: Flicker Effect With Custom Values - update_interval: 16ms - intensity: 5% - type: GRBW - variant: SK6812 - method: - type: esp32_rmt - channel: 0 - num_leds: 5 - pin: 4 +<<: !include common_i2s.yaml