Device button with 4 different actions

all good bro

1 Like

Hi, stumble upon this. I have three lights in my kitchen. Two Tasmota lights (a dimmer over the table and a switch for the ceiling light) and a Philips Hue over the sink. I have a 'Home Assistant Switch Plate (HASP) to control everything from the sink where the Hue light is but would like to add some more automations from where the Tasmota ceiling switch is (when you enter the kitchen), like:

  • Single press: Turn the ceiling light on;
  • Double press: Turn all three lights on and set to full brightness for the Tasmota dimmer and Hue light ;
  • Triple press: Turn off the ceiling light and table light, turn on the Hue light at 10%;
  • Hold: Turn all three lights off.

Do you know if it’s feasible with this method?

Thanks.

Not sure about dimer I have non doninhave not played with it.
Travis might know


Heck his discord

I like the Rule in Tasmota that will trigger the scene or buttons in Home Assistant via MQTT. I do not like to mess with limited Rules memory on each switches. Any help will be appreciated. Like a sample codes, Thanks

What is your HA configration.yaml codes look like for this double pressed? Why you send POWER with payload of 2, can it be anything?

Not understanding question. I’m using tasmota rules not yaml.
The switches are mqtt.

My post about Sonoff tx switches with remote control

@Rod_Poplarchick
Did you manage to decouple the button from the local relay?

I can’t seem to stop mine turning the local relay on, which I don’t want, I just want to send the mqtt message relating to the various button press options for home assistant to do things like adjust the temperature for the thermostat in the room (which will likely turn on the relay, but it also does things like call for heat from the boiler).

When you do the setting and rules like explained above yes the relay used for remote decouple.

I can’t make it work. Are you sure this is correct?

There are so many reason why it dont work
you set the setting and the rule in the Master device console and the devicenametopic is the device you want to control.
]is your setting like this?
**Should look like this:
“SwitchMode1”:“0” or “SwitchMode1”:“OFF”
“SetOption1”:“1” or “SetOption1”:“ON”
“SwitchTopic”:"" or “SwitchTopic”:“0”
“SetOption73”:“0” or “SetOption73”:“OFF”
“ButtonTopic”:"" or “ButtonTopic”:“0”

and you have to put the name device name and topic that you want to control.

Rule1 ON
button1#state=3 DO publish cmnd/YOURDEVICENAMETOPIC/POWER 2 ENDON

and you have to turn the rule on
Rule1 1

1 Like

Thanks for the fast help. I am sure I have it all as in your example.

I wonder about “state=3” instead of “state=10”. Tried it but for right now it doesn’t work.

