Sonoff Dual Window Cover with set position

Does the service cover.set_cover_position work for anyone with this setup?

If so, what’s your configuration? Thanks!

Thank you so much for the brilliant solution! I have been trying to do this for so long! Everything is working as it should but the only thing is when I set the window position to x amount the calculation start to go wrong and when I reach the 100% on the slider the cover doesn’t go all the way up!

What I have done is I changed every 18 and 17 to 19 in the configurations/automation files which is my cover time to fully close/open.

So is this normal or am I doing something wrong ?!

Thank You!

Does anyone knows how to use Alexa to open / close the window cover ?

Hello PierreScerri,

I am new to Home Automation, Home Assistant, YAML HASS.io etc. and my knowledge is growig exponentially. However, I need a bit more practice and fiddling around with other’s work for me to fully understand and master this.

From your post, I understood that the first quoted code is for the groups.yaml - but the second bit is code for the view (To get it showing correctly in one of the overview tabs, right?). If you could confirm, I would appreciate that.

Now, I have modified a lot of stuff from here, and this probably is not helping. BUT. I managed to have a fully working example for one shutter in my house. I want to set up 8 shutters in total: 5 in a downstairs group, and three in an upstairs group. I Have modified the entries in the groups.yaml file accordingly.

I have this as the code for my view:

shutters_view:
  entities:
    - group.downstairs_shutters
    - group.upstairs_shutters
  name: Shutters
  view: 'yes'
type: vertical-stack

But I get an error :slight_smile:

When I go to hassio.local:8123/states I see this:

(See cover, input number and Automation.)

Could you break down for me the steps involved in setting up multiple roller blinds? Should I be setting up yaml files for each blind? I then just reference those with a !include in the configuration.yaml, right?

An outline of the approach (without the detail - I should figure that out) would be greatly appreciated.

A big thanks to bkbilly for starting this topic.

I am operating my blinds with Tuya based curtain switches (three buttons Closed - Pause and Open) flashed with Tasmot and set up as per bkbilly’s examples.

I got these switches for about €14 each from China (€25 for swift delivery directly in France : Amazon.fr)

If anyone wants information about the switches, how I have configued them in Tasmota (or anything else for that matter - but at this stage I probably will not be f much use!!!) please let me know - I would be happy to provide further detail.

Hi

Apologies for not replying earlier, but I was away on holiday.

The post you refer to is old. Things are very different with the new Lovelace front end.

That means that the ‘shutters_view’ group is no longer used.

Try this:

type: entities
entities:
  - group.downstairs_shutters
  - group.upstairs_shutters
show_header_toggle: false
title: Shutters

You can include any entity you like in the list.

Or you could simply click on the ‘+’ in Configure UI and add an entities card and fill in the fields as required.

To setup multiple roller blinds, I set up one and got it working as I wanted. Then duplicate the code for each blind making changes such as name, timer duration, Mqtt topics etc.

Yes. That’s what I did.

The reference for the automation folder needs to look something like this:

automation old: !include_dir_merge_list automation

The ‘states’ view shows all the entities you have grouped by type.

Hope this helps.

Thanks! PierreScerri.

I started again with hass.io and got that part working OK. Your explaination is clear and I am fine with that. Thanks very much.

If you could help a complete beginner on something else that would be appreciated…

I have spent a week messing around with HomeAssistant and my shutters to get a better understanding of how HA works.
Its starting to come together, but I need more practice, time etc.

I reworked my configs and got the shutters working. I could not get the timers working reliably, and will remove those, but I did manage to Integrate IFTTT with Google Assistant and IFTTT with HA using webhooks. By defining a voice command “OK Google, Open the kitchen shutter” I am able to get IFTTT to send a webhook to my HA instance and get it to close my shutter.

This is what I was looking to achieve initially, so I was going to replicate that for each shutter command as well as shutter groups to be able to control multiple shutters with one voice command…
That was the plan. No idea what happened, as nothing has really changed in my config, but hass.io now shows:

Failed to call cover/close_cover image when trying to use one of the switches on the dashboard to control my shutters.
Same for cover/open_cover…

Using developers tools the same thing:

What happened to my services?!?!?!? From what I can tell these are effectively defined in “automations.yaml” and nothing has changed there between when it was working and now?

I feel like Ive taken 10 steps back in my understanding!!!

Any help would be greatly appreciated. Even pointers in te right direction to help my understanding.

EDIT: I found what the problem was. Trying to change too many things at once. My MQTT broker was defined in configuration.yaml with its IP address. I had been configuring DHCP reservations so that my different Wi-Fi devices have grouped IP addresses. So, my hass.io server IP address changed, but I did not change the mqtt broker IP address in the config…

