Shelly 2.5 cover tilt script

Hi everyone,
I’m using Shelly 2.5 to control my Venetian blinds. Since the Shelly integration (or the device) doesn’t support service cover.tilt I’m trying to figure it out using scripts.
On my dashboard I have 2 buttons for 50% & 75% position open. When I click on them I want the blinds to go that position and tilt the blinds to ~45°.

The routine goes like this:
blinds are open (position 100%) → set_cover_position 50% → wait for position “open” (tilt is 0° meaning no view through the blinds) → open_cover-> delay 900ms → stop_cover.

This way I get the ~45°.

Now I’ve got 2 problems:
a) the wait template is not working
b) I need a condition based on the state opening or closing. The script right now wouldn’t tilt when coming from a full closed status because when opening and reaching the 50% the tilt degree is already 90° and by using open_cover it wouldn’t go further. So I’d need it to close_cover.

How can I resolve this?

Any help much appreciated.

alias: move to 50%, tilt 45°
fields:
  mycover:
    description: Raffstoren auswählen
    selector:
      target:
        entity:
          domain: cover
sequence:
  - service: cover.set_cover_position
    data:
      position: 50
    target: '{{mycover}}'
  - wait_template: '{{ is_state("cover.{{mycover}", "open") }}'
  - delay: '00:00:01'
  - service: cover.open_cover
    data: {}
    target: '{{mycover}}'
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 900
  - service: cover.stop_cover
    data: {}
    target: '{{mycover}}'
mode: single

¡bump!
¡bump!

If it is a venetian blind that goes on tilt after the close state i can share my code

yes please :slight_smile:

on configuration.yaml I added:

cover: !include_dir_merge_list covers
input_number: !include inputnumbers.yaml

I created an input number to configure the close position for the blind and I added it to FrontEnd
On inputnumbers.yaml I added:

tapparellacc_close_position:
  name: Camera C
#  initial: 30
  min: 0
  max: 100
  step: 1
  unit_of_measurement: "%"
  mode: slider

I created a folder covers under config and there I add a yaml file for every venetian blind that then I added to frontend (and also i published to my alexa infrastructure)


- platform: template
  covers:
    shelly25_tapparellacc:
      device_class: blind
      unique_id: shelly25_tapparellacc
      friendly_name: "Tapparella CC"
      #value_template: "{{ states('cover.shelly_shsw_25_40f520XYZ') }}"
      availability_template: "{{ states('cover.shelly_shsw_25_40f520XYZ') != 'unavailable' }}"   
      position_template: >-
        {% set position_close = states('input_number.tapparellacc_close_position')|int %}      
        {% if state_attr('cover.shelly_shsw_25_40f520XYZ', 'current_position') | float == position_close %}
           {{ 0 }}
        {% elif state_attr('cover.shelly_shsw_25_40f520XYZ', 'current_position') | float < position_close %}
           {{ 1 }}
        {% else %}
           {{ (1.265 * (state_attr('cover.shelly_shsw_25_40f520XYZ', 'current_position') - position_close)) | round(0) | int }}
        {% endif %}
      tilt_template: >-
        {% set position_close = states('input_number.tapparellacc_close_position')|int %}
        {% if state_attr('cover.shelly_shsw_25_40f520XYZ', 'current_position') | float <= position_close %}
           {{ 100 - ((state_attr('cover.shelly_shsw_25_40f520XYZ', 'current_position') * (100/position_close))) | round(2)|int  }}
        {% else %}
           {{ 0 }}
        {% endif %}
      optimistic: true
      tilt_optimistic: true
      open_cover:
        service: 'cover.set_cover_position'
        data:
         entity_id: cover.shelly_shsw_25_40f520XYZ
         position: 100
      close_cover:
        service: 'cover.set_cover_position'
        data:
         entity_id: cover.shelly_shsw_25_40f520XYZ
         position: "{{ states('input_number.tapparellacc_close_position') | int }}"        
      stop_cover:
        service: 'cover.stop_cover'
        data:
         entity_id: cover.shelly_shsw_25_40f520XYZ
         
      set_cover_position:
        service: cover.set_cover_position
        data:
         entity_id: cover.shelly_shsw_25_40f520XYZ
         position: "{{((position * ((100 - (states('input_number.tapparellacc_close_position')|int)) / 100)) + states('input_number.tapparellacc_close_position')|int ) | round (0)|int}}" 

      
      set_cover_tilt_position:
        service: cover.set_cover_position
        data:
         entity_id: cover.shelly_shsw_25_40f520XYZ
         position: "{{( states('input_number.tapparellacc_close_position')|int-((states('input_number.tapparellacc_close_position')|int / 100) * tilt)) | round (0)|int}}"

My venetian blinds are not going to tilt after complete closing. Any idea how to deal with that? For now i can just tilt playing around with the open/close toggles.

your message is not clear, could you explain more what happen and how your blinds works?

So i have blinds from Warema, i have my wall switches right now connected to a shelly 2.5 in rolle shutter mode. Controls like up/down are working normally, but if i want to tilt the blind i need to initiate an up or down command and shortly after that in the reverse direction.

Your template is just resulting in up/down commands on my side. So i guess i need something with an delay like the thread opener was mentioning.

Hope it’s more clear with that explanation, otherwise i can try to make a short video

Short update, found an article on medium.com, which point to this package Home Assistant script to control venetian blinds with Shelly · GitHub

With this Script & Automation i got my Tilt working also with the original Shelly 2.5 firmware. Just needed to tweak with the timout configuration. Maybe this will also help out somebody else

2 Likes

Wow, thats what i was looking for since months. I tired to install it on a fresh Home assistant instance with Shelly 2PM but completly lost. I get error message in the script as well in automation…cant save. I would be more than happy to receive a dummy guide how to install the package from medium.com. Love to offer not just a coffee :slight_smile:

How did you integrated it. You can include it inside your configruation.yaml via a package:

  packages:
    raffstore: !include packages/raffstore/cover_position_tilt.yaml

But you can also ask on medium, the author is really helpful in regards of support :slight_smile: