Template cover - how to get position in set_cover_position

@Tediore awesome, that did the trick, thank you very much, I had no clue I have to use data_template instead of just data when using templates, I thought it was simply just like using a variable, but it needs to have this to actually parse the template.

Would you also please happen to know why the position_template is not working. Basically I have a cover called cover.living_room_cover, which supports tilt position. I need to sync current_tilt_position of the cover.living_room_cover with current_position of this template cover.living_room_cover_tilt.
I tried this

position_template: "{{ state_attr('cover.living_room_cover', 'current_tilt_position') | int }}"

but it seems to only update once on reboot, after changing it doesn’t report the correct value.

@petro oh sorry, that wasn’t supposed to sound agressive or anything. I just normally tend to write too many details in my original post and then nobody reads it because it’s too long, so I tried to keep it short this time :slight_smile: I understand the confusion, the tilt position and position mixes up in my brain all the time haha

1 Like

This should also change

        entity_id: cover.living_room_cover_tilt

to this

        entity_id: cover.living_room_cover

entity_id field is for updates to the cover. You don’t want it referencing itself.

You mean in the cover.set_cover_tilt_position service call?
I believe it is not referencing itself, this template cover I posted has entity_id cover.living_room_cover_tilt, which is just a pseudo entity.

The actual working cover device has entity_id: cover.living_room_cover, so I am calling a service cover.set_cover_tilt_position on this entity, from an action in this template cover cover.living_room_cover_tilt, or am I missing something?
It gets a bit confusing with all those tilt words in those names and services aswell.

The entity_id field that you’re using at the root level, outside your service calls. It’s probably not even necessary but you currently have it pointing to itself.

1 Like

Oh you are right, I should read the docs more carefully, I just saw entity_id and assumed it is to manually select the entity_id of this template cover, but actually it is used to react to the state of listed covers, that might actually be the culprit. Again, my brain messed up with playing too much with ESPHome and setting up manually ids of each component.
These covers will kill me, in ESP I also had to make a pseudo template cover, so I can use time-based cover (which doesn’t support tilt), with tilt function.
Thank you :slight_smile:

1 Like

The real problem is how behind google home and alexa are. They should all support this crap but they are taking 10 years to roll it out.

Exactly, they are too far behind, yet I believe they are soo close with this, they have all the voice recognition pieces in place, with all the modes and chained commands, they would easily be able to achieve this, with a little work on their part, only if they wanted to, that’s the problem, they don’t care, so we need to make all these workarounds. Same with source inputs on media_player for example, why do they give you a pre-made list of possible values, why can’t you just send them your list of values to be evaluated with your voice command.

Btw other way I wanted to achieve this cover and tilt function before I decided on doing separate covers was to use template light, brightness would set the position, and then I would set colors for the tilt: green = open, orange = 45degrees, red = closed lol

Template light would have low WAF in my house, Your solution is the best

1 Like

Haha, that’s right. It’s already enough that I have both Alexa and Google Home in the living room and she is always confused who to talk to.

1 Like

I will open a new thread as this one is 3 months old, but I am having a similar problem, everything works fine, except when I try to move the slider on Lovelace. Then I get an error: Failed to call service cover/set_cover_position. can only concatenate str (not “int”) to str.

I have looked all over and tried all kinds of solution I found here, for 2 days yet. Can someone please help me pointing to what am I missing?

cover:
  - platform: template
    covers:
      suite_shades:
        device_class: shade
        friendly_name: "Suite Shades"
        position_template: "{{ states('sensor.shades') }}"
        open_cover:
          service: script.open_shades
          data:
            shade: Shades
        close_cover:
          service: script.close_shades
          data:
            shade: Shades
        stop_cover:
          service: script.stop_shades
          data:
            shade: Shades
        set_cover_position:
          service: script.posiciona_shades
          data_template:
            position: "{{ position }}"
            shade: Shades

and relevant scripts…

