MQTT alarm : delay question / code for disarm only

Hi,

i have setup an MQTT alarm system, it works, but i need 2 settings changed, i cant figure it out

below is my code
issue1 : when i press the arm button, my alarm is instantly armed, not good offcouse, since i dont have time to leave my house
issue2: i need/want to enter a code ONLY when i disarm the alarm

alarm_control_panel:
  - platform: mqtt
    state_topic: "riscopanel/armstatus"
    command_topic: "riscopanel/armstatus/SET"
    payload_disarm: "disarmed" 
    payload_arm_home: "partially"
    payload_arm_away: "armed"
#code below is BOTH not working for my 2 issues
    code_template: >-
            {% if is_state('alarm_control_panel.mqtt_alarm', 'armed') %}
              1234
            {% endif %}    
    pending_time: 30

seems pending time has no influence
seems code template has no influence, alarm can be disarmed without a code