the Tuya FS-05R dimmers are quite nice. They allow a decent control of dimming and even support 3 separate buttons. E.g. one for on/off, one for up, one for down
attached a script currently supporting one button (as commonly used):
features:
- short press: switches on/off
- double click: reverse dim direction (ping pong shortcut)
- long press if device is on: dim either up or down
- long press if device is off: turn on at brightness zero, continue from there with dim up
- if brightness reaches the upper or lower bound: reverse dim direction (ping pong)
- wifi LED reflects channel 1 state (on/off)
startDriver TuyaMCU
tuyaMcu_setBaudRate 115200
tuyaMcu_defWiFiState 4
PowerSave 1
SetFlag 10 0 // Flag 10 - [MQTT] Broadcast self state on MQTT connect DONT CLUTTER LOG
SetButtonTimes 2 3 2 // provides fast response and low lag
SetChannel 14 40 // define dim stepsize
// button o (connected in parallel to WiFi button)
SetPinChannel 7 10
SetPinRole 7 Btn
// button -
SetPinChannel 24 11
SetPinRole 24 Btn
// button +
SetPinChannel 26 12
SetPinRole 26 Btn
// LED
SetPinChannel 8 13
SetPinRole 8 Rel
alias reverse_dim_dir setChannel 14 -$CH14
alias check_bounds if $CH2==1000||$CH2==0 then reverse_dim_dir
alias turn_on_at_zero backlog SetChannel 1 1; SetChannel 2 1
alias dim_step backlog if $CH2==1000||$CH2==0 then reverse_dim_dir; addChannel 2 $CH14 0 1000
alias calc_sndcmd backlog setChannel 13 !$CH1; setChannel 5 $CH2*$CH1; setChannel 3 $CH5/256; setChannel 4 $CH5%256
setChannelType 1 toggle
setChannelType 2 dimmer
addEventHandler OnChannelChange 1 startScript autoexec.bat refresh
addEventHandler OnChannelChange 2 startScript autoexec.bat refresh
addEventHandler OnClick 7 toggleChannel 1
addEventHandler OnHold 7 if $CH1==0 then turn_on_at_zero else dim_step
addEventHandler OnDblClick 7 reverse_dim_dir
refresh:
calc_sndcmd
tuyaMcu_sendCmd 0x30 00$CH3$$CH4$
tuyaMcu_sendCmd 0x30 00$CH3$$CH4$