Problem with light via motion detectors - Problem bei Licht über Bewegungsmelder

Hi there,

I have created the following automation:

- id: '1630261489093'
  alias: Eingang Licht bei Bewegung und Dunklheit schalten
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    to: 'on'
    id: 'ON'
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    to: 'off'
    for: 00:00:20
    id: 'OFF'
  condition: []
  action:
  - choose:
    - conditions:
      - condition: trigger
        id: 'ON'
      - condition: state
        entity_id: light.lc13_paulmann_level_light_color_on_off
        state: 'off'
      - condition: numeric_state
        entity_id: sensor.lumi_lumi_sensor_motion_aq2_illuminance
        below: '140'
      sequence:
      - service: light.turn_on
        target:
          entity_id: light.lc13_paulmann_level_light_color_on_off
    default:
    - service: light.turn_off
      target:
        entity_id: light.lc13_paulmann_level_light_color_on_off
  mode: single

This means that the light is switched on when there is movement and switched off again later.
Unfortunately, if I enter the room at the moment when the light is switching off, then switching it on again does not work.

Can someone help me how to fix this?

Greetings Werner

Hallo,

ich habe folgende Automatisierung angelegt:

- id: '1630261489093'
  alias: Eingang Licht bei Bewegung und Dunklheit schalten
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    to: 'on'
    id: 'ON'
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    to: 'off'
    for: 00:00:20
    id: 'OFF'
  condition: []
  action:
  - choose:
    - conditions:
      - condition: trigger
        id: 'ON'
      - condition: state
        entity_id: light.lc13_paulmann_level_light_color_on_off
        state: 'off'
      - condition: numeric_state
        entity_id: sensor.lumi_lumi_sensor_motion_aq2_illuminance
        below: '140'
      sequence:
      - service: light.turn_on
        target:
          entity_id: light.lc13_paulmann_level_light_color_on_off
    default:
    - service: light.turn_off
      target:
        entity_id: light.lc13_paulmann_level_light_color_on_off
  mode: single

Dadurch wird das Licht bei Bewegung eingeschalten und später wieder ausgeschaltet.
Wenn ich jetzt aber gerade in dem Moment den Raum betrete, wenn das Licht gerade ausschaltet, dann funktioniert das erneute einschalten leider nicht.

Kann mir jemand helfen, wie ich das lösen kann?

Gruß Werner

I think it happens because the sensor.lumi_lumi_sensor_motion_aq2_illuminance is not updating quick enough (takes longer than 20 seconds) when the light switches off.

If that is true, I suggest you move the illuminance sensor to another place that does not get any other influence except from the sun.

Hi there,

Thanks very much. That would not be my intended solution.
It is strange that the moment the light did not come on, the motion detector was on “motion detected”.

Greetings Werner

Hallo,

vielen Dank. Das wäre nicht meine angestrebte Lösung.
Merkwürdig ist, dass in dem Moment wo das Licht nicht anging, der Bewegungsmelder auf “Bewegung erkannt” stand.

Gruß Werner

When that happens, check your automation trace.

Check at the illuminance level when it does not work. Is it below 140?

Are both the illuminance sensor and motion sensor come from a single device?

Unfortunately, I do not understand that…

Das verstehe ich leider nicht…

Yes.

Ja

Can you try removing this?

      - condition: numeric_state
        entity_id: sensor.lumi_lumi_sensor_motion_aq2_illuminance
        below: '140'

See if it turns the light ON when you enter at the moment the light is switched off.

Hi there,

Thanks very much. I will test it, but that may take a while.
Then I’ll get back to you.
But even if it were because of that, the following might be possible :?

Since the light only stays on for a short time, you could define in the automation that the light value had to be below 140, for example 5 minutes ago. So the switched on light would have no influence on it.

Is the ?

Greetings Werner

Hallo,

vielen Dank. Ich werde es testen, dass kann aber etwas dauern.
Dann melde ich mich wieder.
Aber selbst wenn es daran liegen würde, wäre evtl. folgendes möglich:?

Da das Licht immer nur kurz anbleibt, könnte man doch in der Automatisierung festlegen, dass der Lichtwert bereits vor z.B. 5 Minuten unter dem Wert 140 liegen musste. So würde das eingeschaltete Licht keinen Einfluss darauf haben.

Geht das ?

Gruß Werner

I’ve read from another thread that Aqara Motion Sensor + Illuminance Sensor only updates the illuminance sensor when it detects motion AND after 1 hour of not detecting motion. In my opinion, it is not a good idea to use it to determine the light level.

Maybe what happen is the illuminance sensor still has the previous value when the light is ON - so the illuminance sensor update is not quick enough when the automation is triggered.

Just a suggestion, it is better to have a separate sensor in another place that is not affected by lights turning ON/OFF. That way, the sensor can truly measure the illuminance level based on the light from the sun.

In the mean time, you can use Sun Elevation Condition to determine the light level (although not very accurate).

trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    to: 'on'
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
    to: 'off'
    for: '00:00:20'
action:
  - choose:
      - conditions:
          - "{{ trigger.to_state.state == 'on' }}"
          - "{{ is_state('light.lc13_paulmann_level_light_color_on_off', 'off') }}"
          - "{{ state_attr('sun.sun', 'elevation') < 0 }}"
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.lc13_paulmann_level_light_color_on_off
      - conditions:
          - "{{ trigger.to_state.state == 'off' }}"
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.lc13_paulmann_level_light_color_on_off

I did not use default action as the motion sensor can sometimes turn to OFF even though you are still in the room (but not much movement) - and as soon as you move it will trigger to ON. If that happens, the condition of light is OFF is not satisfied, then it will use the default action (turning the light off before 20 seconds of no motion) which is not suppose to happen.

1 Like

Hi there,

Thanks very much. I’ll take a closer look and then I’ll get in touch.

Thanks. Greetings Werner

Hallo,

vielen Dank. Das schaue ich mir näher an und werde mich dann melden.

Danke. Gruß Werner