Trigger-based template binary sensors in UI? Window alarm sensor

I have this my config.yaml … is there a way to set up this template binary sensor helper from the UI??

RF window sensor (KERUI D025), it listens to RFbridge (flashed with esphome). Based on the event (open/close…different code each), it changes the status of the binary sensor.

template:
  - trigger:
      - platform: event
        event_type: esphome.rf_code_received
        event_data:
          device_id: c893ffef7e1816adeb244f4e138f7840
          #sync: "17048"
          #low: "614"
          #high: "1858"
          code: "5425310"
        id: "on"
      - platform: event
        event_type: esphome.rf_code_received
        event_data:
          device_id: c893ffef7e1816adeb244f4e138f7840
          #sync: "18904"
          #low: "616"
          #high: "1856"
          code: "5425303"
        id: "off"
    binary_sensor:
      - name: Office window
        device_class: window
        state: "{{ trigger.id }}"```