question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tuya dimmer switch cannot change brightness, only on/off

See original GitHub issue

The problem

Tuya dimmer switches not getting brightness command from Home Assistant. product Category is “tgq”. I have 2 types of this dimmer, and one type works and the other does not. Suspect related to a differenece in: Working tgq instruction set:

switch_led_1 | Boolean | "{true,false}"
-- | -- | --
bright_value_1 | Integer | {   "unit": "",   "min": 10,   "max": 1000,   "scale": 0,   "step": 1 }

Non working set:

switch_led | Boolean | "{true,false}"
-- | -- | --
bright_value_v2 | Integer | {   "min": 10,   "scale": 0,   "unit": "",   "max": 1000,   "step": 1 }

One uses bright value 1 and the other bright value 2. These are the same brand… working unit “Smart 3-Way Dimmer Switch_DS02_NEW”, non working unit “DS02S Smart dimmer switch”

HA is not sending any brightness command information to these devices… brightness control works well in native app.

Logs and debug info below.

What version of Home Assistant Core has the issue?

2021.11.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

tuya

Link to integration documentation on our website

No response

Example YAML snippet

N/A

Anything in the logs that might be useful for us?

2021-11-28 08:02:11 DEBUG (SyncWorker_4) [homeassistant.components.tuya.base] Sending commands for device 8240074324a1603a1e8e: [{'code': <DPCode.SWITCH_LED: 'switch_led'>, 'value': True}]
2021-11-28 08:02:13 DEBUG (Thread-5) [homeassistant.components.tuya] Received update for device 8240074324a1603a1e8e: {'switch_led': True, 'bright_value_v2': 100}


THIS COMMAND EXECUTED VIA SERVICE CALL TO LIGHT_ON... SAME RESULTS
2021-11-28 08:04:11 DEBUG (SyncWorker_5) [homeassistant.components.tuya.base] Sending commands for device 8240074324a1603a1e8e: [{'code': <DPCode.SWITCH_LED: 'switch_led'>, 'value': True}]
2021-11-28 08:04:11 DEBUG (Thread-5) [homeassistant.components.tuya] Received update for device 8240074324a1603a1e8e: {'switch_led': True, 'bright_value_v2': 100}


THIS IS A COMMAND TO THE WORKING SWITCH FOR THE SAME ACTION:
2021-11-28 08:07:41 DEBUG (SyncWorker_0) [homeassistant.components.tuya.base] Sending commands for device 22002172e0980605bf33: [{'code': <DPCode.SWITCH_LED_1: 'switch_led_1'>, 'value': True}, {'code': <DPCode.BRIGHT_VALUE_1: 'bright_value_1'>, 'value': 445}]
2021-11-28 08:07:41 DEBUG (Thread-5) [homeassistant.components.tuya] Received update for device 22002172e0980605bf33: {'switch_led_1': True, 'bright_value_1': 445, 'brightness_min_1': 100, 'led_type_1': 'incandescent'}

Additional information

This Unit Works Correctly:

Product Name: Smart 3-Way Dimmer Switch_DS02_NEW Product Category: tgq

Code	Type	Values
switch_led_1	Boolean	"{true,false}"
bright_value_1	Integer	{
  "unit": "",
  "min": 10,
  "max": 1000,
  "scale": 0,
  "step": 1
}
brightness_min_1	Integer	{
  "unit": "",
  "min": 10,
  "max": 1000,
  "scale": 0,
  "step": 1
}
led_type_1	Enum	{
  "range": [
    "incandescent",
    "halogen"
  ]
}

This is the non working model:

Product Name: DS02S Smart dimmer switch Product Category: tgq

Code	Type	Values
switch_led	Boolean	"{true,false}"
bright_value_v2	Integer	{
  "min": 10,
  "scale": 0,
  "unit": "",
  "max": 1000,
  "step": 1
}

HA is not sending any brightness command to the non working unit. I cannot find any further log information related to the problem, no errors or other messages that trace back to this.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
lukeskiscommented, Jul 20, 2022

I am experiencing the “on/off works, but brightess doesn’t” on my Gosund SW-2 dimmers. Tuya category “dj”

The following behavior is consistent on both of the following dimmers:

