Tuya Dimmer Brightness while off


I used to have my Tuya devices configured within configuration.yaml but recently updated it to the latest version of LocalTuya, which offers config through the UI. In the old version, I somehow managed to set up a dimmer switch in such a way that I could set its brightness while the light stayed off. It was glorious, and based on my Google searches, a bit of a unicorn, but since I updated, I can’t figure out how to make it work with the latest version of the integration. If I change the brightness of the light now, the light turns on when I do.

I have backups of my configuration and my automations and the main (maybe only?) difference that I see is that I’d configured the device with two entities, one using the “switch” platform, which controlled on/off via DP #1, and another using the “light” platform, which supported the brightness, and it allowed me to change the brightness exactly how I wanted while the light was off.

Strangely, when I look at that old configuration, it almost seems like it’s configured incorrectly, yet it worked.

Old config:

  - host: 192.168.xxx.xxx
    device_id: 71033xxxxxxxxxxxxxxx
    local_key: 03c0fxxxxxxxxxxx
    friendly_name: Bathroom Light
    protocol_version: "3.3"
      - platform: binary_sensor
        friendly_name: Bathroom Light
        id: 1
        state_on: "true"
        state_off: "false"
      - platform: switch
        friendly_name: Bathroom Light Switch
        id: 1
      - platform: light
        friendly_name: Bathroom Dimmer
        id: 2 # Usually 1 or 20
        brightness: 2 # Optional, usually 3 or 22, default: "none"
        brightness_lower: 10 # Optional, usually 0 or 29, default: 29
        brightness_upper: 1000 # Optional, usually 255 or 1000, default: 1000

Does anyone have any experience with version 4.1.0 of LocalTuya that can help me with this?


Sometimes, the best way to fix a problem is to ask for help on a forum before you continue working on it. I got it to work!

If you have the same problem, here’s what I did.

  1. If you have the device set up already and it’s not working, delete it entirely.

    • It’s best to start from scratch. Do this by going to Settings, Devices & Service, select the Devices tab, click the device in question, then in the Device Info section, click the three dots next to Download Diagnostics and click Delete
  2. Add the device again.

    • Go to the Integrations tab of Devices and Services and click Configure within the localtuya integration
    • Add a new device and enter the approprate information to get to the card to select entities, such as switches or lights
    • Add a switch entity, select (in my case) DP 1 and give it a name like Living Room Switch. This is the entity that you will use to toggle the light on and off
    • Submit the entity and you’ll be shown a card to add more entities. By default, a checkbox will be checked saying not to create more entities. Uncheck this box. In the dropdown list, select Light and then continue.
    • On the card to configure the entity, select (in my case) DP 2. Give it a name like Living Room Dimmer. Be sure to also select DP 2 within the Brightness section of the entity setup. That’s the step that I was missing in the past.
    • Submit the entity, then close the configuration without adding more entities

That’s it! Now, when you go to configure automations, you’ll turn it on and off with the switch entity, and you’ll set the brightness with the dimmer entity, even if the light is off. Since the switching is done by the switch and not the light, changing the brightness does not turn the light on!