great. I didn't realize that 'OnRelease' is *not* sent for other button presses (OnClick etc.) than 'OnHold'. That's why I made the conditionals.
Testet now the firmware support with a super simple script (but same functionality) - works 👍
// device: Moyes MS-105
//
// features:
// short press: switches on/off
// 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)
// after long press: reverse dim direction
Testet now the firmware support with a super simple script (but same functionality) - works 👍
// device: Moyes MS-105
//
// features:
// short press: switches on/off
// 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)
// after long press: reverse dim direction
startDriver TuyaMCU
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, works with bDPCache==2 only (see below)
// must use Version: noread_e8ef72c891b1 for that
SetChannel 14 4 // define dim stepsize
// P6 connected to the push button
SetPinChannel 6 10
SetPinRole 6 Btn
alias turn_on_at_zero backlog SetChannel 1 1; SetChannel 2 1
setChannelType 1 toggle
linkTuyaMCUOutputToChannel 1 bool 1
setChannelType 2 dimmer
tuyaMcu_setDimmerRange 0 1000
linkTuyaMCUOutputToChannel 2 val 2 2 // new "bDPCache" "flags" arg: 2 means "do not read"
addEventHandler OnClick 6 toggleChannel 1
addEventHandler OnHold 6 if $CH1==0 then turn_on_at_zero else "addChannel 2 $CH14 0 100 2"
addEventHandler OnRelease 6 addChannel 2 $CH14 0 100 3 // new flag 3