Trigger on value between X and Y?

I’m trying to add some smartness to my bathroom lights, but I can’t figure out how to write the config.

I have a Fibaro Motion Sensor and thought I should try to use it’s LUX-sensor to adjust the brightness.
So the idea is to trigger on motion and based on the luminescence in the room set the brightness and color accordingly.
Good in theory but turns out harder to implement… It always triggers on the first block, why?

automation:
 -  alias: 'Bathroom 1'  
    trigger:
      - platform: state
        entity_id: binary_sensor.motion
        to: 'on'
      - platform: numeric_state
        entity_id: sensor.fibaro_system_fgms001zw5_motion_sensor_luminance_2
        above: 100
        below: 350
    action:
      service: light.turn_on
      entity_id: group.bathroom
      data:
        brightness: 240
        color_name: white

 -  alias: 'Bathroom 2'
    trigger:
      - platform: state
        entity_id: binary_sensor.motion
        to: 'on'
      - platform: numeric_state
        entity_id: sensor.fibaro_system_fgms001zw5_motion_sensor_luminance_2
        above: 40
        below: 100
    action:
      service: light.turn_on
      entity_id: group.bathroom
      data:
        brightness: 200
        color_name: Antique White

 -  alias: 'Bathroom 3'
    trigger:
      - platform: state
        entity_id: binary_sensor.motion
        to: 'on'
      - platform: numeric_state
        entity_id: sensor.fibaro_system_fgms001zw5_motion_sensor_luminance_2
        below: 40
    action:
      service: light.turn_on
      entity_id: group.bathroom
      data:
        brightness: 150
        color_name: Gold

Multiple triggers in one automation act as an OR. If you want an AND you need to add the second trigger into a condition.

Cheers

1 Like

Can you show me an example please? :slight_smile:

automation:
 -  alias: 'Bathroom 1'  
    trigger:
      - platform: state
        entity_id: binary_sensor.motion
        to: 'on'
    condition:
      condition: numeric_state
      entity_id: sensor.fibaro_system_fgms001zw5_motion_sensor_luminance_2
      above: 100
      below: 350
    action:
      service: light.turn_on
      entity_id: group.bathroom
      data:
        brightness: 240
        color_name: white
1 Like

Thank you! I’ll give it a try right away :slight_smile:
Btw, may I ask why you use the dash in-front of platform when it’s only one and not multiple platform statements?

EDIT: It’s working, thanks again!

Just a habit. Even if you have only one, the dash does not hurt. But if I want to expand at a later point I do not have to worry about the indentation again.

Cheers

1 Like

It’ll ignore them when there’s only one, but if you get in the habit you won’t forget when you do have more than one instance, right? You’re old school and I like that!

I also like that this advice helps me with this stupid laundry project I’ve been working on. I’m trying to check the current flow on some smart switches to determine when my washer or dryer is done. Dryer is easy as it draws down to zero when it’s done.

But the washer is all over the place in it’s ‘landing zone’ from as high as 3.39 to as low as 1.25. This shows me how to account for that. So thanks!!

1 Like