Configure the "Switch-Sonoff-Tasmota" to give only one impulse?

Hi, I want to configure the sonoff switch to make it work as a button. Currently in my configuration.yaml file I have this:
Switch:

  • platform: mqtt
    name: “Sonoff”
    command_topic: “cmnd / sonoff / power”
    state_topic: “stat / sonoff / POWER”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    retain: true

What should I change to make it work as a button?

Try:

platform: mqtt
name: “Sonoff”
command_topic: “cmnd / sonoff / power”
state_topic: “stat / sonoff / POWER”
qos: 1
payload_on: “toggle”
payload_off: “toggle”
retain: true

Which sonoff device are you using?

Thank you. I will try

My sonoff is sonoff basic. No rf, with firmware tasmota.

Would you be a bit more specific about what you want to do?
The sonoff basic is a switch that acts on commands. Do you want the relay to switch on then off again?

Yes, right! I have to connect a relay to which a light is connected. must give an impulse

Look at the pulsetime command in the Tasmota docs

I open some gates by closing the Sonoff relay for 1/2 a sec using

pulsetime 5

and here is an excerpt from my yaml file -

- platform: mqtt
  name: "Gate"
  state_topic: "stat/sonoff-015-Gate/POWER"
  command_topic: "cmnd/sonoff-015-Gate/POWER"
  availability_topic: "tele/sonoff-015-Gate/LWT"
  qos: 1
  payload_on: "ON"
  payload_off: "OFF"
  payload_available: "Online"
  payload_not_available: "Offline"
  retain: false # NB FALSE here - we do not want to retain the ON flag posted to open

PS Please post code corectly to make it easier for people to help you - highlight the code then hit the button which looks like </>

2 Likes

That’s 5 seconds
pulsetime 5 is half a second

Don’t work.
Can youi give me configuration tasmota sonoff??
My cfg tasmota is:
Switche_mode. Toggle
App_pulstime 0,5

In what way does it not work? Can you post the MQTT messages you are seeing?

Did you read the manual about pulsetime? Did you enter pulsetime 5 into the Sonoff console?

What are Switche_mode and App_pulsetime - I have not seen these before.

hello and thank you for your interest. these are the options I can manage in tasmota’s firmware. I use arduino ide to transfer the firmware to the sonoff. in the user_config section you will find these options that you can modify according to the operation you want to get from the sonoff

what do you mean when you tell me to change your image? Where is this swcondo option you? I want to get a simple impulse of the sonoff and I want the status to be updated when the lamp is on or off

You do not need to re-flash the Sonoff, or to change any of the settings in user_config.

Start the Sonoff. Go to the web page of the Sonoff using your web browser. Go to the Console section. Type

pulsetime 5

then when the Sonoff is turned on it will turn itself off after 0.5 seconds.

You can find a detailed description of the command in the manual.

Hi, your information is correct! Now the sonoff I get the impulse I wanted. The problem is that the state of the button in HA follows the hypulso … Let me explain: I want that when I press the button in HA the stao appears “On” when the lamp is on and “off” when and 'turned off even if I only give an impulse. How can I set only the status of the HA icon?

There are lots of ways of doing that. But none of them are very good, because you do not know what the state of the lamp is (for example, if HA re-starts, or if someone toggles the lamp outside of the Sonoff).

If it was me, I would set up a new dummy light in HA, then have an automation which has a trigger of the Sonoff turning ON, with an action of “toggle” on the state of the new light. Then every time you get the impulse the state of the dummy light will toggle between ON and OFF - probably the best you can do.

Um … this is not beautiful! Is it possible that there is not an option that allows me to keep feedback high (or low) until it squashes again? For the physical keys my idea is to use a double button that goes every time to excite both a traditional relay and the sonoff. In this way I can keep the sonoff and my traditional system completely isolated (and I was also thinking about updating the state in this way). This means that even if the sonoff should one day abandon me, I can always count on my civil system. But I want the correct feedback. With the automation of ha I can do nothing? It is necessary to understand which bit is related to the status of the sonoff’s specola and to intervene there.

I am sorry - I do not really understand what you are saying. Are you using Google translate?

Perhaps ask the question in your native language, and see if you can find someone local to help you.

I’m trying to understand your scenario, tell me if I’m correct.

You have a light that is controlled by a latching relay, with momentary buttons on the wall that turn on or off the light at every press. You added the Sonoff in parallel, as another momentary button that toggles the state of the light.
Now you are trying to make the status in HA follow the real status of the light.

I see two options:

  1. you connect the pushbuttons only as an input to the Sonoff. This way you can also think of replacing the relay and let the Sonoff control directly the lights. If the Sonoff breaks, you lose control of the light
  2. you build or find a current-sensing circuit that gets the real status of the light from the output of the relay and connect that to the input of the Sonoff

Correct. Define your point two. please