I use SIRI to control individual or groups of shutters. No need to set commands for each one.

I can tell SIRI “open kitchen shutter to 60%”, for example.

No experience with IFTTT. Glad it works for you.

The timers are there to help simulate shutter position (even if it’s not extremely accurate) and the time the switches are ‘ON’. I think that removing them will break the automations.

How do the relays of the switches turn off after a shutter has reached its end of travel? Are you using ‘Pulsetime’ in Tasmota?

It would be interesting to see your configuration.

Yep we all fall into that trap.

Hi bkbilly,

in your post of 9th February, you state that you have updated all the code in your first post. Thanks for that.
I am new to this and appreciate your contributions, I may well be mistaken, but from your configuration.yaml, without the recorder: part, it won’t work?

recorder: is not in the code in the first post btw.

Been trying to figure this out on my own, but I’m stuck and would appreciate some help.
Details from my configuration.yaml and automations.yaml are at the bottom of this post.

The position of the shutters:

Up / Down (Open / Closed) buttons inactive.
Shutter is half way up, but the position is incorrect (eg. it shows fully up) and as such the up button is greyed out. (If you’re at the top you can’t go up, I get that).
Currently I have to manually change the position slider to activate the buttons to get the shutter to work… not very practical!!
How can I get the buttons to be active all the time, accepting that the position will never be 100% accurate for multiple reasons? (Principally, the thickness of the shutter on the roller means as it is rolling up, it “accelerates” as one turn of the motor is moving more shutter due to the increased circumference of the roller.)

Thanks for any pointers!

My Setup:
My configuration.yaml:
(I have three buttons on my physical switches. I have set up the middle (stop) button as a third relay in tasmota so that with interlocking, it simply turns the other relays off ) up/down).

recorder:

timer:
  livingfront_up:
    duration: '00:00:21'
  livingfront_down:
    duration: '00:00:21'

input_number:
  livingfront_position:
    name: "LivingF Pos."
    min: 0
    max: 100
  livingfront_set_position:
    name: "Set Liv.F"
    min: 0
    max: 100

cover:
      - platform: template
        covers:
          livingfront_cover:
            friendly_name: "Living Room Front Shutter"
            position_template: "{{ (states.input_number.livingfront_position.state | int) }}"
            open_cover:
              - service: mqtt.publish
                data:
                  topic: 'homeassistant/downstairs/shutters/LivingRoomShutter1/cmnd/POWER1'
                  payload: 'On'
            close_cover:
              - service: mqtt.publish
                data:
                  topic: 'homeassistant/downstairs/shutters/LivingRoomShutter1/cmnd/POWER2'
                  payload: 'On'
            stop_cover:
              - service: mqtt.publish
                data:
                  topic: 'homeassistant/downstairs/shutters/LivingRoomShutter1/cmnd/POWER3'
                  payload: 'On'

My automations.yaml config

- id: '301_1'
  alias: Living Room Front - MQTT Button1 OFF (up)
  trigger:
  - payload: 'OFF'
    platform: mqtt
    topic: homeassistant/downstairs/shutters/LivingRoomShutter1/stat/POWER1
  action:
  - service: timer.cancel
    entity_id: timer.livingfront_up
  - service: input_number.set_value
    data_template:
      entity_id: input_number.livingfront_set_position
      value: >-
          {{ states.input_number.livingfront_position.state }}

- id: '302_1'
  alias: Living Room Front - MQTT Button2 OFF (down)
  trigger:
  - payload: 'OFF'
    platform: mqtt
    topic: homeassistant/downstairs/shutters/LivingRoomShutter1/stat/POWER2
  action:
  - service: timer.cancel
    entity_id: timer.livingfront_down
  - service: input_number.set_value
    data_template:
      entity_id: input_number.livingfront_set_position
      value: >-
          {{ states.input_number.livingfront_position.state }}
          
- id: '303_1'
  alias: Living Room Front - Timer stopped
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.livingfront_up
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.livingfront_down
  - platform: mqtt
    topic: homeassistant/downstairs/shutters/LivingRoomShutter1/cmnd/POWER3
    payload: 'on'
  action:
  - service: cover.stop_cover
    data:
      entity_id: cover.livingfront_cover

- id: '311_1'
  alias: Living Room Front - MQTT Button1 ON (up)
  trigger:
  - payload: 'ON'
    platform: mqtt
    topic: homeassistant/downstairs/shutters/LivingRoomShutter1/stat/POWER1
  action:
  - service: timer.start
    data:
      duration: 00:00:21
    entity_id: timer.livingfront_up

