Motion Sensor instar camera

Hi, i have a instar camera from which i want to use the motion sensor in Home assistant. Via Mqtt i receive motion data as Values. I need a binary sensor which give me the state On or Off
I tried this:

mqtt:
  - binary_sensor:
    - name: "Bewegungsmelder Hof"
      state_topic: "instar/10D1DC2286D1/status/alarm/triggered"
      payload_on: "ON"
      payload_off: "OFF"
      device_class: motion
      value_template: "{% if value_json.val == "0" %}OFF{% else %}ON{% endif %}"

however in Yaml i get an error “bad identation” (last line)
in dev.tools i get an error: “value_json is undefined”
so i dont even know if the code could work

It is because you are wrapping your value in double quotes. Use single quotes like this.

mqtt:
  - binary_sensor:
    - name: "Bewegungsmelder Hof"
      state_topic: "instar/10D1DC2286D1/status/alarm/triggered"
      payload_on: "ON"
      payload_off: "OFF"
      device_class: motion
      value_template: "{% if value_json.val == '0' %}OFF{% else %}ON{% endif %}"

If that doesn’t get it working, post your mqtt message.