Syntax for sensor, enum and set mapper

As a binary sensor things are working fine. But I wanted to upgrade my binary sensor to a sensor, device class “enum”. It’s not working, although the syntax is ok. What am I doing wrong?

  - trigger:
      - id: '0'
        platform: event
        event_type: sia_event_12300_100100
        event_data:
            code: 'OP'
      - id: '1'
        platform: event
        event_type: sia_event_12300_100100
        event_data:
            code: 'CG'
      - id: '2'
        platform: event
        event_type: sia_event_12300_100100
        event_data:
            code: 'CL'
    sensor:
      - name: "Area Armed"
        device_class: enum
        icon: mdi:shield-home
        state: >
          {% set mapper =  {
              '0' : 'Disarmed',
              '1' : 'Armed Partial',
              '2' : 'Armed Full'} %}
          {{ mapper[state] if state in mapper else 'Unknown' }}

Last line:

{{ mapper.get(trigger.id,  'Unknown') }}

This is working. Thank you so much for the quick reply. I wouldn’t be able to find the solution myself for sure…

Just one question, with a binary_sensor the status colour is blue or yellow. Is it possible to colour the icon based on its status 0, 1 or 2?