Connect sensor to cover

Hi there,

I have a new sensor it is already in HA and I want to say that when the door sensor is open, the garage door is also open. The garage door is the cover in this case.

The problem now is when I’m opening the garage door it continu says opening because there is no sensor. With this door sensor I’ve tried this with an automation, a value template, … but in al of those cases it creates a whole new “device” or “Entity” but that is not what I want.

I just want to let the sensor say “Ok the door is open”, “door is closed”. It’s a magnetic door sensor. And that my existing garage door get the state of the sensor.

Hopefully someone can help me.

Thanks.

I think you’re going to have to wrap those in another entity though with something like

Yes it will create a new entity which can use the sensor and the existing cover underneath.

Hi Calisro,

cover:
  - platform: template
    covers:
      garage_poort:
        device_class: garage
        friendly_name: "Garage poort"
        value_template: "{{ is_state('binary_sensor.contact_sensor', 'on') }}"
        open_cover:
          service: switch.turn_on
          entity_id: switch.garage_poort
        close_cover:
          service: switch.turn_on
          entity_id: switch.garage_poort
        stop_cover:
          service: switch.turn_on
          entity_id: switch.garage_poort

This is what I have, this works roughly. It is possible to open the garage door but not to close.

Now I have changed my switch.garage_poort with a “helper” to a cover. But this won’t work either…

Shouldn’t the value template be:

value_template: "{{ states('binary_sensor.contact_sensor') }}"

I could very well be misunderstanding the issue.

When the sensor is on, the garage is open. When it is off the garage is closed. Then the open and close should work right.

Just tried this but now the garage door is open or the start state is open, even when it is close. and the sensor is also closed.

It’s a very complex thing. because now when I’m opening the garage door, the switch stays active. So I need to deactivate the switch again, and after that I’m able to close to garage door. So for the full open/close movement I need 4 presses. 1 to open, 1 to deactivate the switch, 1 to close, 1 to deactivate the switch. Because I’m using the original switch now in my value template…

Not really. You need to call scripts instead of teh switches directly. The script would turn the switch on to open the garage and then turn off the switch immediately so it is always in the off position.

Alternatively, you can create an automation that just turns the switch off every time it turns on.

And is there any chance you could help me with this? Never used scripts in HA.

I’ve already tried this with an automation, but this also creates a new entity… And to be honest, the knowledge to achieve this with an automation/script, I don’t have this. It is very much copy paste from the internet and hopefully some code works…

alias: Garage Poort Action
sequence:
  - service: switch.turn_on
    entity_id: switch.garage_poort
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: switch.turn_off
    entity_id: switch.garage_poort
mode: single

It really should be as simple as that. THen call that script from the cover template for both open and close. Its essentially a toggle at this point.

So this I need to paste in…? If I navigate to scripts there is no area to type some code…

And how can I call the script in my configuration.yaml file?

in the scripts.yaml file probably?

alternatively, you can just use an automation to just turn it off every time it gets turned on:

alias: Garage Poort turn off
description: ''
mode: single
trigger:
  - platform: state
    entity_id:
      - switch.garage_poort
    to: 'on'
    for:
      hours: 0
      minutes: 0
      seconds: 1
condition: []
action:
  - service: homeassistant.turn_off
    data: {}
    target:
      entity_id: switch.garage_poort

Then you don’t even need to change what you have in your configuration file for hte cover.

Jsut create this automation above and see how it works when you open/close the garage now.

In both the scripts or automations, you can create a new one and then just in the 3 dots in the right corner select ‘edit in yaml’ then paste it.

Yes indeed, just saw this. Ok let me try this!

Already many thanks for this help!

Hi Calisro,

This works surprisingly very well! The button is indeed deactivate automatically after 1 sec! Just a little remarks and maybe you can help me with this, the sensor don’t work now for the state. So even when the sensor is open/close the door won’t get that state…

Hi Calisro,

I’m excited to tell that your solution works. It was because I changed the line of the value template. I’ve set it back to the original line of me and now everything works as it should be!

Many thanks for this help, was looking for ages for this! Can I hide the automation, so that it is working always but I don’t see the rule or icon, everything from HA is connected with the homekit integration. So in homekit I now have an extra icon to turn on/off this automation… Don’t need this of course in homekit…

I don’t use homekit. But you can exclude items.

See:


homekit:
  filter:
    exclude_entities:
      - automation.garage_poort_turn_off

Untested btw. Just typed from the example…You probably can also exclude your switches and all and just keep the new cover template entity.

I personally rather use ‘includes’ rather than ‘excludes’ for things like this so I can control what gets automatically pushed into other systems as I create new things. But this will require you to look at what you need in homekit and add includes for all of them.

1 Like