script:
  posiciona_shades:
    mode: single
    sequence:
      - choose:
        # IF must open_shades
        - conditions:
            - condition: template
              value_template: "{{ position|int > (states('sensor.{{ shade }}') + 9) }}"
          sequence:
            - service: script.turn_on
              entity_id:
                - script.rise_shades
              data_template:
                variables:
                  deltaporcento: "{{ position|int - states('sensor.{{ shade }}') }}"
                  shade: "{{ shade }}"
            - service: mqtt.publish
              data:
                topic: "void/Shades/Position"
              data_template:
                payload: "{{ position }}"
      # ELSEIF must close_shades
        - conditions:
            - condition: template
              value_template: "{{ position|int < (states('sensor.{{ shade }}') - 9) }}"
          sequence:
            - service: script.turn_on
              entity_id:
                - script.lower_shades
              data_template:
                variables:
                  deltaporcento: "{{ states('sensor.{{ shade }}') - position|int }}"
                  shade: "{{ shade }}"
            - service: mqtt.publish
              data:
                topic: "void/Shades/Position"
              data_template:
                payload: "{{ position }}"

  lower_shades:
    mode: single
    sequence:
      - service: switch.turn_off
        data_template:
          entity_id: "switch.{{ shade }}"
      - delay:
          milliseconds: 1000
      - service: switch.turn_on
        data_template:
          entity_id: "switch.{{ shade }}_up"
      - delay:
          milliseconds: 1000
      - service: switch.turn_on
        data_template:
          entity_id: "switch.{{ shade }}"
      - delay: 
          milliseconds: "{{ deltaporcento|int * 140 }}" # Takes 14s to close
      - service: switch.turn_off
        data_template:
          entity_id: "switch.{{ shade }}"
  rise_shades:
    mode: single
    sequence:
      - service: switch.turn_off
        data_template:
          entity_id: "switch.{{ shade }}"
      - delay:
          milliseconds: 1000
      - service: switch.turn_off
        data_template:
          entity_id: "switch.{{ shade }}_up"
      - delay:
          milliseconds: 1000
      - service: switch.turn_on
        data_template:
          entity_id: "switch.{{ shade }}"
      - delay: 
          milliseconds: "{{ deltaporcento|int * 150 }}" # Takes 15s to open
      - service: switch.turn_off
        data_template:
          entity_id: "switch.{{ shade }}"
  stop_shades:
    sequence:
      - service: switch.turn_off
        data_template:
          entity_id: "switch.{{ shade }}"

Ok, forget about it. It was my bad understanding of state types and conversion syntax.
It had to do with value_template conditions and operations rather than Cover entities…

Can either of you guys post your now corrected, working configs, and maybe if you’re feeling super helpful an explanation of how they work? I’m trying to do the exact same thing I think. I made a microcontroller that creates auto discoverable blinds over MQTT. Everything works fine except as mentioned above - Google Home can’t control their tilt. I was going to try to expose a fake switch or something for each window and then a bunch of voice routines for each individual blind, but this solution seems more elegant if someone doesn’t mind helping explain it a little.

Technically, there may be an even easier solution to my problem, as my blinds only have tilt open or closed, no percentage position. Also, going to “open” is technically the down command because they open when they are all the way down. Whereas “closed” is the stop command, which doubles as the “favorite” command. So I’d settle for even being able to say “hey google, stop the kitchen blinds.” Unfortunately, that seems to always fail as well, because google says the blind is not in motion (regardless of whether or not it is).

Any help you guys can offer would be great, thanks!

Hi @InToSSH , I have the same problem, did you solved it.

If you have the same problem, then you’re using the wrong variable or your template is bad. No help can be provided without your configuration. It’s also best to start a new topic. When you revive old topics like this, they fall off the front page quickly unless there’s people watching the thread. This is why everyone’s question after @InToSSH’s question has gone unanswered.

Hello @drphungky and @Dreamray
I am really sorry about the delay and I know it’s probably too late, but I wanted to respond in case somebody else needs this in the future. I got caught up with a project and didn’t have much time to play with HA or monitor this forum.

This is the currently working config I am using for tilt:

