Skip to content

gresuk/tuya-zigbee-switch

 
 

Repository files navigation

GitHub stars GitHub issues StandWithUkraine

Custom firmware for Tuya switch

A custom firmware for Tuya telink based switch module. Code is based on pvvx's ZigbeeTLc firmware, huge thanks!

Supported devices

Note that rebranded versions may have different internals and may not work. "Zigbee Manufacturer" is the most reliable identifier of the device.

Z2M device name Vendor name Zigbee Manufacturer Type Status Issue
TS0012_switch_module GIRIER TS0012, OXT _TZ3000_jl7qyupf router / end_device Supported -
WHD02 No-name 1 gang switch _TZ3000_skueekg3 router Supported -
TS0002_basic OXT TS0001, probably other rebrands _TZ3000_01gpyda5 router Supported link
TS0011_switch_module GIRIER TS0011, OXT TS0011 _TZ3000_ji4araar router / end_device Supported link
TS0001_switch_module OXT TS0001, probably other rebrands _TZ3000_tqlv4ug4 router Supported link
TS0002_basic GIRIER 2 Gang _TZ3000_zmy4lslw router Supported link
TS0001_switch_module Avatto TS0001 _TZ3000_4rbqgcuv router Supported link
TS0002_limited Avatto TS0002 _TZ3000_mtnpt6ws router Supported link
TS0004_switch_module_2 Avatto TS0004 _TZ3000_5ajpkyq6 router Supported link
TS0012 Moes TS0012 (2 gang switch) _TZ3000_18ejxno0 router / end_device Supported link
TS0012 Bseed TS0012 (2 gang switch) _TZ3000_f2slq5pj router / end_device Supported link
LZWSM16-2 Avatto TS0012 _TZ3000_ljhbw1c9 router / end_device Supported link
WHD02 Aubess WHD02 _TZ3000_46t1rvdu router / end_device Supported link
ZS-EUB_1gang Moes TS0011 (1 gang switch) _TZ3000_hhiodade router / end_device Supported link
TS0013 Moes TS0013 (3 gang switch) _TZ3000_qewo8dlz router / end_device Supported link
TS0012 Internet search says this is Zemismart 2 gang switch, needs confirmation _TZ3000_zmlunnhy router / end_device In progress link
TS0011 Avatto TS0011 _TZ3000_hbxsdd6k router / end_device Supported link
TS0003 Moes MS-104CZ _TZ3000_pfc7i3kt router Supported -
ZB08 Girier-ZB08 _TZ3000_ypgri8yz router / end_device Supported link
TS0004_switch_module Avatto 4 gang switch module with N _TZ3000_ltt60asa router WIP, SUPPORT NOT CONFIRMED YET! link

If you device is not supported, but it is some Tuya switch module, please check the porting guide.

Why?

The main driver for this project was the following factory firmware bug: if one button is pressed, the device ignores clicks to other buttons for ~0.5 seconds. The most frustrating consequence is that pressing both buttons at the same time turns only one relay on.

Features

  • Detached mode, e.g. switch doesn't trigger relay but only generates events via Zigbee
  • Long press for momentary switches with configurable duration
  • Router/EndDevice modes for no-neutral devices
  • Super fast reaction time (compared to the factory firmware)
  • 5 quick presses to reset the device
  • Power-on behavior
  • Switch modes ON_OFF/OFF_ON/TOGGLE allowing to synchonize switch position with relay state

Building

Only on linux:

make install
make

Flashing

Firmware can be flashed via OTA. If you still use zigbee2mqtt 1.x, use this guide

To switch between End Device and Router follow this guide

To flash via wire, follow this guide

Changelog

v1.0.15

  • Add support for Zigbee groups. Read doc for details about endpoints.

v1.0.14

  • Improve code logic for Indicator LED on for switches

v1.0.13

  • Fix power on behavior = OFF not working if toggle in pressed state during boot
  • Add way to control network state led state (requires re-download of switch_custom.js)

v1.0.12

  • Fix led indicator state in manual mode not preserved after reboot
  • Add forced device announcement after boot to make sure device is seen as "available" as soon as it boots
  • Restored device pictures in z2m (requires re-download of switch_custom.js)
  • Cleaned-up z2m converter (fix typos, inconsistent names, etc). Warning! This may break your automations as it changes property names (requires re-download of switch_custom.js)

v1.0.11

  • Improve join behaviour by decreasing timeout between tries to join
  • Fix leave network: now device will send LeaveNetwork command properly
  • Display firmware version in a human-readable form

v1.0.10

  • Add support for bi-stable relays contolled by 2 pins
  • Fix Led indicator mode not preserved after reboot

v1.0.9

  • Fix reporting of indicator led status

v1.0.8

  • Add support for indicator leds
  • Add way to force momentary mode as default via config

v1.0.7

  • Add SUSPEND-based sleep to EndDevice firmware to decrease power usage ~10x

v1.0.6

  • Add way to change device pinout on the fly, to allow easier porting of firmware

v1.0.5

  • Keep status LED on when device is connected
  • Add separate firmwares for End Device/Router
  • Improve device boot time significantly by removing unnecessary logs

v1.0.4

  • Fix bug that caused report to be sent every second

v1.0.3

  • Add support of statup behaviour: ON, OFF, TOGGLE, PREVIOUS
  • Add support of button actions: 'released', 'press', 'long_press'. This is only useful for momentary (doorbell-like) switches.

v1.0.2

  • Add way to reset the device by pressing any switch button 5 times in a row
  • Fix support for ON_OFF, OFF_ON actions

Acknowledgements

About

Firmware for tuya zigbee switch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 38.4%
  • C 32.8%
  • Python 17.3%
  • Makefile 4.0%
  • Jinja 4.0%
  • Assembly 3.5%