Skip to content

HA discovery: don't advertise a TuyaMCU LED's raw channels as entities (#2218) - #2235

Open
codypendant wants to merge 2 commits into
openshwprojects:mainfrom
codypendant:fix-2218-tuyamcu-led-discovery-v2
Open

codypendant wants to merge 2 commits into
openshwprojects:mainfrom
codypendant:fix-2218-tuyamcu-led-discovery-v2

Conversation

@codypendant

Copy link
Copy Markdown
Contributor

Fixes #2218.

On a device configured with tuyaMcu_setupLED, discovery advertises the raw
on/off and dimmer channels as entities. The LED is driven from led_dimmer /
led_basecolor_rgb, so those channels stay at 0 and the entities are inert.

HA ends up with a working light plus a dead one, and a dead switch — the toggle
channel falls through to the relay loop.

The LED light itself is published correctly by the existing pwmCount == 5
branch; ledDriverChipRunning is 1 on these devices, so pwmCount is
reassigned from CFG_CountLEDRemapChannels(). Only the duplicates are wrong.

TuyaMCU_HasLED() marks the toggle and dimmer channels as published without
emitting them, which suppresses both the duplicate light and the switch.

Before:

light/OpenBK7231T_<id>_light/config       led_* topics, works
light/OpenBK7231T_<id>_light_1/config     ~/1/get + ~/2/get, stuck at 0
switch/OpenBK7231T_<id>_..._1/config      same channel as a switch

After:

light/OpenBK7231T_<id>_light/config
select/OpenBK7231T_<id>_select_3/config
sensor/... build, ip, rssi, ssid, temp, uptime

Verified on two Costco Feit FETAPE/RGBW/CONT strip controllers (BK7231T) with
tuyaMcu_setupLED 24 1. No other TuyaMCU LED hardware here.

codypendant and others added 2 commits September 18, 2026 07:46
…openshwprojects#2218)

On a device configured with tuyaMcu_setupLED, the toggle+dimmer path
publishes a light bound to the raw on/off and dimmer channels. Those
channels are not what drives the LED -- real state lives in led_dimmer
and led_basecolor_rgb -- so they sit at 0 permanently and the entity is
inert.

The LED itself is already advertised correctly by the ENABLE_LED_BASIC
block, so HA ends up with two lights for one device: one that works and
one that never will. Skip the raw pair when an LED is configured.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ay loop (openshwprojects#2218)

Breaking out of the light path left the toggle and dimmer channels
unclaimed, so the relay loop below picked the toggle up and published it
as a switch -- the same dead channel in a different form.

Mark both channels as published instead, which suppresses the light and
the switch in one go.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TuyaMCU LED driver (tuyaMcu_setupLED): HA discovery publishes a light bound to raw channels 1/2 instead of the LED driver

1 participant