is a good example of how to receive all data on request, and I noticed that in every successful example, our device sends the entire packet every time after waking up, even if there are no changes in the settings, which in turn leads to less autonomy from the accumulator, if you take away from the code "linkTuyaMCUOutputToChannel 17 val 5 1" and "linkTuyaMCUOutputToChannel 18 val 6 1" then the device only sends temperature, humidity, and when battery status changes and alarm states.
I am trying to execute the following logic:
if "CH7" is set to a high state through mqtt, then insert the following code "linkTuyaMCUOutputToChannel 18 val 6 1", otherwise - do not execute
if - works improperly regardless of whether the condition is met or not, it still performs the function
I am trying to execute the following logic:
if "CH7" is set to a high state through mqtt, then insert the following code "linkTuyaMCUOutputToChannel 18 val 6 1", otherwise - do not execute
if - works improperly regardless of whether the condition is met or not, it still performs the function
Spoiler:
waitFor MQTTState 1
// extra delay, to be sure
delay_s 1
startDriver TuyaMCU
startDriver tmSensor
// dpID 1 is tempererature div 10
setChannelType 1 temperature_div10
linkTuyaMCUOutputToChannel 1 val 1
// dpID 2 is % humidity
setChannelType 2 Humidity
linkTuyaMCUOutputToChannel 2 val 2
// dpID 3 is battery state - low(0), mid(1) and high(2)
linkTuyaMCUOutputToChannel 3 enum 3
setChannelType 3 ReadOnlyLowMidHigh
setChannelLabel 3 Battery
setChannelType 7 Toggle
setChannelLabel 7 seting
//
// setup dpCache - temperature interval
//
// Show textfield for that
setChannelType 5 TextField
// setup display name
setChannelLabel 5 Temperature Interval
// Make value persistant (stored between reboots),
// start value -1 means "remember last"
SetStartValue 5 -1
// set default value if not set
if $CH5=0 then "setChannel 5 1"
// link dpID 17 to channel 5, the type is val, extra '1' means that its dpCache variable
if $CH7!=0 then "linkTuyaMCUOutputToChannel 17 val 5 1"
setChannelType 6 TextField
setChannelLabel 6 Humidity Interval
SetStartValue 6 -1
if $CH6=0 then "setChannel 6 1"
if $CH7!=0 then "linkTuyaMCUOutputToChannel 18 val 6 1"
waitFor MQTTState 1
// extra delay, to be sure
delay_s 1
startDriver TuyaMCU
startDriver tmSensor
// dpID 1 is tempererature div 10
setChannelType 1 temperature_div10
linkTuyaMCUOutputToChannel 1 val 1
// dpID 2 is % humidity
setChannelType 2 Humidity
linkTuyaMCUOutputToChannel 2 val 2
// dpID 3 is battery state - low(0), mid(1) and high(2)
linkTuyaMCUOutputToChannel 3 enum 3
setChannelType 3 ReadOnlyLowMidHigh
setChannelLabel 3 Battery
setChannelType 7 Toggle
setChannelLabel 7 seting
//
// setup dpCache - temperature interval
//
// Show textfield for that
setChannelType 5 TextField
// setup display name
setChannelLabel 5 Temperature Interval
// Make value persistant (stored between reboots),
// start value -1 means "remember last"
SetStartValue 5 -1
// set default value if not set
if $CH5=0 then "setChannel 5 1"
// link dpID 17 to channel 5, the type is val, extra '1' means that its dpCache variable
if $CH7!=0 then "linkTuyaMCUOutputToChannel 17 val 5 1"
setChannelType 6 TextField
setChannelLabel 6 Humidity Interval
SetStartValue 6 -1
if $CH6=0 then "setChannel 6 1"
if $CH7!=0 then "linkTuyaMCUOutputToChannel 18 val 6 1"