Sonoff Dual Window Cover with set position

Same by me, the physical buttons do not work.

Does someone has an fix?

Hi, I have read all the topic and applied the custom timer component to my configuration. Now I can control my ride shutter from hassio, Google assistant and switches without problems.
The only thing I can’t adjust is about different position shutter reach depending if i’m closing or opening it.
For instance, if shutter is closed and I set to open it 50% the reached position is correct but it is not the same when the shutter is all open and I want to close it 50%. In this case the shutter stops far from 50%…near to completely close. I suppose it is a different speed of the engine opening or closing the shutter. Is there a way to solve it?
Thanks to everyone will give advices.

Hi, do you think it’s possible to adapt your code to ESPHome? Thanks

It’s already there - https://esphome.io/components/cover/time_based.html
I’m using sonoff touch to operate my roller shutters. I can set position and open/close them from HomeAssistant and Google Assistant

Dear all thank you so much for the code and continuous improvement. I have one problem with this code… I’m not able to get the position sliders to be updated when I press the arrows or when I use the physical buttons. In the past (one year ago maybe) I was able to get this working but now it does not work.

Any advice?

You will have to check that the topic stat/window_1/POWER1 is sent correctly to mosquitto server which is defined on the automations.yaml file.

Thank you so much!!! I had a issue with topics definition overall and MQTT that was causing this behaviour and not the code itself. After setting up the devices correctly everything worked as expected!!! Great code!

Best regards

Hi, Thanks for sharing the project. I am using my shutters with your esphome code on an Olimex esp32 platform. However, I would like to have set position and Windows position control in the home assistant. This seems possible only with the mqtt protocol. I, however, would like to avoid mqtt because when the server is off I would like to be able to close the blinds from the physical buttons. In your opinion, would it be possible to set simple buttons and relays in esphome without using the cover and then arrange the cover in the Home assistant? can you help me?

For controlling the cover with physical buttons you will have to change the pin number from the binary_sensor (GPIO09 & GPIO00). This way the server can be off and still be able to control the cover.

Though, if you want to set the position I believe that this might help: set_position(0.5), but I don’t know exactly how to use it so you might want to try it out.

Edit: This might also work by replacing it on on_press and on_release:

    - cover.control:
        id: cover_1
        position: 50%

Now my code is

binary_sensor:

  • platform: gpio
    pin:
    number: GPIO02
    mode: INPUT_PULLUP
    inverted: True
    id: ph_button3
    on_press:

    • cover.open: my_cover
      on_release:
    • cover.stop: my_cover
  • platform: gpio
    pin:
    number: GPIO03
    mode: INPUT_PULLUP
    inverted: True
    id: ph_button4
    on_press:

    • cover.close: my_cover
      on_release:
    • cover.stop: my_cover

switch:

  • platform: gpio
    pin: GPIO04
    interlock: &interlock [open_cover, close_cover]
    id: open_cover
  • platform: gpio
    pin: GPIO05
    interlock: *interlock
    id: close_cover

cover:

  • platform: time_based
    name: “myroom_window”
    id: my_cover
    open_action:

    • switch.turn_on: open_cover
      open_duration: 18s

    close_action:

    • switch.turn_on: close_cover
      close_duration: 18s

    stop_action:

    • switch.turn_off: open_cover
    • switch.turn_off: close_cover

… but i don’t see the slider position

in HA i see only
31

Hi, could you tell me exactly where to write

- cover.control:
    id: cover_1
    position: 50%

???

Hi Pierre, can you help me?
I would like to add to my cover in esphome a slider that marks the position of the curtain. My code is currently:

binary_sensor:

- platform: gpio
  pin:
    number: GPIO02
    mode: INPUT_PULLUP
    inverted: True
  id: ph_button3
  on_press:
  - cover.open: my_cover
  on_release:
  - cover.stop: my_cover
  
