Create antomation to change state

Hi everyone, i have an unusual request.

I am setting up an alarm in home assistant but here is my problem

I want that when arming the system, if a door is left open the state changes to pending and stays on pending.

The reason for this is i will have a second automation that starts when the state on pending.

This second automation will then look at the pending state and then if the door is closed it will continue arming.

The main problem is i can only see the state in triggers and i cant call state from action like i would be able to call arm away or arm home. i cant call an option called pending.

how can i set the state of my alarm under the actions within automations

Setting an entity’s state is not a thing for most entities created by integrations other than the Input helpers. If you need an automation to wait for something, use one of the three types of Wait actions or restructure your automations to use additional triggers.

Input helpers are indeed the way to go if you want control over setting a state. Another option would be a trigger template, if the state changes according to specific triggers. But before buiding your own alarm system from scratch, are you aware of existing integrations that do the heavy lifting for you, such as:

The thing is because of the sequence the alarm has to be in pending i can probably do something like keeping it in pending for a long period like hours so that i can react to the next automation because it would have already been in the pending state. i was looking to do it in helpers but could not find where it could be done

yea i was exploring this option i will read the documentation you just shared and see if that helps me but my setup is going to be very unique. I have built a basic one before but i want it to work the the traditional alarm system. i have contact by the windows and doors wired ones going back to my esp32 card.

This is a rough idea on how my automation will flow

Always Displayed Status based on state before trying to arm system:

State 1: All arming zones are closed - Message (System is ready to be armed)
State 2: (listed zone is open are zones are opened - Message (Please Close “listed zones” before trying to conntinue arming)

Automation 1: All zones are closed when arming

1 Display Alarm Status - System is Ready to be Armed all area are closed

2 status changed from disarmed to arming.

3 all zones closed

Automation 2: Zone are opened when arming

  1. Display Alarm Status - Please close “listed areas” before trying to arm system

  2. Change State from Arming to pending

  3. When state of sensor in the arming arm away group changes from open to closed, start automation 1

i check and i was looking at the toggle switch but was not seeing where i could tie it to the alarm entity and change the state.

if i can change the state in the actions that would solve every problem when i manually call the service pending and then test the other automations it works perfectly how i want it. Just that bridge i need to build between service and state

This was an automation i tried to do everthing in one go but when the state of the door changes to close it does not continue. Nothing happens i have to hit arm system again. it is meant to automatically change arm after the zone is closed and doesn’t

To make it easier for us to understand the structure and function of your automation share the YAML instead of screenshots. To do that click on the three-dot menu at the top right of the automation editor, select “Edit in YAML”, then paste the contents to the thread adding 3 backticks (```) before and after the code block.

1 Like

okay sharing that now
but one more screenshot before i share that. This works but if i hit arm away once but if i hit it a second time even though the contact state did not chage to closed it starts arming.

yaml code

alias: more advance automation
description: “”

  • platform: state
    • alarm_control_panel.alarm
      to: arming
      from: disarmed
  • condition: state
    entity_id: binary_sensor.zone_1
    state: “on”
  • service: alarm_control_panel.alarm_disarm
    entity_id: alarm_control_panel.alarm
    code: “my code here”
  • service: notify.persistent_notification
    message: zone opened
  • wait_for_trigger:
    • platform: state
      • binary_sensor.zone_1
        from: “on”
        to: “off”
  • service: alarm_control_panel.alarm_arm_away
    code: “my code here”
    entity_id: alarm_control_panel.alarm
    mode: single
    initial_state: true

only using one sensor now for testing but i have the others in a sensor group and once i get this working i will change to that group. I will also use the secrets file for the code but to keep it simple and make sure everything functions i kept it small.

@Didgeridrew @Edwin_D i got it done. I had to change the mode to restart and it does what i want without the need to use multiple automations