Device Information:
Product Name: SW2智能调光开关-AR
Device ID: [REDACTED]
Product Category: dj
Main Module: v1.0.3
MCU Module: v1.0.3
Device Information:
Product Name: SW2智能调光开关
Device ID: [REDACTED]
Product Category: dj
Main Module: v1.0.1
MCU Module: v1.0.1

On this version of HA:

Home Assistant 2022.7.3
Frontend 20220707.0 - latest

When debugging using the Tuya IoT platform to send instructions directly to the dimmers, I have noticed that when sending instructions containing BOTH switch_led & bright_value at the same time, the bright_value gets ignored.

For example, with the switch OFF, and the last bright_value @ 255, sending:

[
  {
    "code": "switch_led",
    "value": true
  },
  {
    "code": "bright_value",
    "value": 100
  }
]

Will only turn the switch ON.

Once the switch is ON, sending the same instructions does not change the brightness at all (bright_value still at 255)

HOWEVER, once the switch is on, if you send JUST the bright_value, it is respected and the light dims.

E.g. - sending:

[
  {
    "code": "bright_value",
    "value": 115
  }
]

adjusts the brightess as expected.

I have noticed that the HA never sends two separate messages (e.g. one for power, the other for brightness) - instead, it looks like both are always sent at once (and in my case, the brightness value is ignored by the dimmer switch)

e.g. - turning the switch ON using HA look like this in the debug logs:

2022-07-20 16:21:25 DEBUG (SyncWorker_6) [tuya_iot] Request: method = POST,url =https://openapi.tuyaus.com/v1.0/devices/[REDACTED]/commands,params = None, body = {'commands': [{'code': <DPCode.SWITCH_LED: 'switch_led'>, 'value': True}]}, t=1658334085801

changing the brightness (which doesn’t change the brightness) looks like this:

2022-07-20 16:23:30 DEBUG (SyncWorker_9) [tuya_iot] Request: method = POST,url = https://openapi.tuyaus.com/v1.0/devices/[REDACTED]/commands,params = None,body = {'commands': [{'code': <DPCode.SWITCH_LED: 'switch_led'>, 'value': True}, {'code': <DPCode.BRIGHT_VALUE: 'bright_value'>, 'value': 131}]},t = 1658334210881

I believe that if HA was to send distinct instructions/API requests to Tuya for dimming & power, then adjusting the brightness would work.

E.g.: When turning ON in HA:

  1. Send instruction for switch_led: true
  2. Send instruction for bright_value: [HA value]

When changing brightness in HA:

  1. Only send instruction for bright_value: [HA value]

When turning OFF in ha:

  1. Send instruction for switch_led: false

Note that sending bright_value when the switch is OFF appears to be ignored, as well.

I’m new to HA & these switches, so cannot comment on whether this has ever worked before, and/or what might have changed over time to change the behaviour.

1reaction
svante-jacobsencommented, Feb 7, 2022

I have this problem too. It worked just before the recent status delay/lost issue. With on/off starting to work again yestrerday, brightness was lost. It works using the Tuya Smart app but not using HA.

I have latest HA and recently restarted the entire host.

Product name: WIFI Dimmer module Product Category: dj

EDIT: I have since quit everything Tuya.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tuya Dimmer Brightness while off - Third party integrations
Tuya Dimmer Brightness while off · Go to the Integrations tab of Devices and Services and click Configure within the localtuya integration ·...
Read more >
Smart Dimmer Switch Compatible with Alexa Google Home ...
1% - 100% DIMMING- This tuya smart dimmer switch adjust the light dimming rang from 1 –100% to cut energy costs and extend...
Read more >
SMATRUL Tuya DIY Mini WiFi Smart LED Dimmer Switch ...
1. Support reset switch, touch switch, mechanical switch.Dimmer switch. 2. If you wire the dimmer switch, you must first adjust the brightness to...
Read more >
Google home no longer allows changing of light colour
Can only turn them on / off or alter the brightness, colour has to be controlled by the Smart Life or Tuya Smart...
Read more >
ABIDE WiFi Mini Smart On-off Device Tuya Dimmer Switch ...
The smart switch supports dimmable lights only. Voice Control: the smart witch supports voice control, which enables you to change the light brightness...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found