- id: '312_1'
  alias: LivingFront - MQTT Button2 ON (down)
  trigger:
  - payload: 'ON'
    platform: mqtt
    topic: homeassistant/downstairs/shutters/LivingRoomShutter1/stat/POWER2
  action:
  - service: timer.start
    data:
      duration: '00:00:21'
    entity_id: timer.livingfront_down

- id: '411_1'
  alias: Living Room Front - Position UP
  trigger:
    platform: time_pattern
    seconds: '/1'
  condition:
    condition: state
    entity_id: 'timer.livingfront_up'
    state: active
  action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.livingfront_position
      value: >-
          {% set step=100/21 %}
          {% if (states.input_number.livingfront_position.state | float + step) < 100 %}
            {{ states.input_number.livingfront_position.state | float + step }}
          {% else %}
            100
          {% endif %}
        
- id: '412_1'
  alias: Living Room Front - Position Down
  trigger:
    platform: time_pattern
    seconds: '/1'
  condition:
    condition: state
    entity_id: timer.livingfront_down
    state: active
  action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.livingfront_position
      value: >-
          {% set step=100/21 %}
          {% if (states.input_number.livingfront_position.state | float - step) > 0 %}
            {{ states.input_number.livingfront_position.state | float - step }}
          {% else %}
            0
          {% endif %}
        
- id: '511_1'
  alias: Living Room Front - Set Position Down
  trigger:
    platform: state
    entity_id: input_number.livingfront_set_position
  condition:
    condition: template
    value_template: >-
        {{ (states.input_number.livingfront_position.state | int) >
           (states.input_number.livingfront_set_position.state | int) }}
  action:
  - service: timer.start
    data_template:
      entity_id: timer.livingfront_down
      duration: >-
          {{ '00:00:%02d' | format(((
              (states.input_number.livingfront_position.state | int) - 
              (states.input_number.livingfront_set_position.state | int)
             ) * 21 /100) | int | abs )
          }}
  - service: cover.close_cover
    data:
      entity_id: cover.livingfront_cover

- id: '512_1'
  alias: Living Room Front - Set Position UP
  trigger:
    platform: state
    entity_id: input_number.livingfront_set_position
  condition:
    condition: template
    value_template: >-
        {{ (states.input_number.livingfront_position.state | int) <
           (states.input_number.livingfront_set_position.state | int) }}  
  action:
  - service: timer.start
    data_template:
      entity_id: timer.livingfront_up
      duration: >-
          {{ '00:00:%02d' | format(((
              (states.input_number.window_position.state | int) - 
              (states.input_number.window_set_position.state | int)
             ) * 21 /100) | int | abs )
          }}
  - service: cover.open_cover
    data:
      entity_id: cover.livingfront_cover

You can use:

assumed_state: true in the customise section of each shutter to make both arrows active all the time.

Check out:

However, I have a similar setup and both arrows become active when the position >0 & <100.

I found that you may need to get everything in sync initially perhaps by working the shutters via their web interface and manually setting the input sliders. Usually it works quite well afterwards.

Hope this helps

(I have three buttons on my physical switches. I have set up the middle (stop) button as a third relay in tasmota so that with interlocking, it simply turns the other relays off ) up/down).

I have the same thing, A button with three actions up/down/stop so the question is how you configured the middle button as the third action please ?! I don’t know how to do it!

Your switch probably has 2 physical relays, like mine.
First thing I did was configure interlocking (interlock on) as a command in the tasmota console in the web interface. This means that when any relay is activated, it deactivates the other relays.
Then, I set button 3 and relay 3 together. Even with no relay, pursuing the button gets tasmota to think it has enabled relay 3, thereby deactivating relays 1 and 2 ( up and down).

Thanks for replying what i have is sonoff dual r2 and the switch is this one


So the wire that come from this switch is three wires I connected one to the gnd and one to button 0 and the third to button 1 and everything works as it should but if I activate it from mqtt or from home assistance and i click on the stop button the middle one it turn on rely 1 !
What i need is to configure middle button as off at all cases. Thank you so much

Can you post a screenshot of your tasmota module configuration. I’ll try to help if I can see how you have it configured currently.

here is my configration


and I’ve enabled the interlock “Interlock”:“ON”,“Groups”:“1,2”

Question is do you have physical 3 switches ? or like the switch I’m using?

Thank you for your support.

I have updated the first post with some explanations and some Frequent Asked Questions.
This should make things more clear.

Hi, thanks for sharing this wonderful project. I set and everything works. I’m not sure about the recorder function. I wrote like this:
46
it’s correct?
Thank’s!!!

Yes, that’s correct.

Thanks, but how does the “recorder:” feature work specifically?

It stores the current values of window position to the Db and they are restored after a reboot.
If you want more info check the official thread Here