Switch as toggle to control shades/blinds

I built my own automated windows shades a couple years ago, using cheap tube motors, aluminum tubes, and dual relay modules from sonoff. You can use just about anything, but I used these or similar relays with a simple 3D printed wall mount enclosure I designed, these exact motors (although others would work as well), tubes from some place that specialized in projector screens and sent them cut to length, and cheap-o power bricks.

I wanted to be able to control them from an unused gang on a multi-gang wall switch, or from a lovelace button (via input_boolean). Tap to move them. Tap to stop them if they’re moving.

Originally, I was running them with 5 separate automations for each window, because I had no idea what I was doing. I eventually figured out if/then templating well enough to get them condensed into 1 per window, and now generalized into a blueprint.

You’ll need an up entity, a down entity, whatever switch or boolean entity you want to use as a push-button, and an input_boolean to store the state.

You’ll also need to make sure the motor you’re using allows you to set stop points at the motor. (most of them do, but not all) and you’ll want to turn on the inching function in ewelink, tuya, or whatever else you’re using, set to just a little longer than they take to open/close.

I’m sure it could be modified to include stop points, handle non-interlocking relays, or time out the relays if they don’t support inching, but it’s complicated enough as it is for me, and works with my hardware.

blueprint:
  name: Dual Relay blinds control
  description: "# Dual Relay Blinds/Shades control

    Allows control of blinds, shades or other cover-like mechanisms that are driven
    by an interlocking dual relay device, where only one relay can be on at a time.


    These devices are readily availalble from multiple manufacturers.


    The dual relay device also needs an inching function for the best functionality.
    That way the switch entities will turn themselves off when idle, and you can save
    button presses or switch clicks.


    The motor for your blinds needs to stop at set points automatically. This is the
    case with most cheap DC tube motors for shades you would order online.


    ## Configuration requires 4 entities:

    + One switch entity for up/open

    + One switch entity for down/close

    + An input_boolean for the current state/last move (on is up/open, off is down/closed).

    + An entity which will act as a momentary switch to open, close, or stop the blinds.
    A switch or input_boolean is recommended.


    ## Function:

    + If the relays are both off, the shades will move in the oposite direction from
    their last move, and the state boolean will be updated.

    + If either the up switch or down switch is on, it will turn both off "
  domain: automation
  input:
    up_entity:
      name: Up/Open
      description: The switch entity that raises/opens your shades.
      selector:
        entity:
          domain: switch
    down_entity:
      name: Down/Close
      description: The switch entity that lowers/closes your shades.
      selector:
        entity:
          domain: switch
    blinds_switch_entity:
      name: Control Entity
      description:
        Switch, input_boolean, or other entity with on and off states which
        will act as a momentary button to open, close, and stop your blinds.
      selector:
        entity: {}
    state_boolean:
      name: State Boolean
      description:
        You must create and specify an input_boolean to store the state
        of your shade/blind.
      selector:
        entity:
          domain: input_boolean
  source_url: https://community.home-assistant.io/t/dual-relay-blinds-shades-motor-control/289662
variables:
  upe: !input "up_entity"
  dne: !input "down_entity"
  bsw: !input "blinds_switch_entity"
  sbl: !input "state_boolean"
trigger:
  - platform: state
    entity_id: !input "blinds_switch_entity"
    from: "off"
    to: "on"
action:
  - service: homeassistant.turn_off
    entity_id: !input "blinds_switch_entity"

  - service: switch.turn_on
    data_template:
      entity_id:
        "{% if states(upe) == 'off' and states(dne) == 'off' and states(sbl)
        == 'off'%} {{ upe }} {% else %} none {% endif %}

        "
  - service: switch.turn_on
    data_template:
      entity_id:
        "{% if states(upe) == 'off' and states(dne) == 'off' and states(sbl)
        == 'on'%} {{ dne }} {% else %} none {% endif %}

        "
  - service: switch.turn_off
    data_template:
      entity_id: "{% if states(upe) == 'on' or states(dne) == 'on' %} {{ upe }},
        {{ dne }} {% else %} none {% endif %}

        "
  - delay: 0.5
  - service: input_boolean.toggle
    data_template:
      entity_id: "{% if states(upe) == 'on' or states(dne) == 'on' %} {{ sbl }}
        {% else %} none {% endif %}

        "
mode: queued

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

1 Like

Re-wrote post to make better use of formatting and put the description at the top. Also, here’s the in-blueprint description:

Dual Relay Blinds/Shades control

Allows control of blinds, shades or other cover-like mechanisms that are driven by an interlocking dual relay device, where only one relay can be on at a time.

These devices are readily availalble from multiple manufacturers.

The dual relay device also needs an inching function for the best functionality. That way the switch entities will turn themselves off when idle, and you can save button presses or switch clicks.

The motor for your blinds needs to stop at set points automatically. This is the case with most cheap DC tube motors for shades you would order online.

Configuration requires 4 entities:

  • One switch entity for up/open
  • One switch entity for down/close
  • An input_boolean for the current state/last move (on is up/open, off is down/closed).
  • An entity which will act as a momentary switch to open, close, or stop the blinds. A switch or input_boolean is recommended.

Function:

  • If the relays are both off, the shades will move in the oposite direction from their last move, and the state boolean will be updated.
  • If either the up switch or down switch is on, it will turn both off
1 Like