How to get the entered pin code of a template alarm control panel?

I have created a template alarm control panel to do some checks before “the real alarm” is armed/disarmed and also to control the lights/sound/alarm mode of the Ring Keypad V2.

I’m using Node-RED for my automations but that is not the problem.

The problem is that I don’t get a way to get the entered pin code by the user. I need this code to check for example if it is the correct code (compare it with the alarm code in configuration of the alarm control panel) so that I can give a signal on the Ring Keypad that it is the wrong code.

In the documentation you find this:

# Example configuration.yaml entry
alarm_control_panel:
  - platform: template
    panels:
      safe_alarm_panel:
        value_template: "{{ states('alarm_control_panel.real_alarm') }}"
        arm_away:
          service: alarm_control_panel.alarm_arm_away
          target:
            entity_id: alarm_control_panel.real_alarm
          data:
            code: !secret alarm_code
        arm_home:
          service: alarm_control_panel.alarm_arm_home
          target:
            entity_id: alarm_control_panel.real_alarm
          data:
            code: !secret alarm_code
        disarm:
          - condition: state
            entity_id: device_tracker.paulus
            state: "home"
          - service: alarm_control_panel.alarm_arm_home
            target:
              entity_id: alarm_control_panel.real_alarm
            data:
              code: !secret alarm_code

Everywhere you see the data: !secret alarm_code.

So that means whatever code you entered always will be used the correct code that is specified in the configuration on the alarm control panel.

Of course, that’s not really a convenient way, so it will always good whatever code you have entered.

In the action parts of the template alarm control panel I need the really ENTERED code by user. Is this possible?

So look at the disarm action:

alarm_control_panel:
  - platform: manual
    name: real_alarm_panel
    code: !secret alarm_code
    arming_time: 10
    delay_time: 10
    trigger_time: 60
    disarmed:
      trigger_time: 0
    armed_home:
      arming_time: 0
      delay_time: 0
  
  - platform: template
    panels:
      safe_alarm_panel:
        value_template: "{{ states('alarm_control_panel.real_alarm_panel') }}"
        arm_away:
          service: nodered.trigger
          data:
            entity_id: switch.safe_alarm_panel_arm_away_switch
        arm_home:
          service: nodered.trigger
          data:
            entity_id: switch.safe_alarm_panel_arm_home_switch
        disarm:
          service: nodered.trigger
          data_template:
            entity_id: switch.safe_alarm_panel_disarm_switch
            payload:
              entered_code: "{code}"

I’m using a HACS Node-RED integration to trigger Node-RED that the user is disarming the alarm and so I want to send the entered pin code with it. The problem is that inside the action of the template alarm control panel, ‘code’ is not an available property.

How to fix this?

Is this maybe the solution?

use the code variable to extract the code supplied in the action section.

        disarm:
          service: nodered.trigger
          data_template:
            entity_id: switch.safe_alarm_panel_disarm_switch
            payload:
              entered_code: "{{ code }}"

Thanks Petro, that was the solution, it works now!