status 0
09:23:27.449 MQT: sonoff/SF_GarageDoorSwitch/STATUS = {"Status":{"Module":1,"DeviceName":"SF_GarageDoorSwitch","FriendlyName":["Tasmota"],"Topic":"SF_GarageDoorSwitch","ButtonTopic":"","Power":1,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0,"InfoRetain":0,"StateRetain":0}}
09:23:27.463 MQT: sonoff/SF_GarageDoorSwitch/STATUS1 = {"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://ota.tasmota.com/tasmota/release/tasmota.bin.gz","RestartReason":"Software/System restart","Uptime":"1T01:53:04","StartupUTC":"2022-12-22T06:30:23","Sleep":50,"CfgHolder":4617,"BootCount":12,"BCResetTime":"2022-10-14T06:10:07","SaveCount":108,"SaveAddress":"FB000"}}
09:23:27.476 MQT: sonoff/SF_GarageDoorSwitch/STATUS2 = {"StatusFWR":{"Version":"12.1.1(tasmota)","BuildDateTime":"2022-08-25T11:33:55","Boot":7,"Core":"2_7_4_9","SDK":"2.2.2-dev(38a443e)","CpuFrequency":80,"Hardware":"ESP8285","CR":"387/699"}}
09:23:27.488 MQT: sonoff/SF_GarageDoorSwitch/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["home",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["0000800B","0F05C80001000600003C5A0A002800000000","00000080","00006000","00004000","00000000"]}}
09:23:27.510 MQT: sonoff/SF_GarageDoorSwitch/STATUS4 = {"StatusMEM":{"ProgramSize":624,"Free":376,"Heap":23,"ProgramFlashSize":1024,"FlashSize":1024,"FlashChipId":"144051","FlashFrequency":40,"FlashMode":3,"Features":["00000809","8F9AC787","04368001","000000CF","010013C0","C000F981","00004004","00001000","54000020","00000000"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,16,18,19,20,21,22,24,26,27,29,30,35,37,45,62","Sensors":"1,2,3,4,5,6"}}
09:23:27.525 MQT: sonoff/SF_GarageDoorSwitch/STATUS5 = {"StatusNET":{"Hostname":"SF-GarageDoorSwitch-5306","IPAddress":"192.168.0.51","Gateway":"192.168.0.1","Subnetmask":"255.255.255.0","DNSServer1":"192.168.0.1","DNSServer2":"0.0.0.0","Mac":"DC:4F:22:9E:74:BA","Webserver":2,"HTTP_API":1,"WifiConfig":4,"WifiPower":17.0}}
09:23:27.540 MQT: sonoff/SF_GarageDoorSwitch/STATUS6 = {"StatusMQT":{"MqttHost":"192.168.0.6","MqttPort":1883,"MqttClientMask":"SF_GarageDoorSwitch","MqttClient":"SF_GarageDoorSwitch","MqttUser":"kai","MqttCount":1,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30,"SOCKET_TIMEOUT":4}}
09:23:27.555 MQT: sonoff/SF_GarageDoorSwitch/STATUS7 = {"StatusTIM":{"UTC":"2022-12-23T08:23:27","Local":"2022-12-23T09:23:27","StartDST":"2022-03-27T02:00:00","EndDST":"2022-10-30T03:00:00","Timezone":99,"Sunrise":"08:41","Sunset":"16:56"}}
09:23:27.572 MQT: sonoff/SF_GarageDoorSwitch/STATUS10 = {"StatusSNS":{"Time":"2022-12-23T09:23:27","Switch1":"ON"}}
09:23:27.588 MQT: sonoff/SF_GarageDoorSwitch/STATUS11 = {"StatusSTS":{"Time":"2022-12-23T09:23:27","Uptime":"1T01:53:04","UptimeSec":93184,"Heap":25,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"ON","Wifi":{"AP":1,"SSId":"home","BSSId":"50:XX:F6:83:31:5C","Channel":1,"Mode":"11n","RSSI":100,"Signal":-49,"LinkCount":1,"Downtime":"0T00:00:03"}}}

I still don’t understand your question
Need more information.
Can you type rule1 in your command line and paste the output of that here?
Also what is the topic name of the device you are trying to control ?

Also what are you trying to have the slave device do?
Because the power command 2 at the end is toggle
If you want on or off you use another power command.

Rules for remote buttons to control other MQTT entities/devices.
A little bit of explaining what each command is and what control relays.

Power Control the corresponding power state (1…8) (also restarts PulseTime)
0 / off / false = turn OFF
1 / on / true = turn ON
2 / toggle = if power state is ON switch to OFF and vice versa
3 / blink = toggle power for BlinkCount times each BlinkTime duration (at the end of blink, power state is returned to pre-blink state)
4 / blinkoff = stop blink sequence and return power state to pre-blink state

Thanks, Rod!

when I type “rule1” I get:

MQT: sonoff/SF_GarageDoorSwitch/RESULT = {"Rule1":{"State":"ON","Once":"OFF","StopOnError":"OFF","Length":58,"Free":453,"Rules":"ON button1#state=3 DO publish cmnd/SF_Garage/POWER 2 ENDON"}}` 

I am trying to control with a single click SF_Garage and with a double click “SF_Gate”

My slave devices are connected to other Sonoffs which send an on-command during a second, so they close the relay during one second and open/close a garage door or a gate.

Well if it is a button and not a relay you are trying to activate I don’t believe power would be the command.

“Power” or “toggle”… it doesn´t matter. But my problem is that the switch does not recognize the difference between a single and a double click. Also, it does not decouple from the relais which it should as the single or double click should not control the relais of the same sonoff device but from different ones.

What I believe you are trying to do is use device A buttons to control a gate button for Device B.

This write up is for multi button press on a master device to control other devices topics.
I’m not sure how to do button presses on slave devices from another device.

Multiple press settings for device A
Has nothing to do with the number of press for device B.

Write up exacty what your trying to do.
With type of master device {Device A}and the topic name of that device
And the slave device {device B} type and topic or button and action you want.
Someone smarter than me should be able to help you out. In the discord channels or maybe @digiblur can help you

1 Like

Rod, thanks once again for your help. Just a quick update how I managed to get it all sorted out: The Sonoff Mini’s GPIO 4 needs to be configured as a Button. As the Mini already has one button configured internally, this one needs to be configured as Button 2.

Once this was sorted out, I managed to use your code. But it did need a smaller correction


This indeed needs to be #state=10

And then it all worked like a charme.

I did not notice we were on this old post

This one might help you with other tricks.
Most of our 1 to 3 button switches {15 of them}in our house is set up with most of the below link set-up.
Controling esp Wled lights, esphome based led lights and many other automation.