- platform: template
  covers:
    living_room_cover_tilt:
      friendly_name: "Living Room Cover Tilt"
      position_template: "{{ state_attr('cover.living_room_cover', 'current_tilt_position') | int }}"
      availability_template: "{% if is_state('cover.living_room_cover', 'unavailable') %} false {% else %} true {% endif %}"
      device_class: blind
      open_cover:
        service: cover.open_cover_tilt
        data:
          entity_id: cover.living_room_cover
      close_cover:
        service: cover.close_cover_tilt
        data:
          entity_id: cover.living_room_cover
      set_cover_position:
        service: cover.set_cover_tilt_position
        data_template:
          entity_id: cover.living_room_cover
          tilt_position: "{{position}}"
4 Likes

I think I gave up on getting Google to work with tilting the blinds. Weirdly, it did work for a while, but not sure if it was my current settings or not. Maybe google home was quietly testing tilt functionality for exposed blinds, who knows. I ended up abandoning my discoverable over MQTT microcontroller and did the whole thing in ESPHome. I don’t use tilt in this file anymore, but last I recall it did work in Home Assistant - I just took the buttons off the dashboard so it matches the remote (which as I mentioned above, only has up, down, and stop buttons - tilt is just down all the way, and stop doubles as “favorite” which is closed.) Full config is below in case anyone wants to steal the format:

esphome:
  name: downstairs_esp
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: 
  password: 

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Downstairs Esp Fallback Hotspot"
    password: 

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

# Devices
remote_transmitter:
  pin: D7
  carrier_duty_percent: 100%

switch:
#Living Room Blinds
  - platform: template
    name: "Living Room Blinds Up Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: livingRoomBlindsUp
    internal: TRUE
  - platform: template
    name: "Living Room Blinds Down Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 700, -350, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: livingRoomBlindsDown
    internal: TRUE
  - platform: template
    name: "Living Room Blinds Stop Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: livingRoomBlindsStop
    internal: TRUE

#Dining Room Blinds
  - platform: template
    name: "Dining Room Blinds Up Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: diningRoomBlindsUp
    internal: TRUE
  - platform: template
    name: "Dining Room Blinds Down Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: diningRoomBlindsDown
    internal: TRUE
  - platform: template
    name: "Dining Room Blinds Stop Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: diningRoomBlindsStop
    internal: TRUE
    
#Guest Room Blinds
  - platform: template
    name: "Guest Room Blinds Up Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: guestRoomBlindsUp
    internal: TRUE
  - platform: template
    name: "Guest Room Blinds Down Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: guestRoomBlindsDown
    internal: TRUE
  - platform: template
    name: "Guest Room Blinds Stop Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: guestRoomBlindsStop
    internal: TRUE

#East Kitchen Blinds
  - platform: template
    name: "East Kitchen Blinds Up Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: eastKitchenBlindsUp
    internal: TRUE
  - platform: template
    name: "East Kitchen Blinds Down Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 700, -350, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: eastKitchenBlindsDown
    internal: TRUE
  - platform: template
    name: "East Kitchen Blinds Stop Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: eastKitchenBlindsStop
    internal: TRUE

#Kitchen Sink Blinds
  - platform: template
    name: "Kitchen Sink Blinds Up Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: kitchenSinkBlindsUp
    internal: TRUE
  - platform: template
    name: "Kitchen Sink Blinds Down Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: kitchenSinkBlindsDown
    internal: TRUE
  - platform: template
    name: "Kitchen Sink Blinds Stop Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: kitchenSinkBlindsStop
    internal: TRUE

#Master Bedroom Blinds
  - platform: template
    name: "Master Bedroom Blinds Up Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 700, -350, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
      - delay: 340ms
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
      - delay: 390ms
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: masterBedroomBlindsUp
    internal: TRUE
    
  - platform: template
    name: "Master Bedroom Blinds Down Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
      - delay: 340ms
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
      - delay: 390ms
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: masterBedroomBlindsDown
    internal: TRUE
    
  - platform: template
    name: "Master Bedroom Blinds Stop Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: masterBedroomBlindsStop
    internal: TRUE

#Kids Room Blinds
  - platform: template
    name: "Kids Room Blinds Up Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 700, -350, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
      - delay: 340ms
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
      - delay: 390ms
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 700, -350, 700, -350, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: kidsRoomBlindsUp
    internal: TRUE
    
  - platform: template
    name: "Kids Room Blinds Down Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
      - delay: 340ms
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
      - delay: 390ms
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: kidsRoomBlindsDown
    internal: TRUE
    
  - platform: template
    name: "Kids Room Blinds Stop Switch"
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [3850, -2450, 1750, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 700, -350, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 350, -700, 700, -350, 350, -700, 350, -700, 700, -350, 700, -350, 700, -350, 1750]
          repeat:
            times: 8
            wait_time: 0s
    id: kidsRoomBlindsStop
    internal: TRUE
    
    
