Trouble making an automation to close my covers with LUX

Hello,

I’m trying to make an automation to close my covers when LUX goes bellow 1.6 with no luck.
I read a lot of posts about this but I can’t figure out what’s wrong. When I try to run the automation manually it works fine. If I cover the lux sensor for 5 minutes it goes bellow 1.6 but the lights don’t turn off.
I did this experiment after 12:00:00.

Here’s my code…

alias: Luzes Por do Sol
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.multisensor_brightness
    for:
      hours: 0
      minutes: 1
      seconds: 0
    attribute: ""
    below: "1.60000"
condition:
  - condition: time
    after: "12:00:00"
    before: "23:00:00"
    weekday:
      - sun
      - sat
      - fri
      - thu
      - wed
      - tue
      - mon
action:
  - type: turn_on
    device_id: ac523b86858663bd694916510dc15548
    entity_id: switch.luz_da_entrada
    domain: switch
  - type: turn_on
    device_id: 5a813b2778081e75b2facd84202a26e8
    entity_id: switch.luz_do_ginasio
    domain: switch
  - type: turn_on
    device_id: 4c5a83aec24f7282cf887e6bbaf34c93
    entity_id: switch.luz_do_jardim
    domain: switch
  - type: turn_on
    device_id: 84d42b435f181aca3046f3ebc5633756
    entity_id: switch.luz_do_terraco
    domain: switch
  - type: turn_on
    device_id: 5e1febc05d0cf8369b6ef7da3449fb0e
    entity_id: switch.candeeiro_do_hall
    domain: switch
mode: single

Might be worth trying to drop the ‘attribute’

But I want the lights to go ON when lux goes bellow 1.6…
If I drop that I don’t achieve what I want, right?

I suggested to try it, have you tried it ?

Sorry. I’ll try that.

I get this…

Message malformed: required key not provided @ data['trigger']

OK, this works for me as I have just tested it:

trigger:
  - platform: numeric_state
    entity_id: sensor.garage_motion_sensor_lux_level
    for:
      hours: 0
      minutes: 1
      seconds: 0
    below: "1.60000"

What am I doing wrong?

Why would they turn off? All of the actions in your automation turn on the switches.

type: turn_on

In your first post, you said off. Can you confirm which statement is the correct one.

Sorry! If the lux go bellow 1.6 i want the lights to turn ON.

alias: Luzes Por do Sol
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.multisensor_brightness
    for:
      minutes: 1
    below: 1.6
condition:
  - condition: time
    after: "12:00:00"
    before: "23:00:00"
action:
  - service: switch turn_on
    target:
      entity_id:
        - switch.luz_da_entrada
        - switch.luz_do_ginasio
        - switch.luz_do_jardim
        - switch.luz_do_terraco
        - switch.candeeiro_do_hall
mode: single

Be aware that a Numeric State Trigger will trigger only when the sensor’s value crosses the threshold of 1.6. In other words, it triggers the moment the value decreases from above 1.6 to below 1.6.

I know, but If I cover the lux sensor for 5 minutes LUX goes bellow 1.6 but the lights don’t turn ON.
It reached 1.3

If your experiment successfully triggered the automation, it will have produced a trace. Examine the automation’s trace to learn why the lights didn’t turn on.

Couldn’t find anything wrong. Damn!!
I bought this light sensor just for this reason.

What did the trace report exactly?

The firs trigger was not run.

Post a screenshot of sensor.multisensor_brightness as it appears in the Developer Tools > States view.

Create the following automation:

alias: Test 1
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.multisensor_brightness
    for:
      seconds: 2
    below: 1.6
condition: []
action:
  - service: notify.persistent_notification
    data:
      title: 'Test 1 {{ now().timestamp() | timestamp_custom() }}'
      message: '{{ trigger.to_state.state }}'
mode: single
  • To test it, go to Developer Tools > States and, in the Entity column, click on sensor.multisensor_brightness. It will make all of the sensor’s information appear in a form at the top of the page.

  • In the form’s State field, replace 36.72 (or whatever value is displayed as long as it’s above 1.6) with 1.5 and then click the Set State button.

  • After 2 seconds, a persistent notification should appear (orange bell icon at the bottom of the left-hand menu). Click the orange bell icon to display the notification. It will report the time when the automation triggered and the sensor’s value (which should be the value you entered 1.5).

Let me know the result of this experiment.

It did appear…