Best way to disable "cover open" when alarm is armed

Hi guys,

i’m trying to find a solution to avoid accidentally cover open when security alarm is armed (away or night).
One solution looks at create a template cover (and export them on GA\Alexa\HomeKit instead of real cover) and for the open action use a script that check the status of the alarm and avoid accidentally open.

Did you know if there is another “smart” solution?

Thanks in advance!

But i’m not using the Lovelance UI, as I’ve said I need to avoid accidentally open from Alexa\Google\Homekit

Hi Stich86,

are you able to “monitor” the cover states within HA also when triggerd by 3rd party Alexa,Google and Homekit?
If so have a automation monitor the states and if it changes even when “alarm ist still in armed mode” then let it close the cover in question again and let it inform you… on your desired media.

this would be one of many options but it really depends on what “covers” you are using.

Can you give us a little more info on your setup?

Kind regards,
Dieter

Yes I’m using Shellies 2.5 in roller mode over MQTT. The problem is that I don’t want to open rollers when alarm is armed to avoid alarm trigger (I’ve sensor on each roller to avoid raise up)

Thanks

Rather than exposing the cover to HomeKit you could expose a script that opens the cover. Include a condition in the script that the alarm must be off.

yes one of the options

  • I would go with tom_I option.

but i want to expose as a cover and not as a switch, and the problem is also related to GA\Alexa.

I’m trying to do a “Template Cover” using a script but i’ve a problem on the open part. I want to use just a single script and pass the entity_id based on the roller shutter, but it doesn’t work. Here is the configuration:

cover:
  - platform: template
    covers:
      tapparella_test:
        device_class: blind
        friendly_name: "Tapparella Test Allarme"
        value_template: "{{ states('cover.shelly2_5_bcddc277b83e_roller_0') }}"
        position_template: "{{ state_attr("cover.shelly2_5_bcddc277b83e_roller_0", "current_position") }}"
        open_cover:
          service: script.open_cover
          data:
            cover_name: cover.shelly2_5_bcddc277b83e_roller_0 <-- this should be passed to the script
        close_cover:
          service: cover.close_cover
          data:
            entity_id: cover.shelly2_5_bcddc277b83e_roller_0
        stop_cover:
          service: cover.stop_cover
          data:
            entity_id: cover.shelly2_5_bcddc277b83e_roller_0          
        set_cover_position:
          service: cover.set_cover_position
          data
            entity_id: cover.shelly2_5_bcddc277b83e_roller_0
            position: "{{ position }}"

and this is the script:

open_cover:
  alias: Apri Tapparella - ALAMAR_DISARMED
  mode: parallel
  sequence:
  - condition: state
    entity_id: alarm_control_panel.allarme
    state: disarmed
  - data:
      entity_id: cover.{{ cover_name }}
    service: cover.open_cover
  max: 10

But when calling this script from the developer page, passing as parameter this:

data:
   cover_name: cover.shelly2_5_bcddc277b83e_roller_0

I got this error:

voluptuous.error.MultipleInvalid: not a valid value for dictionary value @ data['entity_id']

Any hints?

Thanks in advance!

If you use the script.turn_on service you need to use the variables: key. See: https://www.home-assistant.io/integrations/script/#passing-variables-to-scripts

If you call the script directly as a service you don’t have to use variables: but there are other issues with doing that. See https://www.home-assistant.io/integrations/script/#waiting-for-script-to-complete

i’m not using “variables:” because calling the script directly

Try this:

open_cover:
  alias: Apri Tapparella - ALAMAR_DISARMED
  mode: parallel
  sequence:
  - condition: state
    entity_id: alarm_control_panel.allarme
    state: disarmed
  - data_template:
      entity_id: "cover.{{ cover_name }}"
    service: cover.open_cover
  max: 10

still the same error :frowning:

ok i’ve finally solved :slight_smile:

here is final configuration

- platform: template
  covers:
    tapparella_salone_l:
      device_class: shutter
      friendly_name: "Tapparella Salone Lunga"
      position_template: '{{ state_attr("cover.shelly2_5_bcddc277b83e_roller_0", "current_position") }}'
      open_cover:
        service: script.open_cover
        data:
          cover_name: cover.shelly2_5_bcddc277b83e_roller_0
      close_cover:
        service: cover.close_cover
        data:
          entity_id: cover.shelly2_5_bcddc277b83e_roller_0
      stop_cover:
        service: cover.stop_cover
        data:
          entity_id: cover.shelly2_5_bcddc277b83e_roller_0
      set_cover_position:
        service: cover.set_cover_position
        data_template:
          entity_id: cover.shelly2_5_bcddc277b83e_roller_0
          position: "{{ position }}"

and script:

open_cover:
  alias: Apri Tapparella - ALAMAR_DISARMED
  mode: parallel
  sequence:
  - condition: state
    entity_id: alarm_control_panel.allarme
    state: 'disarmed'
  - data_template:
      entity_id: '{{ cover_name }}'
    service: cover.open_cover
  max: 10

I think i’ll do the same also for close (in case a cover is opened)

thanks for the help!

i think it’s not working as intended…
the open\close now works executing the script, but the problem is that the condition is not honored and also if the alarm is not in “disarmed” state, the script still execute calls to open\close cover services.

Any hints?

thanks!

ok… it looks like that state is matched only from Lovelace UI, but not from HA\GH or Alexa.
Is it normal?

EDIT: i’ve found that HA\GH\Alexa are using “set_cover_position” and not “open\close”, putting another script using the same approach make it working as expected