cover:
  - platform: template
    name: "Living Room Blinds"
    open_action:
      - switch.turn_on: livingRoomBlindsUp
    close_action:
      - switch.turn_on: livingRoomBlindsStop
    stop_action:
      - switch.turn_on: livingRoomBlindsStop
    tilt_action:
      - lambda: |-
          if (tilt <= 0.5) {
            id(livingRoomBlindsStop).turn_on();
            }
          else {
            id(livingRoomBlindsDown).turn_on();
          }
    assumed_state: true
    device_class: blind

  - platform: template
    name: "Dining Room Blinds"
    open_action:
      - switch.turn_on: diningRoomBlindsUp
    close_action:
      - switch.turn_on: diningRoomBlindsStop
    stop_action:
      - switch.turn_on: diningRoomBlindsStop
    tilt_action:
      - lambda: |-
          if (tilt <= 0.5) {
            id(diningRoomBlindsStop).turn_on();
            }
          else {
            id(diningRoomBlindsDown).turn_on();
          }
    assumed_state: true
    device_class: blind

  - platform: template
    name: "Guest Room Blinds"
    open_action:
      - switch.turn_on: guestRoomBlindsUp
    close_action:
      - switch.turn_on: guestRoomBlindsStop
    stop_action:
      - switch.turn_on: guestRoomBlindsStop
    tilt_action:
      - lambda: |-
          if (tilt <= 0.5) {
            id(guestRoomBlindsStop).turn_on();
            }
          else {
            id(guestRoomBlindsDown).turn_on();
          }
    assumed_state: true
    device_class: blind

  - platform: template
    name: "East Kitchen Blinds"
    open_action:
      - switch.turn_on: eastKitchenBlindsUp
    close_action:
      - switch.turn_on: eastKitchenBlindsStop
    stop_action:
      - switch.turn_on: eastKitchenBlindsStop
    tilt_action:
      - lambda: |-
          if (tilt <= 0.5) {
            id(eastKitchenBlindsStop).turn_on();
            }
          else {
            id(eastKitchenBlindsDown).turn_on();
          }
    assumed_state: true
    device_class: blind

  - platform: template
    name: "Kitchen Sink Blinds"
    open_action:
      - switch.turn_on: kitchenSinkBlindsUp
    close_action:
      - switch.turn_on: kitchenSinkBlindsStop
    stop_action:
      - switch.turn_on: kitchenSinkBlindsStop
    tilt_action:
      - lambda: |-
          if (tilt <= 0.5) {
            id(kitchenSinkBlindsStop).turn_on();
            }
          else {
            id(kitchenSinkBlindsDown).turn_on();
          }
    assumed_state: true
    device_class: blind

  - platform: template
    name: "Master Bedroom Blinds"
    open_action:
      - switch.turn_on: masterBedroomBlindsUp
    close_action:
      - switch.turn_on: masterBedroomBlindsStop
    stop_action:
      - switch.turn_on: masterBedroomBlindsStop
    tilt_action:
      - lambda: |-
          if (tilt <= 0.5) {
            id(masterBedroomBlindsStop).turn_on();
            }
          else {
            id(masterBedroomBlindsDown).turn_on();
          }
    assumed_state: true
    device_class: blind

  - platform: template
    name: "Kids Room Blinds"
    open_action:
      - switch.turn_on: kidsRoomBlindsUp
    close_action:
      - switch.turn_on: kidsRoomBlindsStop
    stop_action:
      - switch.turn_on: kidsRoomBlindsStop
    tilt_action:
      - lambda: |-
          if (tilt <= 0.5) {
            id(kidsRoomBlindsStop).turn_on();
            }
          else {
            id(kidsRoomBlindsDown).turn_on();
          }
    assumed_state: true
    device_class: blind

