Device button with 4 different actions

Tags: #<Tag:0x00007f32888b69a8> #<Tag:0x00007f32888b65c0> #<Tag:0x00007f32888b6318> #<Tag:0x00007f32888b5da0> #<Tag:0x00007f32888b5a30>

DEVICE BUTTON WITH 4 DIFFERENT ACTIONS
Tasmota Version 8.3.1 button and switch commands.

EDIT May 28 2020 Added to bottom of post:
Sonoff Touch multiple press and group topic

This works 1 short press, 2 short press, 3 short press and long press on tasmota Sonoffs basic button to toggle other MQTT devices. Remote MQTT Controlled devices do not need to be V8.3.1

!!! WORKS!!!
On a devices that has a button,switch or touch pad.

This is with a tasmota V8.3.1 sonoff basic fixed to a living floor lamp.
IMG_20200527_103812

I wanted the Sonoff basic button pushed onced to toggle the relay ON\OFF to the lamp.
(NO CHANGE from default)

Now I want to hold the button down for 1.5 seconds to toggle ON\OFF kitchen sink light.
And then push putting twice to toggle ON\OFF kitchen overhead light and so on…

Setup on the device to operate push button.
** BACK UP FIRST :skull_and_crossbones:**
SetOption can now be shortened to SO in 8.3.1
In tasmota console input:

SO1 1

SetOption1 Set button multipress mode to
0 = allow all button actions (default)
1 = restrict to single to penta press and hold actions (i.e., disable inadvertent reset due to long press)

Next
(optional)for auto discovery if using Home assistant without yaml.

SO19 1

** Check your other settings.**
Use this backlog.

Backlog SwitchMode1;SwitchTopic1;SetOption73;ButtonTopic1

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”

Second step:
Set button hold time to 1.5 seconds.
On Lamp tasmota console input

SetOption32 15

SetOption32 Number of 0.1 seconds to hold button before sending HOLD action message.
1…100 to set button hold time (default = 40). This option also affects the time required to perform a firmware defaults reset (10x HOLD action time)

Then type in the rules:

(you can put all in one rule but I like to be able to shut off and on each rule.)

Find the MQTT topic of the device(s)you wish to remotely toggle.
Can view in tasmota device info.

Screenshot_20200527-123915_2

*Check what the order of
prefix/topic or topic/prefix
In tasmota device info or console
by typing

Fulltopic
will look like this or reversed
“FullTopic”:"%prefix%/%topic%/"

kids_bedroom_light/cmnd/
or
cmnd/kids_bedroom_light/

List of button states

  • 10=1 short press
  • 11=2 short press
  • 12=3 short press
  • 13=4 short press
  • 14=5 short press
  • 3=LONG press

Input rules in the tasmota console
each rule is for 3 other devices to toggle from this button.

In console input with your device topic replace device_topic with your prefix/topic order:

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

Then type:

Rule1 on

Rule2
ON button1#state=11 DO publish device2_topic/cmnd/POWER 2 ENDON

Then type:

Rule2 on

Then type:

Rule3
ON button1#state=12 DO publish device3_topic/cmnd/POWER 2 ENDON

*Then type:

Rule3 on

Single gang Sonoff Touch

sonoff_touch_us
This switch has Capacitive Touch Sensors as the button. Same procedure as the Sonoff basic just a couple of setting changes for the type of button and group topic.

Tasmota settings for the Sonoff Touch. Version 8.3.1
Before you make any changes, ** BACK UP FIRST :skull_and_crossbones:**

  • SwitchMode1 0
  • SwitchTopic 0
  • SetOption73 OFF
  • ButtonTopic 0
  • SetOption1 ON

I set my kitchen lights in a group called kitchen
You can set group topic by editing each device you want in that group device using the console
grouptopic1 kitchen

My rules for this switch in my bedroom will toggle my bedroom light one press, Two press toggle master bathroom light and Long press Power OFF ALL my kitchen lights.

Set my hold action time to 1.5 seconds.
SetOption32 15

Input my two rules.
Set long two press to toggle bathroom.
ON button1#state=11 DO publish my_bathroom/cmnd/POWER 2 ENDON

Set LONG press to do a grouptopic to shut off all kitchens lights.
Rule2 ON button1#state=3 DO publish kitchen/cmnd/POWER 0 ENDON
kitchen is the name of the group for my kitchen lights.

Tasmota gethub help pages

Enjoy,
diyredneck.thestovedoc.com

2 Likes

added at bottom of post
** Sonoff Touch multiple press and group topic**

hay bro

did you see this

also I have this which see the button press
as a sensor

  - platform: mqtt
    name: "SpareRoom"
    state_topic: "stat/SpareRoom/BUTTON1"
    value_template: "{{value_json.ACTION }}"
    qos: 1
    expire_after: 1

automations

- id: 'SpareRoom HOLD'
  alias: SpareRoom HOLD
  initial_state: true
  trigger:
  - entity_id: sensor.spareroom
    platform: state
    to: 'HOLD'
  action:
  - data:
      entity_id: light.sidelamp1_1 , light.sidelamp1_2
    service: light.toggle

- id: 'SpareRoom SINGLE'
  alias: SpareRoom SINGLE
  initial_state: true
  trigger:
  - entity_id: sensor.spareroom
    platform: state
    to: 'SINGLE'
  action:
  - data:
      entity_id: light.toilet
    service: light.toggle

and the expire_after: 1 set it back to ‘unknown’

2 Likes

yes I follow Travis that is how I learned but I like to not use yaml if not needed for easy integration and the future of HA is not using so much yaml.
the tasmota rules you don’t really have to do any automation or node red for multi button push.

you know sensors are auto discovery now? Also no need to add in yaml if you set up in tasmota correctly.
the only things I really have in my yaml files are for Shelly and what other setup for integrations to use.

I don’t even use the input selects or booleans anymore because I use the helpers in front end.

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Example configuration.yaml entry
sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /home
      - type: memory_free
      - type: processor_use
      - type: load_1m
      - type: load_15m
      - type: memory_use
      - type: disk_use
        arg: /home
      - type: disk_free
        arg: /home

  
  
homeassistant:
  customize: !include customize.yaml

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate
  
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
climate: !include climate.yaml
input_select: !include input_select.yaml
input_boolean: !include input_boolean.yaml
# Example configuration.yaml entry
weather:
  - platform: darksky
    api_key: !secret darksky_api
    
 

#add Shelly's below 
switch:
  - platform: mqtt
    name: "Factory Shelly2 MQTT 1"
    state_topic: "shellies/shelly1-C48852/relay/0"
    command_topic: "shellies/shelly1-C48852/relay/0/command"
    payload_on: "on"
    payload_off: "off"
    retain: false
    icon: mdi:fireplace

    
  - platform: mqtt
    name: "fish feeder"
    state_topic: "shellies/shelly1-C497C8/relay/0"
    command_topic: "shellies/shelly1-C497C8/relay/0/command"
    payload_on: "on"
    payload_off: "off"
    retain: false
    icon: mdi:fish

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.