Tuya switch

I tried to test this, but I was not really happy with the result (when comparing with Tasmota Integrations). Anyway it is a great project for those who want to stick with the original Tuya firmware. Cudos to the developer and to the community supporting this.

I ended up flashing Tasmota on all my Blitzwolf Tuya powered plugs. Wondered why this was not done earlier…

It is not my intention to offend anybody, but it is widely known that Tuya cloud raises a lot of questions when security and information protection is concerned.

You can flash Tasmota with zero hardware handling (I also didn’t want to mess with soldering, etc). have a look on tuya-convert project. This flashes your plug over the air.

Cheers all

Did you figure this out?

Nope, spent a few more hours on it but did not manage to figure it out beyond the suspicion that the switch might be incompatible (although I can control it fine with the original tuya component).

Try this library instead. It just worked for me. https://github.com/fastcolors/localtuya-homeassistant

So what is the currently most reliable option for sockets with power monitoring to get also the consumption data? Besides tuya convert…

I tried it, and I got the following error:

2020-04-17 14:15:47 ERROR (MainThread) [homeassistant.components.switch] Error while setting up localtuya platform for switch,
Traceback (most recent call last):,
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform,
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT),
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for,
    return fut.result(),
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run,
    result = self.fn(*self.args, **self.kwargs),
  File "/config/custom_components/localtuya/switch.py", line 76, in setup_platform,
    config.get(CONF_VOLTAGE),
  File "/config/custom_components/localtuya/switch.py", line 148, in __init__,
    self._status = self._device.status(),
  File "/config/custom_components/localtuya/switch.py", line 129, in status,
    self._cached_status = self.__get_status(),
  File "/config/custom_components/localtuya/switch.py", line 110, in __get_status,
    status = self._device.status(),
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 311, in status,
    result = json.loads(result),
  File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads,
    return _default_decoder.decode(s),
  File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode,
    obj, end = self.raw_decode(s, idx=_w(s, 0).end()),
  File "/usr/local/lib/python3.7/json/decoder.py", line 355, in raw_decode,
    raise JSONDecodeError("Expecting value", s, err.value) from None,
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0),

I have also changed the acs_voltage with value_tamplate, as the configuration was not valid when using acs_voltage (in the sensor configuration).

How were you able to get the protocol version from the id? What kind of decoder do you use?

No decoder, if your tuya device_id is numeric, eg 1234567890ABCDEF, then you have a protocol 3.1 or 3.3. If your device_id is alfanumeric, eg abcdefghijklmn, you have protocol 3.2 device.

So I guess it is 3.2 on mine - bf8c8a6fbd1cb5d4dbhmay? There is still no support to the 3.2 protocol right?

Unfortunately not. I’m waiting too.

I can get my tuya light switch to work in node-red
in a inject node
{“set”: true, “dps” : 2}
{“set”: false, “dps” : 2}
this is for switch 2
{“set”: true, “dps” : 1}
{“set”: true, “dps” : 1}
this is for switch 1
how an I but in in home assistant as a switch

PLEASE HELP

This one worked for me

Heyy,

Just a little question. Do you guys have a delay as well when switching the switch by hand, so not over the localtuya component? Home Assistant usually takes more than 15 seconds to detect the change. Is there a way to instantly track the change ? Or is that the limitation we have to take for local use.

I use ESPHome for tuya switches now. And there is no problem with the time. Switches in HA and even in Apple Home through bridge work instantly.

Yeah I do that for a few switches as well.
Sadly I got some which are not compatible with tuya convert and doesn’t have an ESP Chip.
So my only Option is using them with localtuya :confused:

Does anyone know if this switch is compatible with tuya-convert:
Switch

if you ID is really 1, 2, 3, 4

hi! may I know where can I get the id of the tuya devices?

Hi. I used this method:

When I last set this up for myself, the Tuya gloves on the main dashboard, showed controls for the colour as well as on off - for my smart globes.

I re-installed my entire setup! Why would this option now be gone?