This is what I did in ESPHome, which is running on Shelly 2.5, which is connected directly in place of my previous up/down buttons on my blind. This exposes the cover with tilt in my HA, then I separated the tilt to separate cover using the code above and I am using it as a separate cover in Google Home to control the tilt with my voice.


globals:
  - id: cover_moving #This is for the HW buttons to determine if a press should stop the blind or start moving it (this could probably be done without this var by reading id(time_cover).current_operation)
    type: bool
    initial_value: "0"

cover:
  - platform: time_based # Time based cover to track the position of the blind based on the time (unfortunatelly this doesn't support tilt)
    name: ${device_name} - Time Cover
    internal: True
    id: time_cover
    has_built_in_endstop: True # The controller in my blind automatically stops the motor in it's endpoints, this is set to True to be able to synchronize the zero position based on time with the actual position when the blind is either fully closed or open
                               # The power meter in the Shelly2.5 is then used to determine when the blind has stopped, sending a "cover.stop" action to this cover.
    open_action:
      - globals.set:
          id: cover_moving
          value: "true"
      - script.execute: detect_endpoint
      - switch.turn_off: motor_down
      - switch.turn_on: motor_up
    open_duration: 54sec # Set the correct time for your specific blind

    close_action:
      - globals.set:
          id: cover_moving
          value: "true"
      - script.execute: detect_endpoint
      - switch.turn_off: motor_up
      - switch.turn_on: motor_down
    close_duration: 53sec # Set the correct time for your specific blind

    stop_action:
      - globals.set:
          id: cover_moving
          value: "false"
      - script.stop: detect_endpoint
      - switch.turn_off: motor_up
      - switch.turn_off: motor_down
      
  - platform: template # Template cover which synchronizes position with the time_cover, but also supports tilt.
    name: ${device_name}
    id: template_cover
    lambda: |-
      if (id(template_cover).current_operation != id(time_cover).current_operation)
      {
        id(template_cover).current_operation = id(time_cover).current_operation;
      }
      return id(time_cover).position;
    has_position: true
    assumed_state: True
    open_action: 
      - cover.open: time_cover
    close_action:
      - cover.close: time_cover
    stop_action:
      - cover.stop: time_cover
    position_action:
      - cover.control:
          id: time_cover
          position: !lambda |-
            return pos;
    tilt_action:
      - lambda: |-
          if (tilt == 1) {
            auto call1 = id(time_cover).make_call();
            call1.set_command_open();
            call1.perform();
            delay(1000);
            auto call2 = id(time_cover).make_call();
            call2.set_command_stop();
            call2.perform();
            
          } else if (tilt == 0) {
            auto call1 = id(time_cover).make_call();
            call1.set_command_close();
            call1.perform();
            delay(1000);
            auto call2 = id(time_cover).make_call();
            call2.set_command_stop();
            call2.perform();
            
          } else {
            if (tilt > 0.5) {
              auto call1 = id(time_cover).make_call();
              call1.set_command_open();
              call1.perform();
              delay(1000);
              auto call2 = id(time_cover).make_call();
              call2.set_command_stop();
              call2.perform();
              delay(500);
              auto call3 = id(time_cover).make_call();
              call3.set_command_close();
              call3.perform();
              delay(1000 - (tilt*1000) + 50);
              auto call4 = id(time_cover).make_call();
              call4.set_command_stop();
              call4.perform();
              
            }
            if (tilt <= 0.5) {
              auto call1 = id(time_cover).make_call();
              call1.set_command_close();
              call1.perform();
              delay(1000);
              auto call2 = id(time_cover).make_call();
              call2.set_command_stop();
              call2.perform();
              delay(500);
              auto call3 = id(time_cover).make_call();
              call3.set_command_open();
              call3.perform();
              delay(tilt*1000 + 200);
              auto call4 = id(time_cover).make_call();
              call4.set_command_stop();
              call4.perform();
              
            }
          }
          
          
          id(template_cover).tilt = tilt;
          id(template_cover).publish_state();

