Im using Tasmota on several switches and need more actions on my buttons.
Tasmota is already set-up and when I press a button multiple times, I can see the console log with
9:43:32 MQT: stat/pRSW_DG01/BUTTON3 = {"ACTION":"SINGLE"}
09:43:34 MQT: stat/pRSW_DG01/BUTTON3 = {"ACTION":"DOUBLE"}
09:43:36 MQT: stat/pRSW_DG01/BUTTON3 = {"ACTION":"TRIPLE"}
09:43:38 MQT: stat/pRSW_DG01/BUTTON3 = {"ACTION":"QUAD"}
ideally I just want to trigger rules on certain events like Button3 double press. It would be great if I donÂŽt need to create a virtual switch for every possible state and instead just trigger on string updates with case statements like double, triple, hold etcâŠ
My current things definition file look like this:
Channels:
Type switch : power01 "dgshutterSwitch1" [stateTopic="stat/pRSW_DG01/POWER1", commandTopic="cmnd/pRSW_DG01/POWER1", on="ON", off="OFF" ]
Type string : power01A "dgshutterSwitch1A" [stateTopic="stat/pRSW_DG01/BUTTON1", transformationPattern="JSONPATH:$.ACTION" ]
Type switch : power02 "dgshutterSwitch2" [stateTopic="stat/pRSW_DG01/POWER2", commandTopic="cmnd/pRSW_DG01/POWER2", on="ON", off="OFF" ]
Type string : power02A "dgshutterSwitch2A" [stateTopic="stat/pRSW_DG01/BUTTON2", transformationPattern="JSONPATH:$.ACTION" ]
Type switch : power03 "dgshutterSwitch3" [stateTopic="stat/pRSW_DG01/POWER3", commandTopic="cmnd/pRSW_DG01/POWER3", on="ON", off="OFF" ]
Type string : power03A "dgshutterSwitch3A" [stateTopic="stat/pRSW_DG01/BUTTON3", transformationPattern="JSONPATH:$.ACTION" ]
//Status commands
Type string : status "Status" [stateTopic="tele/pRSW_DG01/LWT"]
Type number : wifi "RSSI" [stateTopic="tele/pRSW_DG01/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
Type string : Version "Firmware" [stateTopic="tele/pRSW_DG01/STATUS2", transformationPattern="JSONPATH:$.StatusFWR.Version"]
}
my Item is defined as:
Switch pRSW_DG01_1 "pRSW_DG01 01 ShutterUP" (pRSWDebug,gDG) {channel="mqtt:topic:MQTTBrokerMT:pRSW_DG01:power01", expire="1s,command=OFF"}
Switch pRSW_DG01_2 "pRSW_DG01 02 Light" (pRSWDebug,gDG) {channel="mqtt:topic:MQTTBrokerMT:pRSW_DG01:power02"}
Switch pRSW_DG01_3 "pRSW_DG01 03 ShutterDWN" (pRSWDebug,gDG) {channel="mqtt:topic:MQTTBrokerMT:pRSW_DG01:power03", expire="1s,command=OFF"}
String pRSW_DG01_1A "pRSW_DG01 01 Press [%s]" (pRSWDebug) {channel="mqtt:topic:MQTTBrokerMT:pRSW_DG01:power01A"}
String pRSW_DG01_2A "pRSW_DG01 02 Press [%s]" (pRSWDebug) {channel="mqtt:topic:MQTTBrokerMT:pRSW_DG01:power02A"}
String pRSW_DG01_3A "pRSW_DG01 03 Press [%s]" (pRSWDebug) {channel="mqtt:topic:MQTTBrokerMT:pRSW_DG01:power03A"}
String pRSW_DG01_Status "pRSW_DG01 Status [%s]" <check> (pRSWDebug) {channel="mqtt:topic:MQTTBrokerMT:pRSW_DG01:status"}
Number pRSW_DG01_Wifi "pRSW_DG01 Wifi [%s %%]" <antenna> (pRSWDebug) {channel="mqtt:topic:MQTTBrokerMT:pRSW_DG01:wifi"}
My rule:
val logName = "Wallmount Switches"
rule "pRSW_DG01_1 Multipress"
when
Item pRSW_DG01_1A received update
then
switch pRSW_DG01_1A.state.toString {
case "SINGLE": {
logInfo(logName, "pRSW_EG01_1" + pRSW_DG01_1A.state.toString)
}
case "DOUBLE": {
logInfo(logName, "pRSW_EG01_1" + pRSW_DG01_1A.state.toString)
}
case "TRIPLE": {
logInfo(logName, "pRSW_EG01_1" + pRSW_DG01_1A.state.toString)
}
case "QUAD": {
logInfo(logName, "pRSW_EG01_1" + pRSW_DG01_1A.state.toString)
}
case "HOLD": {
logInfo(logName, "pRSW_EG01_1" + pRSW_DG01_1A.state.toString)
}
}
end
I updated my code to the correct solution if anyone is having the same questionâŠ