Sonoff Dual Window Cover with set position

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.

Thanks.

Some progress here, problem was PIBCAK. Resolved. ( had an incorrect name for one of my time counters).

However, now I have a different problem, that I don’t fully understand.
None of my sliders work as expected, and one seems to be the reverse of all of the others.

I also find that composing questions to post here is the best way to troubleshoot. While explaining the problem in words, it really helps to go back and check the config… Like you PierreScerri - my POWER1 is up/close and my POWER2 is down/open.

I modified my covers.yaml to reflect the up / down timer for POWER 1 and POWER 2 respectively. It seems to be working better now.

However, the Office Shutter position never gets set… it always stays at 100%. when I use the buttons to control that shutter. If I use the slider, the shutter moves accordingly, and the position is set correctly when it stops moving… unless I set the position with the slider to 0% - then it stays at 100%. Everything is set up the same as the other shutters, so this is a mystery to me.

NONE of the other shutters sliders work to set the position. I try to set the position to say 50% from 100% - and it stops at 97%? However, their position is correctly reported as closed or 100% when fully opened or closed.

So frustrating when the setup is identical (probably isn’t but I cannot see…

One other thing… there’s always one thing isn’t there… When I use a script to invoke the closure of all shutters, once closed, all positions update, apart from my office shutter, which remains at 100% (open). That’s also another small issue… when closed (0%) the slider shows closed. When open (100%) the slider shows 100% (and not open). Can we not have a consistent display and show open for 100%, closed for 0% and the %age for anything in between?

HELP!!!

The inverted shutter has to be a typo.

Re 100% vs open, perhaps that’s why the iPhone Home app says “Opening” when the shutter is at 100%

Still getting a lot of this:

Unable to remove unknown listener <function async_track_point_in_utc_time..point_in_time_listener at 0x6f193108>
6:08 PM core.py (WARNING)

A few of them at a time every 30-45 minutes.

Any idea what this could be?

Hey, good to see that someone made a use of this component. :slight_smile:

I updated the component.py under:

It solves Unable to remove unknown listener warnings.
FYI @PierreScerri

@Neale_Dowling I’ll take a look at your scenario when I find some time!

@Seweryn_Zeman THanks for your work here… using it and its working well.

I found my problem after leaving things alone for some time… (A break, and coming back with fresh eyes is often the solution!!! My problem was my MQTT topic. I organise my topics under “upstairs” and “downstairs”. My office is downstairs, and in the automation, a copy paste error meant I had upstairs in the mqtt topic, not downstairs… @PierreScerri - of course, you were right, it was a typo!!! hence the problem. All working well now. Will try the new code to see if the Unable to remove unknown listener warnings go away.

Thanks again…

Hi, I have just configured everything with time_counter but despite having put 20 seconds of time the relay always stops at 10 seconds.
It also doesn’t fit the position and I don’t know how to calibrate.
here is my configuration.
can you help me?

time_counter:
saracinesca_garage:
name: Saracinesca Garage
duration: 20
initial: 0
min: 0
max: 100
debounce: 1000

  • platform: template
    covers:
    saracinesca_garage:
    friendly_name: “Saracinesca Garage”
    position_template: “{{ (states.time_counter.saracinesca_garage.state | int) }}”
    close_cover:
    - service: mqtt.publish
    data:
    topic: ‘cmnd/saracinesche_garage/power2’
    payload: ‘ON’
    open_cover:
    - service: mqtt.publish
    data:
    topic: ‘cmnd/saracinesche_garage/power1’
    payload: ‘ON’
    stop_cover:
    - service: mqtt.publish
    data:
    topic: ‘cmnd/saracinesche_garage/power1’
    payload: ‘OFF’
    - service: mqtt.publish
    data:
    topic: ‘cmnd/saracinesche_garage/power2’
    payload: ‘OFF’
    set_cover_position:
    - service: time_counter.set
    entity_id: time_counter.saracinesca_garage
    data_template:
    state: ‘{{ position }}’
    - service_template: >
    {% if position > states.cover.saracinesca_garage.attributes.current_position | int %}
    cover.open_cover
    {% elif position < states.cover.saracinesca_garage.attributes.current_position | int %}
    cover.close_cover
    {% endif %}
    entity_id: cover.saracinesca_garage

  • alias: Saracinesca Garage - started
    trigger:

    • platform: mqtt
      topic: ‘stat/saracinesche_garage/+’
      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.saracinesca_garage
  • alias: Saracinesca Garage - stopped
    trigger:

    • platform: mqtt
      topic: ‘stat/saracinesche_garage/+’
      payload: ‘OFF’
      action:
    • service: time_counter.stop
      entity_id: time_counter.saracinesca_garage
  • alias: Porta Cucina - time counter stopped
    trigger:
    platform: event
    event_type: time_counter.stopped
    event_data:
    entity_id: time_counter.saracinesca_garage
    action:

    • service: cover.stop_cover
      data:
      entity_id: cover.saracinesca_garage

I had forgotten the pulsetime command active on the sonoff, now the time is respected. But the problem remains that the slide does not match.
For example if I put the cursor on 25% he moves up to 36% or 38% etc.
How can I solve this problem?

Is it possible to set the cover position with alexa? So when I say “alexa, set roller to 38 %”, ha set the roller to that percentage.

hi sorry to bump this, but since I also suffer a lot of the unknown listeners errors: do you know what causes these warnings?

This error shows up when you create a new timer and what is returned is a listener on which you can call .cancel(). If timer ended successfully this listener is wiped out so you cannot call .cancel() on it anymore. If you try – you get this one.

I had mine Unable to remove unknown listener because of async executions which didn’t lined up.

thanks! you’re the first to give me a lead where to look…

thing is, the log is flooded with these… and I don’t have a lot of timers, which aren’t active when this happens:

could this also be caused by sensors, checking for time differences like


      - condition: template
        value_template: >
          {{ (now() - trigger.from_state.last_changed | default(0) ).total_seconds() > 120 }}

Hi to everybody, anyone have some idea how to implement the duration of timers in Node_red? Call service tab on node_red don’t accept data_template but only data

Hi, were you able to solve your problem? I used your automation as the basis for mine but it reports an error in the position part. Could you help me? good day

HI Asino, I suggest you to direct use the custom_component Timedcover, this platform can make what they need without any additional set.

Hi and thanks for the advice, I implemented the component. I just have a question to you does set_position work? good evening

1 Like

Yes Asino,off course work, this platform work like a timer, you need to set the time need for full open and for full close the cover, than when you for example set position to 20% your cover will be in open function for 20% time of your full open time (eg. full open time 30s - set 20% position: 30/100*20= 6s in open function).
Let me know if you need some help for properly set this platform, just for your info, the tilt position work only for suncover with motorized tilt function.

1 Like

Thank you for your support, you are right after several attempts the component works on the gray scale. All that remains is a problem not related to the component. I control the device through a double relay of the quino that I also control with two physical buttons. It happens that if I control the blinds with the physical buttons the component does not detect the displacement. Now I’m trying to create the automations associated with the relays closing but for now without success. good day.

HI Asino123, one solution for your issue is using a timer that’s both activated by your switch and the Home Assistant (set position or switch). I’ve used the solution provided below along with timedcover: