Sonoff Dual Window Cover with set position

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

Perfect. Thank you. So just write recorder:
without adding anything else. It will update the home-assistant_v2-db file. Correct?

It doesn’t need anything more. This way it will write on the DB file, though you do have the option to write on a different DB if you configure it.

In other news, I found a really useful feature of Home Assistant, it’s called Packages.
Because of all these lines and different components of the configuration you could end up having a really large configuration file. With the Packages you could add them to a different file.

If anyone is interested check the official doc here.
I’ve also updated the first thread with this tip.

1 Like

I copy all the code but nothing is working for me. It doesn’t show errors. I think that it isn’t even communicating with the sonoff by mqtt. I putted window_1 as the sonoff topic. I have connected the sonoff with home assistant with discovery in configuration ( with setoption19 in the sonoff, and interlock) and I can control it as 2 normal switches in HA. What should I do??

EDIT: It’s working now, I changed the cover (I have the sonoff mqtt integrated by configuration integration).

I was really unhappy with HomeAssistant not having time-based value-changing timers – this kind of timer would fit perfectly here.

What was the assumptions:
a) find out MIN value,
b) find out MAX value,
c) find time DURATION that takes between MIN and MAX,
d) store current value STATE between MIN and MAX based on what time passed in down-counting and up-counting.

I ended up with my own time-counter custom component that simplifies “Dual switch window cover with set position” to three automations.

EDIT:

I’m removing source code from here to keep it up-to-date under this topic:

1 Like

That looks interesting.

Have you tried with multiple covers (I have 11 shutters ie 99 automations)?

I’m giving it a go.

Will let you know how it goes.

It works partially.

First of all I get the following errors:

Error while executing automation automation.back_bedroom_shutter_time_counter_stopped. Invalid data for call_service at pos 1: not a valid value for dictionary value @ data[‘entity_id’]
11:12 AM helpers/script.py (ERROR) - message first occured at 11:05 AM and shows up 19 times

Unable to remove unknown listener <function async_track_point_in_utc_time..point_in_time_listener at 0x6ebe78a0>
11:12 AM core.py (WARNING)

The Up/Down arrows and stop button work as expected.

When using the arrows/stop buttons the position updates when the cover stops not in real time (I can live with that)

Moving the slider (eg 100 -> 90) sets the cover in motion but it (the cover) does not stop at the set position (90) but keeps going. The slider updates to 90. The time_counter is running as expected.

Perhaps if we determine the cause of the errors it may solve the issue.

Hi, thanks for your feedback!

Invalid data for call_service at pos 1: not a valid value for dictionary value @ data[‘entity_id’]

First error looks like you have a typo or disallowed characters in entity_id.

Unable to remove unknown listener <function async_track_point_in_utc_time…point_in_time_listener at 0x6ebe78a0>

I was also seeing this from time to time, but it’s probably caused by first error.

Please review the config for a single cover – you can paste it here for some debug. :slight_smile:

I’m using it with 3 covers.

In configuration.yaml I have:

   time_counter:
      back_bedroom_shutter:
        name: "Back Bedroom Shutter position counter"
        duration: 16 
        min: 0 
        max: 100
        debounce: 1000

The cover definition is:

- platform: template
  covers:
    back_bedroom_shutter:
      friendly_name: "Back Bedroom Shutter"
      position_template: "{{ (states.time_counter.back_bedroom_shutter.state | int) }}"
      close_cover:
        - service: mqtt.publish
          data:
            topic: 'cmnd/sonoff11/power2'
            payload: 'ON'
      open_cover:
        - service: mqtt.publish
          data:
            topic: 'cmnd/sonoff11/power1'
            payload: 'ON'
      stop_cover:
        - service: mqtt.publish
          data:
            topic: 'cmnd/sonoff11/power1'
            payload: 'OFF'
        - service: mqtt.publish
          data:
            topic: 'cmnd/sonoff11/power2'
            payload: 'OFF'
      set_cover_position:
        - service: time_counter.set
          entity_id: time_counter.back_bedroom_shutter
          data_template:
            state: '{{ position }}'
        - service_template: >
            {% if position > states.cover.back_bedroom_shutter.attributes.current_position | int %}
              cover.open_cover
            {% elif position < states.cover.back_bedroom_shutter.attributes.current_position | int %}
              cover.close_cover
            {% endif %}
          entity_id: cover.back_bedroom_shutter

And the automations are:

- alias: Back Bedroom Shutter - started
  trigger:
    - platform: mqtt
      topic: 'stat/sonoff11/+'
      payload: 'ON'
  action:
    - service_template: >
        {% if trigger.topic.split('/')[-1] == 'POWER2' %}
          time_counter.downcount
        {% elif trigger.topic.split('/')[-1] == 'POWER1' %}
          time_counter.upcount
        {% endif %}
      entity_id: time_counter.back_bedroom_shutter

    - alias: Back Bedroom Shutter - stopped
      trigger:
        - platform: mqtt
          topic: 'stat/sonoff11/+'
          payload: 'OFF'
      action:
        - service: time_counter.stop
          entity_id: time_counter.back_bedroom_shutter

    - alias: Back Bedroom Shutter - time counter stopped
      trigger:
        platform: event
        event_type: time_counter.stopped
        event_data:
          entity_id: time_counter.back_bedroom_shutter
      action:
        - service: cover.stop_cover
          data:
            entity_id: back_bedroom_shutter