- platform: gpio
  pin: 
    number: GPIO03
    mode: INPUT_PULLUP
    inverted: True
  id: ph_button4
  on_press:
  - cover.close: my_cover
  on_release:
  - cover.stop: my_cover

switch:
- platform: gpio
  pin: GPIO04
  interlock: &interlock [open_cover, close_cover]
  id: open_cover
- platform: gpio
  pin: GPIO05
  interlock: *interlock
  id: close_cover

      
cover:

- platform: time_based
  name: "myroom_window"
  id: my_cover
  open_action:
    - switch.turn_on: open_cover
  open_duration: 4s

  close_action:
    - switch.turn_on: close_cover
  close_duration: 4s

  stop_action:
    - switch.turn_off: open_cover
    - switch.turn_off: close_cover

what do I have to add to see also the position slider besides the forward, back and stop buttons?
Thank you!!!

I used the slider-entity row: https://github.com/thomasloven/lovelace-slider-entity-row

type: entities
entities:
  - entity: cover.back_bedroom_shutter
  - entity: cover.back_bedroom_shutter
    full_row: true
    type: 'custom:slider-entity-row'

which gives:

34

I use slider-entry-row and it works perfectly. Only one problem: when I restart home assistant, the slider is setted to 0 even if the shutter is in other position. And on my sonoff dual (whit tasmota and shutter configuration) the position is right. Thers’s an automation to announce the current position that I have to call on home assistant start?
This is my cover configuration:

  - platform: mqtt
    name: "Cameretta_f"
    availability_topic: "tele/sonoffdual002/LWT"
    state_topic: "stat/sonoffdual002/RESULT"
    command_topic: "cmnd/sonoffdual002/Backlog"
    value_template: '{{ value | int }}'
    qos: 1
    retain: false
    payload_open: "ShutterOpen1"
    payload_close: "ShutterClose1"
    payload_stop: "ShutterStop1"
    state_open: "ON"
    state_closed: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    optimistic: false
    set_position_topic: "cmnd/sonoffdual002/ShutterPosition1"
    position_topic: "stat/sonoffdual002/SHUTTER1"

Hi all, today I will receive my Sonoff Dual and I will setup this project, so thanks for sharing!

This is al very new for me and I am still a bit concerned about a possible short circuit and breaking the motor. I know that power1 OFF is being published before power2 ON, but what if something is wrong with publishing power1 OFF? Then power2 ON should not be published. Is this possible or should I trust HA for 100% publishing them in the right order?

There is an interlock option for both solutions which only enables one relay at a time, though in my motor if both are pressed it just stops.

Thanks, I founfd it! Very useful

Hi, I’m trying to enter the availability_template command but I’m getting an error. Can you help me?

  - platform: template
    covers:
      window_cover_cucina:
        friendly_name: "Cucina"
        availability_template: 'tapparella/status'
        position_template: "{{ (((states.input_number.window_position_cucina.state | int) * 100)/39 | int) }}"
        open_cover:
          - service: mqtt.publish
            data:
              topic: 'tapparella/switch/tenda_cucina_giu/command'
              payload: 'OFF'
          - service: mqtt.publish
            data:
              topic: 'tapparella/switch/tenda_cucina_su/command'
              payload: 'ON'
        close_cover:
          - service: mqtt.publish
            data:
              topic: 'tapparella/switch/tenda_cucina_su/command'
              payload: 'OFF'
          - service: mqtt.publish
            data:
              topic: 'tapparella/switch/tenda_cucina_giu/command'
              payload: 'ON'
        stop_cover:
          - service: mqtt.publish
            data:
              topic: 'tapparella/switch/tenda_cucina_su/command'
              payload: 'OFF'
          - service: mqtt.publish
            data:
              topic: 'tapparella/switch/tenda_cucina_giu/command'
              payload: 'OFF'

this setup could be also valid to XIAOMI AQARA ZIGBEE to control covers?

autoanswer, yes it’s working… !!!
but i have some issues with the "set_position! but im working in progress to fix it.