Is there a way to disable 'cover down' if the window is open?

Hi All

I’ve created this nifty illustration of the state of a window. The window also has a blind, but if the window is open, the blind shouldn’t close as that will mess it up.
So I was wondering if there was a way to disable that?
It’s not a problem to roll the blind up if the window is open, so I can’t just make a conditional and hide the ‘cover’ controls.

cards:
  - type: entities
    entities:
      - entity: cover.rullegardin_i_sovevaerelse
  - entity: binary_sensor.bedroomwindow
    image: /local/samsung0.jpg
    show_name: false
    show_state: false
    state_image:
      'off': /local/window/close.png
      'on': /local/window/open.png
    type: picture-entity
type: vertical-stack

1 2

sorry maybe you find some additional words to describe your Problem?

The only way I could see this working is if you take your existing cover and make it into a cover template.

The down script would have a condition built into it that would check the state of the window. The button would still appear to work but it would do nothing.

2 Likes

Ahh, I’ve never stumbled on that one, that would be ok I guess, that it just doesn’t work :slight_smile:
Will it update the position during movement like the normal cover controls?

Yes, you just have to build it that way. It’s like creating any other template device in home assistant.

1 Like

I’ll try and get it done in the weekend and post it here then :slight_smile:

Did you get to the bottom of this? I have the same problem, but with roller shutters (so there’s serious damage to be done).

I use MQTT covers, so I was thinking of just doing it via ‘availability’ messages (i.e. if the window is open, an automation runs to publish an ‘unavailable’ message to my roller shutters).

No, I didn’t I left it as is, and posted it in the WTH, but there wasn’t enough votes for it :slight_smile:

Actually, an update 20 minutes later - it’s really easy with MQTT covers and problem solved.

I can just publish an online/offline message to my cover whenever I want with an automation.

2 Likes

I moved the covers to deconz, and in there I could control it, as the remote wasn’t tied directly to the cover.
Unfortunately I had to give up on deconz for that, as the covers constantly lost connection, and had to move two covers back to IKEA, and in there the controller is tied directly to covers.
I’m trying to use the template cover thing to see if that can work, which it should in theory for anything ELSE than the remote itself…

I’m trying to build the template cover, so it matches the normal cover as much as possible.
For now, I’m just trying to set the template so it uses the same logics as the built-in.
The open/close/stop works fine, but the set_position gives me an error when I press a position on the ‘horizontal position bar’:

My definition looks like this:

# Example configuration.yaml entry
  - platform: template
    covers:
      livingroom_cover:
        device_class: blind
        friendly_name: "Stue rullegardin"
        position_template: "{{ state_attr('cover.livingroom_cover_small', 'current_position' ) | int }}"
        open_cover:
          service: cover.open_cover
          data:
            entity_id: cover.livingroom_cover_small
        close_cover:
          service: cover.close_cover
          data:
            entity_id: cover.livingroom_cover_small
        stop_cover:
          service: cover.stop_cover
          data:
            entity_id: cover.livingroom_cover_small
        set_cover_position:
          service: cover.set_cover_position
          data:
            entity_id: cover.livingroom_cover_small
            position: "{{position}}"

I have no idea how to get the value from the bar, except in the docs examples it shows the value as position: "{{position}}".

try casting it as an int. |int. If you’re not on 0.115 you need to use data_template instead of data.

1 Like

That worked, thanks @petro, you are a star!

# Example configuration.yaml entry
  - platform: template
    covers:
      livingroom_cover:
        device_class: blind
        friendly_name: "Stue rullegardin"
        position_template: "{{ state_attr('cover.livingroom_cover_small', 'current_position' ) | int }}"
        open_cover:
          service: cover.open_cover
          data:
            entity_id: cover.livingroom_cover_small
        close_cover:
          service: cover.close_cover
          data:
            entity_id: cover.livingroom_cover_small
        stop_cover:
          service: cover.stop_cover
          data:
            entity_id: cover.livingroom_cover_small
        set_cover_position:
          service: cover.set_cover_position
          data_template:
            entity_id: cover.livingroom_cover_small
            position: "{{position | int}}"

And yes, I’m not on .115 yet.

1 Like

This architecture discussion would be related if anyone is still interested in this Add locked state to Cover · Discussion #545 · home-assistant/architecture · GitHub

Could you please share your final yaml code with the template cover along with the window open then disable close_cover logic integrated? :slight_smile:

1 Like

Sure thing! Could get fancier with the below and delays etc, but I don’t think it will ever be an issue with my use case.

  - alias: Disable shutters on window open
    initial_state: 'on'    
    trigger:
      platform: mqtt
      topic: /server/kitchenwindows
      payload: "Open"
    action:
      service: mqtt.publish
      data:
        topic: "/server/shutteravailability"
        payload: "offline"
        retain: true

  - alias: Enable shutters on window closed
    initial_state: 'on'    
    trigger:
      platform: mqtt
      topic: /server/kitchenwindows
      payload: "Closed"
    action:
      service: mqtt.publish
      data:
        topic: "/server/shutteravailability"
        payload: "online"   
        retain: true   


  - alias: Enable windows on shutter open
    initial_state: 'on'    
    trigger:
      - platform: mqtt
        topic: /server
        payload: "benchup"
      - platform: mqtt
        topic: /server
        payload: "kitchenup"   
    action:
      service: mqtt.publish
      data:
        topic: "/server/windowavailability"
        payload: "online"
        retain: true    
        
  - alias: Disable windows on shutter close
    initial_state: 'on'    
    trigger:
      - platform: mqtt
        topic: /server
        payload: "benchdown"
      - platform: mqtt
        topic: /server
        payload: "kitchendown"   
    action:
      service: mqtt.publish
      data:
        topic: "/server/windowavailability"
        payload: "offline"
        retain: true          
1 Like