script:
  - id: detect_endpoint # Used to detect the endpoint of the blind based on the power draw, the blind automatically stops in it's endpoints, this might not be needed, but I don't like the idea of leaving the relay on when "has_built_in_endstop" is used on the cover.
    then:
      - delay: 5sec
      - wait_until:
          sensor.in_range:
            id: power_down
            below: 20
      - wait_until:
          sensor.in_range:
            id: power_up
            below: 20
            
      - cover.stop: template_cover
        
        
switch:
  - platform: gpio 
    pin: 4
    name: ${device_name} - Motor UP
    id: motor_up
    interlock: [motor_down]
    interlock_wait_time: 100ms
    internal: true
    restore_mode: always off
  - platform: gpio 
    pin: 15
    name: ${device_name} - Motor DOWN
    id: motor_down
    interlock: [motor_up]
    interlock_wait_time: 100ms
    internal: true
    restore_mode: always off
    
binary_sensor:
  - platform: gpio # Physical button on the wall to move the blind UP
    pin: 5
    name: ${device_name} - Button UP
    on_press:
      then:
        - if:
            condition:
              lambda: 'return !id(cover_moving);'
            then:
              - cover.open: template_cover

    on_click:
      - min_length: 1ms
        max_length: 999ms
        then:
          - cover.stop: template_cover

          
  - platform: gpio # Physical button on the wall to move the blind DOWN
    pin: 13
    name: ${device_name} - Button DOWN
    on_press:
      then:
        - if:
            condition:
              lambda: 'return !id(cover_moving);'
            then:
              - if:
                  condition:
                    binary_sensor.is_off: ha_covers_blocked
                  then:
                    - cover.close: template_cover
              
    on_click:
      - min_length: 1ms
        max_length: 999ms
        then:
          - cover.stop: template_cover
          
  - platform: homeassistant
    name: ${device_name} - HA Covers Blocked
    entity_id: input_boolean.covers_blocked
    id: ha_covers_blocked
    
  - platform: homeassistant
    name: ${device_name} - HA UP
    entity_id: input_boolean.momentary_up
    internal: true
    on_press:
      then:
        - if:
            condition:
              lambda: 'return !id(cover_moving);'
            then:
              - cover.open: template_cover

    on_click:
      - min_length: 1ms
        max_length: 999ms
        then:
          - cover.stop: template_cover
    
  - platform: homeassistant
    name: ${device_name} - HA DOWN
    internal: true
    entity_id: input_boolean.momentary_down
    on_press:
      then:
        - if:
            condition:
              lambda: 'return !id(cover_moving);'
            then:
              - cover.close: template_cover
              
    on_click:
      - min_length: 1ms
        max_length: 999ms
        then:
          - cover.stop: template_cover

sensor:          

  - platform: ade7953
    voltage:
      name: ${device_name} - Voltage
    current_a:
      name: ${device_name} - Current Down
      internal: True
    current_b:
      name: ${device_name} - Current Up
      internal: True
    active_power_a:
      name: ${device_name} - Power Down
      id: power_down
    active_power_b:
      name: ${device_name} - Power Up
      id: power_up
      filters:
        - multiply: -1
    update_interval: 3s

This worked perfectly! Thank you!
I have the Z-Wave iBlinds 3 which work great within Home Assistant but where exposed to Google Assistant as unavailable.

I installed your template and after a quick HA restart, I had working blinds in Google Home app/Google Assistant.

For reference, here is what the state and attributes of the original iBlinds entity (top) looks like compared to the newly created cover template (bottom):

Hello @InToSSH, I am trying to find a solution about a similar issue. Can you look at the coding below and find a solution for me?

In the smart curtain system I have been using for a long time, I can only raise and lower the curtain. But when the power is cut off, I want the motor to remember where it left off and continue. Plus I want to be able to raise and lower the curtain to the desired %. Can you help me with this?

My tools in the curtain system.
Nema 17 stepper motor
A4988 motor driver board
Esp32-wroom-32 programming board
LM2596 Regulator
3 buttons
DC 12v adapter

Self-prepared coding

substitutions:
  devicename: yatakodasiperde
  mystepper: my_stepper
  speed: 1200 steps/s

esphome:
  name: $devicename
  platform: ESP32
  board: nodemcu-32s
  libraries:
    - EEPROM

# Enable logging
logger:
  level: DEBUG
  logs:
    esphome.core: DEBUG
    esphome.components: DEBUG

