Sonoff Tasmota extension for covers

I’m developing an extension to the excellent Sonoff Tasmota libraries, so I can use a Sonoff Dual or Sonoff 4CH or custom 8 relay board as a cover controller.
IE where you need two relays to control the different directions on a blind, window, etc.

This means each Pair of relays act as open/close for each cover (I have blinds and auto windows to use with these)

Currently I have it setup as follows
setoption22 turns on cover mode
PulseTimeX then sets the length of time to open or close the cover
New command “cover” then works like power to open or close or set position
StateText1,2 can then be changed to Open/Close, Up/Down, Tilt/Flat etc to match the cover type

thus you can use Cover1 On, Cover1 Off, Cover1 Open, Cover2 Down to move the covers
You can also use Cover1 75 to move it to 75% open
The STAT queries also return these values or the current % position of the blind.

When going fully open or closed, I add 10% extra time to ensure they go fully open or closed.
On the Sonoff Dual, I’ve also implemented the single switch so it toggles between open/stop/close/stop each time its pressed. The Web server, or power commands will also either open/close/stop the blinds, depending on which is pressed.

I don’t have hass discovery working as yet, and not sure if i need a relay pause setting to stop you switching quickly between open and close directions.

If anyone has any further ideas or suggestions to include, please let me know


Excellent. It will help me a lot.
I am in the process of automating the garage with a 4ch Pro.
Also have a few more ordered to use for the patio shades and the gate. And most of the lighting in my house uses low voltage push switches and the relays are all in the switchbox in the garage.

Will the 4ch Pro pulsetime be selectable via console?
As 4ch pro uses dip switches to select pulsetime and I understand this is controlled by the STM32 chip.

Thank you

Hi, I look forward for your firmware. I am planning to add motors to my rolling shutters next summer, and Sonoff 4ch seemed the cheapest option to control them.

I’m oriented to the 4ch Pro, because it can be wired to avoid having both Up and Down on simultaneously and burn the motor.

One detail: with standard Tasmota, when the wifi signal drops they will restart and blink the light every 30 seconds. What will happen to the shutters?

I have existing motorized shades and was researching how to make them “smart.” Did you consider other switches besides Sonoff?

The problems I have with the 4CHPro is

  1. Interlock is one to ALL, I want 2 relays per window, thus a 4CH can do two windows independently and simultaneously, the pro could NOT
  2. the DIP switch timing isn’t long enough, I need 22 seconds for my windows and 35 for my blinds

As for the pulsetime via console, I’m not sure, but you could confirm with arendst as to whether you can change it. I don’t have any 4CH Pro’s to test

The Dual has a blue LED for WIFI and an RGB led for the Relays, so as far as it is concerned, the blinking blue led does not interfere with the relays being operated.

My final safety code to be added, will be to update the lowest level function that controls the relays to guarantee that only one of any pair can be enabled, regardless of higher level attempts to do otherwise.

Currently, I have a 4CH running two blinds with Pulsetime only and controlling all directional changes etc via Home-Assistant, and i’ve never had an issue, even with wifi loss or sonoff crashes.

So i’m reasonably confident.

The other option with the Pro, since you have both NC and NO contacts (unlike the others) means you could run one relay as the “Power on/power off” and the second relay as the “up/down”, thus the second relay guarantees you can’t turn both on simultaneously.

The other advantage of my version, is you can simple set a degree of opening and not the default fully open/fully closed.

I used to have an X10 blind controller running the blinds, but have moved completely away from all the X10 stuff i had.

The reason I like the sonoff tasmota code is

  1. it’ll run on almost any ESP8266 board, so I cna have custom 4 or 8 channel boards
  2. I can use MQTT
  3. I can control/configure directly thru web interface

I have also updated my code, so that each relay pair has two pulsetimers.

the first, defines the length of time for open/close (in seconds)
the second, defines the startup time before movement starts happening.
My LiWIN windows controllers need ~2seconds from power on to start of movement.

Thus to get reasonably accurate positioning, I needed to factor in this startup time.

I will also use this startup time as the “gap” time when switching between “opening” and “closing”

thus further limiting any possibility of both on at the same time.

This sounds awesome! Let me know if you need any beta testers.

1 Like

