Entity_id not being passed with service_template?

I have two alarm_control_panels and I’d like to sync the armed status. For this I have created the following automation:

- alias: 'Alarm: Sync arming with guest-alarm'
    - platform: state
      entity_id: alarm_control_panel.alarm
      from: "disarmed"
    - condition: state
      entity_id: 'input_boolean.enable_guest_alarm'
      state: 'on'
    - entity_id: alarm_control_panel.guest_alarm
      service_template: >
        alarm_control_panel.alarm_{{ states('alarm_control_panel.alarm')|replace('armed','arm') }}

The behavior is actually a bit strange.

  1. If I set the alarm_control_panel.alarm to armed_away it works fine. Both alarms are set to armed_away
  2. If I set the alarm_control_panel.alarm to armed_home it briefly shows that status and then jumps to armed_away
  3. If I set the alarm_control_panel.alarm to armed_night it briefly shows that status and then jumps to armed_away

It appears that the services are being called without passing along the entity_id since it shows the same behavior if I use the services dev tool and call that service (without any data).

I have tried swapping entity_id and service_template but this doesn’t seem to help.

That behavior is also seen when the entity expects to receive an acknowledgement from the device, in response to a command, but doesn’t get it. For example, if a light is turned on and it expects to receive a confirmation from the device that it is, in fact, on but fails to receive it, the light’s state is automatically reverted to off.

Which alarm_control_panel platform are you using?

BTW, I don’t think it’ll make a difference but in your service_template you can get the to_state directly without having to query the entity for its state.

        alarm_control_panel.alarm_{{ trigger.to_state.state | replace('armed','arm') }}

The one for home is manual and the one for guest_alarm is manual_mqtt.

The to_state does make it a little cleaner, thanks for the suggestion!

What happens if you use Home Assistant’s Services page to arm guest_alarm to home mode?

Services: alarm_control_panel.alarm_arm_home
Entity: alarm_control_panel.guest_alarm

Turns out there was another automation tucked away that caused the switching. If I disable that one and trigger the Service call it works fine. Seems I have to go back to the drawing board on this one. Thanks for your help!