Translate FP1 radar action to occupancy

I’m struggling to get a persistent state for a region. The state changes often between regions and empty (?) states.

image

Region 1 is my kitchen and I want to know when it is currently occupied. With the following binary sensor, it sets the occupation correctly, then immediately goes unoccupied.

    - name: kitchen_occupied
      device_class: presence
      state: >-
        {% if is_state('sensor.living_room_radar_action', 'region_1_occupied') %} on
        {% elif is_state('sensor.living_room_radar_action', 'region_1_unoccupied') %} off
        {% else %} {{ this.state.state }}
        {% endif %}

Any ideas? :slight_smile:

Fixed it with some help from New Aqara Human Presence Sensor FP1 - #291 by liviu

template:
  # up to 9 separate regions
  - trigger:
      - platform: template
        value_template: "{{ states('sensor.living_room_radar_action').split('_')[1] == \"1\" }}"
    sensor:
      - name: fp1_z1
        state: >
          {{ trigger.to_state.state.split('_')[-1] }}