# Enable Home Assistant API
api:
  services:
  - service: control_stepper
    variables:
      target: int
    then:
      - stepper.set_target:
          id: my_stepper
          target: !lambda 'return target;'
ota:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
  manual_ip:
    static_ip: 192.168.1.69
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    dns1: 192.168.1.1

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Akilli Perde"
    password: "password"
  
captive_portal:

web_server:
  port: 80

stepper:
  - platform: a4988
    id: $mystepper
    step_pin: GPIO19
    dir_pin:
      number: GPIO18
      inverted: true
    max_speed: ${speed}
    acceleration: inf
    deceleration: inf

sensor:
  - platform: wifi_signal
    name: "WiFi Sinyali yatakodasiperde"
    update_interval: 60s

text_sensor:
  - platform: wifi_info
    ip_address:
      icon: "mdi:ip"
      name: "IP yatakodasiperde"
    ssid:
      name: "SSID yatakodasiperde"
      icon: "mdi:access-point-network"
    bssid:
      name: "BSSID yatakodasiperde"
      icon: "mdi:access-point-network"

output:
  - platform: gpio
    pin: GPIO21
    inverted: true
    id: enable_pin

binary_sensor:
  - platform: gpio
    id: perde_kaldirma_button
    name: Perdeyi kaldir
    pin:
      number: GPIO12
      mode: INPUT_PULLUP
      inverted: true
    on_press:
      then:
        - output.turn_on: enable_pin
        - if:
            condition:
              lambda: 'return id($mystepper).current_position != 35000;'
            then:
              - stepper.set_target:
                  id: $mystepper
                  target: 35000
              - delay: 1ms
              - while:
                  condition:
                    lambda: 'return id($mystepper).current_position != 35000;'
                  then:
                    - delay: 1ms
        - delay: 1ms
        - output.turn_off: enable_pin

  - platform: gpio
    id: perde_indirme_button
    name: Perdeyi indir
    pin:
      number: GPIO13
      mode: INPUT_PULLUP
      inverted: true
    on_press:
      then:
        - output.turn_on: enable_pin
        - if:
            condition:
              lambda: 'return id($mystepper).current_position != 0;'
            then:
              - stepper.set_target:
                  id: $mystepper
                  target: 0
              - delay: 1ms
              - while:
                  condition:
                    lambda: 'return id($mystepper).current_position != 0;'
                  then:
                    - delay: 1ms
        - delay: 1ms
        - output.turn_off: enable_pin
        - cover.template.publish:
            id: blinded
            position: !lambda 'return id($mystepper).current_position;'

  - platform: gpio
    id: perde_durdurma_button
    name: Perdeyi durdur
    pin:
      number: GPIO14
      mode: INPUT_PULLUP
      inverted: true
    on_press:
      then:
        - output.turn_off: enable_pin
        - stepper.set_target:
            id: $mystepper
            target: !lambda 'return id($mystepper).current_position;'

cover:
  - platform: template
    name: Yatakodasi-Perde
    id: blinded

    open_action:
      - output.turn_on: enable_pin
      - if:
          condition:
            lambda: 'return id($mystepper).current_position != 35000;'
          then:
            - stepper.set_target:
                id: $mystepper
                target: 35000
            - delay: 1ms
            - while:
                condition:
                  lambda: 'return id($mystepper).current_position != 35000;'
                then:
                  - delay: 1ms
      - delay: 1ms
      - output.turn_off: enable_pin

    close_action:
      - output.turn_on: enable_pin
      - if:
          condition:
            lambda: 'return id($mystepper).current_position != 0;'
          then:
            - stepper.set_target:
                id: $mystepper
                target: 0
            - delay: 1ms
            - while:
                condition:
                  lambda: 'return id($mystepper).current_position != 0;'
                then:
                  - delay: 1ms
      - delay: 1ms
      - output.turn_off: enable_pin

    stop_action:
      - output.turn_off: enable_pin
      - stepper.set_target:
          id: $mystepper
          target: !lambda 'return id($mystepper).current_position;'
      - cover.template.publish:
          id: blinded
          position: !lambda 'return id($mystepper).current_position;'