Went over it several times but can’t find the typo. Perhaps fresh eyes will pick it up.

BTW my relays are reversed ie POWER1 opens, POWER2 closes
Thanks

In action.service.data.entity_id you’re missing cover. before the id of the entity.

It should be:

data:
  entity_id: cover.back_bedroom_shutter

Yep that’s is. Found it 2 seconds after you did. Thanks.

Works perfectly.

Very elegant, especially when combined with https://github.com/thomasloven/lovelace-slider-entity-row/commits?author=thomasloven like so:

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

20

Now to do the other 10 shutters.

Thanks

1 Like

Hello.

I have been working trying to get my roller blind position working today. I had not seen the recent posts to this thread.

So I am trying Seweryn_Zeman’s time_counter custom component.
I have modified my different config files, and like the simple elegant look of the simple slider that is shown in PierreScerri’s screenshot.

I have my configuration files modified, and Lovelace is set up as per PierreScerri’s screenshot - thanks. However, I am back to an old problem:

The slider moves in the interface, but has no action whatsoever. It jumps back to its original (0%) position. Also, moving a shutter using the cover controls does nothing to the position slider… Hmm. Any ideas?

Also, one of my shutters, which shows this in states:


shows NaN% in lovelace? All the other showing “Closed” regardless of their positions. (All of them show 0.0 as the value in states, only this shutter displays NaN % in Lovelace?

Here’s some of my config:

From covers.yaml:

- platform: template
  covers:
    livingfront_cover:
      friendly_name: "Living Room Front Shutter"
      position_template: "{{ (states.time_counter.cover_livingfront_cover.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'   
      set_cover_position:
        - service: time_counter.set
          entity_id: time_counter.cover_livingfront_cover
          data_template:
            state: '{{ position }}'
        - service_template: >
            {% if position > states.cover.livingfront_cover.attributes.current_position | int %}
              cover.open_cover
            {% elif position < states.cover.livingfront_cover.attributes.current_position | int %}
              cover.close_cover
            {% endif %}
          entity_id: cover.livingfront_cover

From my time_counter.yaml file:

  cover_livingfront_cover:
    name: "Living Room Front Shutter position counter"
    duration: 21
    min: 0
    max: 100
    debounce: 1000

From my scripts.yaml file:

open_front_shutter:
  alias: Open Front Shutter
  sequence:
    - service: cover.open_cover
      data:
        entity_id: cover.livingfront_cover
    - service: time_counter.upcount
      data:
        entity_id: cover.livingfront_cover

stop_front_cover:
  alias: Stop Front Shutter
  sequence:
  - service: cover.stop_cover
    data:
      entity_id: cover.front_cover
  - service: time_counter.stop
    data:
      entity_id: cover.front_cover

close_front_shutter:
  alias: Close Front Shutter
  sequence:
    - service: cover.close_cover
      data:
       entity_id: cover.livingfront_cover
    - service: time_counter.downcount
      data:
        entity_id: cover.livingfront_cover

and from my automation.yaml:

#Automations for Living Room Front Shutter
- alias: Living Room Front Shutter - started
  trigger:
    - platform: mqtt
      topic: 'homeassistant/downstairs/shutters/LivingRoomShutter1/stat/+'
      payload: 'ON'
  action:
    - service_template: >
        {% if trigger.topic.split('/')[-1] == 'POWER1' %}
          time_counter.downcount
        {% elif trigger.topic.split('/')[-1] == 'POWER2' %}
          time_counter.upcount
        {% endif %}
      entity_id: time_counter.cover_livingfront_cover

- alias: Living Room Front Shutter - stopped
  trigger:
    - platform: mqtt
      topic: 'homeassistant/downstairs/shutters/LivingRoomShutter1/stat/+'
      payload: 'OFF'
  action:
    - service: time_counter.stop
      entity_id: time_counter.cover_livingfront_cover

- alias: Living Room Front Shutter - time counter stopped
  trigger:
    platform: event
    event_type: time_counter.stopped
    event_data:
      entity_id: time_counter.cover_livingfront_cover
  action:
    - service: cover.stop_cover
      data:
        entity_id: cover.livingfront_cover

If anyone could give me a hint as to where I might look to get the sliders working, I would appreciate that ! Thanks

I found that the slider does not update until the timer stops.

It would be nice to have some indication that the shutter is moving, but I’m happy with the end result

But hey, I got rid of 66 automations, 22 input sliders, and 22 timers. That has to count for something.

Now if only I could get my iPhone Home app to stop saying ‘Opening’ when the shutter is fully open.