Sensor for HM-MOD-EM-8

Hello guys,

hopefully somebody can give me a hint how to correctly define a sensor according to a log output.

Im using a Homematic HM-MOD-EM-8 with some magnetic contacts to check if a door is open or not.
I read in other threads about a SHORT_PRESS actions. But if I open and close my contact I get following entries in my logs:

Opened:

2021-12-07 20:59:19 DEBUG (Thread-3) [pyhomematic._hm] RPCFunctions.event: interface_id = homeassistant-rf, address = PEQ0106404:3, value_key = STATE, value = True
2021-12-07 20:59:19 INFO (Thread-3) [pyhomematic.devicetypes.generic] HMGeneric.event: address=PEQ0106404:3, interface_id=homeassistant-rf, key=STATE, value=True

Closed:

2021-12-07 21:02:24 DEBUG (Thread-3) [pyhomematic._hm] RPCFunctions.event: interface_id = homeassistant-rf, address = PEQ0106404:3, value_key = STATE, value = False
2021-12-07 21:02:24 INFO (Thread-3) [pyhomematic.devicetypes.generic] HMGeneric.event: address=PEQ0106404:3, interface_id=homeassistant-rf, key=STATE, value=False

So according to Home assistant documentation (Homematic), I would define my new sensor something like

template:
  - sensor:
    - name: "myContact"
      state: "{{ state_attr('climate.PEQ0106404:3', 'state') }}"

But I am not sure what to write instead of “climate” (which is from the example of documentation)?

Thank you in advance.

Best regards,
Haggel