Aqara Motion Sensor P1 illuminance into binary sensor

So, I got into Home Assistant and got my first Motion Sensor. Works nice with ZHA but to setup my automations I need the State e.g. 35 in a binary Sensor that gives me a true if it’s under 35.

  - platform: template
    sensors:
     wohnzimmer_ist_dunkel:
       value_template: "{{ (states.sensor.lumi_lumi_motion_ac02_illuminance.split(' ')[0] | float) < 35 }}"
       friendly_name: "Wohnzimmer ist Dunkel"

The entity Wohnzimmer ist Dunkel gives back not available. What am I doing wrong?

Try this:

- platform: template
    sensors:
      wohnzimmer_ist_dunkel:
        value_template: "{{ states('sensor.lumi_lumi_motion_ac02_illuminance') | float(0) < 35 }}"
        friendly_name: "Wohnzimmer ist Dunkel"

By the way, you should consider moving to the new way of creating template sensors:

template;
  - binary-sensor:
      - name: "Wohnzimmer ist Dunkel"
        device_class: light
        state: "{{ states('sensor.lumi_lumi_motion_ac02_illuminance') | float(0) < 35 }}"

Thank you Edward, you have saved my evening :sweat_smile:

1 Like