Io you need testers

Hi all,

I have code ready for testers to try out.
I’ve only tested on Dual, but should work for 4CH as well.
setoption22 1 turns on Cover mode
pulsetimeN sets open/close time required for relays N and N+1
pulsetimeX sets the gap and/or start time for movement (mine is 2 seconds), where X is the number of pairs + cover number
NOTE: pulsetime for covers is ALWAYS seconds (and not the scale used by arendst - ie 13 is 13 seconds)
IE for a 4CH, pulsetime1 is open/close time for first pair
pulsetime3 is the gap/start time for first pair.

so for my Dual and windw windows I have
setoption22 1
pulsetime1 23
pulsetime2 2

use the command
cover X
where X is ON, OFF or percentage open (5-100%)
cover 0 thru 4 are reserved as follows
0 - OFF
1 - ON (100%)
2 - Toggle between open/stop/close/stop (ie single switch)
3 - immediate stop
4 - immediate stop and set position to 0 (closed)
NOTE: You can also use a negative offset.
If you do it means turn off all relays and set position as absolute value
ie cover -50 will turn off relays and state position is 50%
NOTE: If you set STATETEXT1 to CLOSE and STATETEXT2 to OPEN, you can also use OPEN/Close as commands

Hope this all makes sense

1 Like

Very interesting!
i’ve flashed my sonoff dual R2 and i’ll make some test.
Some questions…how can i read the aperture percentage from the sonoff to HA, for example if i restart HA.
And if i use the external buttons, the percentage is set to the sonoff?

Yes, you can use standard tasmota procedure to flash firmware and revert back.
The firmware have different dates signatures on settings so you’ll likely have to do full settings reset when switching.

If you run the console on the firmware you can see the responses.

Simply sending the cover command without any arguments will return the current cover position

Sorry i modified my reply before yours.
What about my questions?

@kabongsteve cover 0 should open or close the cover?
in my case it opens.

anyway, with your cover mode the sonoff works like a single button that opens or closes the cover, am I right? since I have a rolling shutter with 2 physical buttons that open or close totally with a single push, your version not working for me.

If I set pulsetime 22 to open totally the shutter, if I want to open it 50% I need to send a stop command to the same button of the sonoff after 11 sec.

How can I achieve that?

If cover 0 opens rather than closes, then you simply need to reverse the two relay connections.

How you use it depends on how you have it connected. If you are using the sonoff relays to do the equivalent of press the button on the existing controller, then this will not work for you.

This is designed so the the relays are held closed for the duration of the pulsetime.

Thus if directly connected to the motors, keep the power applied for the length of time needed to open or close. thus, to half open, the relay is held for half the time.

It sounds like you maybe using the relays as the simply button presses.
Thus, you would need a version of this that would pulse the relay on/off initially, then pulse it again at the end of the pulsetime, assuming it was wanted less than fully open or closed.

it could be done

1 Like

It sounds like you maybe using the relays as the simply button presses.
Thus, you would need a version of this that would pulse the relay on/off initially, then pulse it again at the end of the pulsetime, assuming it was wanted less than fully open or closed.

Yes it’s exactly what i need. i posted an issue Sonoff Dual R2 and rolling shutter position · Issue #2167 · arendst/Tasmota · GitHub hoping someone can help me

shall i change the firmware via OTA or do i need to change via cable? I have a Dual just with arendst firmware

is it possible to set duration for every swith? My cover need more time to go up (40 seconds) than go down (30 seconds)


Hi, you can use ota.

Duration is the same for both. I assume your blinds auto stop, so regardless of the duration they should be ok. Just set duration to 40.

The position may not be quite correct.

You could also try pulsetime1 as 35 and pulsetime2 as 6 or 8. Or similar to get it reasonably accurate

Thanks for reply, i did the upgrade via cable and it works fine.

I don’t undestarnd the usage of pulsetime2

Also i notice a strange thing, if for example i send the command Cover1 24 it start to put down the cover but it return another value

11:42:57 CMD: cover 24
11:43:01 MQT: stat/sonoff02/RESULT = {"Cover1":22}
11:43:08 CMD: cover 25
11:43:10 MQT: stat/sonoff02/RESULT = {"Cover1":22}