Correct "state" syntax for automation trigger?

Hi there,

I’m using the “cover” component to control my garage door opener and would like to use the “state” of that component to trigger my alarm. So for example, how should my automation.yaml be set up to arm/disarm my alarm based on the door’s state changing from open to closes or vice versa? What I’m been trying is the following, but it’s not working.

- id: '1565856716161'
  alias: Garage Alarm Trigger
  trigger:
  - entity_id: cover.door_1
    from: state_closed
    platform: state
    to: state_open
  condition: []
  action:
  - service: alarm_control_panel.alarm_disarm

TIA!

from: closed
to: open
1 Like

^^ that

Whenever you’re testing the value of state, find the entry in the States part of the Developer Tools to confirm the actual name of the state and enclose it in quotes to avoid having it be misinterpreted. Using a prefix of “state_” doesn’t mean anything in Home Assistant.

1 Like

Also from: is rarely needed and can introduce errors.

1 Like

A Thanks guys. I know it’s because I’m new to these systems, but I’m having a hard time finding a good tutorial on how everything Is structured beyond specific component examples. Is there an in depth guide, geared at learning the fundamentals so I’d know how to structure any service, script, automation? I’ll keep digging but feel like I missed the basics haha.

Look at the top of this page. Click on Docs. Read all the pages.

1 Like