Help with alarm template

I’m trying to create an alarm template to wrapper an Envisilink alarm_control_panel that I’m not happy with the behavior of. Specifically, I’d like to be able to arm the system without a code, but you still need a code to disarm. The Envisilink takes an all-or-nothing approach where you can either specify a code in the config and you then no longer need one to arm or disarm, OR you can not specify a code in the config and then you need one to both arm and disarm.
So here is what I’ve done:

alarm_control_panel:
  - platform: template
    panels:
      guest_alarm_panel:
        value_template: "{{ states('alarm_control_panel.guest') }}"
        name: Guest Alarm
        code_arm_required: false
        arm_away:
          action: alarm_control_panel.alarm_arm_away
          target:
            entity_id: alarm_control_panel.guest
          data:
            code: !secret envisalink_code
        arm_home:
          action: alarm_control_panel.alarm_arm_home
          target:
            entity_id: alarm_control_panel.guest
          data:
            code: !secret envisalink_code
        disarm:
          action: alarm_control_panel.alarm_disarm
          target:
            entity_id: alarm_control_panel.guest

When I use this, the arm works perfect, but if I try to disarm, even with a code, I get this in the log:

2024-08-20 13:42:57.197 ERROR (MainThread) [homeassistant.helpers.script.guest_alarm] Guest Alarm: Error executing script. Unexpected error for call_service at pos 1: unsupported operand type(s) for +: 'NoneType' and 'str'

Hi Richard, maybe this can help: [Custom Component] Alarmo - browser managed alarm system

I think that’s a full alarm system built using HA. I still want to use my existing alarm system. I just want it to act sensibly and not just allow disarming without typing in a code.

OK. Figured it out. Apparently I wasn’t passing the “code” through the template to the underlying panel. I added the following and now it works as expected:

  - platform: template
    panels:
      guest_alarm_panel:
        value_template: "{{ states('alarm_control_panel.guest') }}"
        name: Guest Alarm
        code_arm_required: false
        arm_away:
          action: alarm_control_panel.alarm_arm_away
          target:
            entity_id: alarm_control_panel.guest
          data:
            code: !secret envisalink_code
        arm_home:
          action: alarm_control_panel.alarm_arm_home
          target:
            entity_id: alarm_control_panel.guest
          data:
            code: !secret envisalink_code
        disarm:
          action: alarm_control_panel.alarm_disarm
          target:
            entity_id: alarm_control_panel.guest
          data:
            code: "{{ code }}"

NOTE: All I did was add the last two lines to this and it works now.

Now if only I could figure out how to make the underlying Envisalink panel not show up on any of my dashboards…hmmm…