Presence with LUX

Hello Everyone,
I just bought two Tuya ZY-M100-S.
And I’m trying to automate the light in my bathroom.
I wanted to turn it on only if the lux was below 25, and the time is between 06:30 and 22:00.
Otherwise the led has to be turned on.
With my old PIR sensor it has worked, and now with the additional LX it doesn’t work anymore.
I think that it’s how Home Assistant displays LX (at the moment there are 1250lx , but it’s shown as 1,250).
Is there a way to remove the comma?
Here how it’s shown in Home Assistant:
image
And here it’s how it is shown in Zigbee2Mqtt:
image

The Automation is following:

alias: Illuminazione_Bagno
description: ""
trigger:
  - type: present
    platform: device
    device_id: 7ed3e228a768fe31cf61b5ad024cd633
    entity_id: 84a223fd896a65b707612a6a4349a89a
    domain: binary_sensor
  - type: not_present
    platform: device
    device_id: 7ed3e228a768fe31cf61b5ad024cd633
    entity_id: 84a223fd896a65b707612a6a4349a89a
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 30
condition: []
action:
  - if:
      - type: is_present
        condition: device
        device_id: 7ed3e228a768fe31cf61b5ad024cd633
        entity_id: 84a223fd896a65b707612a6a4349a89a
        domain: binary_sensor
      - condition: and
        conditions:
          - type: is_illuminance
            condition: device
            device_id: 7ed3e228a768fe31cf61b5ad024cd633
            entity_id: fb55b6401fcb2de89af15cfd6fe1f328
            domain: sensor
            below: 25
          - condition: and
            conditions:
              - condition: time
                before: "22:00:00"
                after: "06:30:00"
                enabled: true
    then:
      - parallel:
          - service: switch.turn_on
            metadata: {}
            data: {}
            target:
              device_id: eb7bf39da2de79749f13c93e10972a1a
    enabled: true
    else:
      - if:
          - type: is_not_present
            condition: device
            device_id: 7ed3e228a768fe31cf61b5ad024cd633
            entity_id: 84a223fd896a65b707612a6a4349a89a
            domain: binary_sensor
          - condition: and
            conditions:
              - condition: device
                type: is_on
                device_id: eb7bf39da2de79749f13c93e10972a1a
                entity_id: 033ac8a695c50983561913b48f59a1ee
                domain: switch
        then:
          - parallel:
              - service: switch.turn_off
                metadata: {}
                data: {}
                target:
                  device_id: eb7bf39da2de79749f13c93e10972a1a
  - if:
      - type: is_present
        condition: device
        device_id: 7ed3e228a768fe31cf61b5ad024cd633
        entity_id: 84a223fd896a65b707612a6a4349a89a
        domain: binary_sensor
      - condition: time
        after: "22:00:00"
        before: "06:30:00"
    then:
      - parallel:
          - service: light.turn_on
            metadata: {}
            data:
              rgb_color:
                - 0
                - 196
                - 196
              brightness_pct: 65
              effect: breathe
              transition: 15
            target:
              device_id: b5957a76de9fc3650dc2d495b470b6af
    enabled: true
    else:
      - if:
          - type: is_not_present
            condition: device
            device_id: 7ed3e228a768fe31cf61b5ad024cd633
            entity_id: 84a223fd896a65b707612a6a4349a89a
            domain: binary_sensor
          - condition: and
            conditions:
              - condition: device
                type: is_on
                device_id: eb7bf39da2de79749f13c93e10972a1a
                entity_id: 033ac8a695c50983561913b48f59a1ee
                domain: switch
        then:
          - parallel:
              - service: switch.turn_off
                metadata: {}
                data: {}
                target:
                  device_id: eb7bf39da2de79749f13c93e10972a1a
      - if:
          - type: is_not_present
            condition: device
            device_id: 7ed3e228a768fe31cf61b5ad024cd633
            entity_id: 84a223fd896a65b707612a6a4349a89a
            domain: binary_sensor
          - condition: and
            conditions:
              - condition: device
                type: is_on
                device_id: b5957a76de9fc3650dc2d495b470b6af
                entity_id: ab51b862191fa1d13f8c6f2951d99ac6
                domain: light
        then:
          - parallel:
              - service: light.turn_off
                metadata: {}
                data:
                  transition: 15
                target:
                  device_id: b5957a76de9fc3650dc2d495b470b6af
mode: single

You can strip out all the and statements - they’re doing nothing for you.

  1. They’re and by default
  2. That’s not how you format them

Have you checked the state of that entity to see what it really looks like?

Did you check the automation trace?

Sorry , I’ve just started with HomeAssistant.
what I would like to achive is:
IF it’s between 06:30 - 22:00 and LX below 25, then turn on the light (button).
If I’m away, turn it off.
IF it’s between 22:00 and 06:30 and LX below 25, turn the led on.
IF i’m away, turn the led off.

At the moment, I’m using the GUI, so I’ve removed the and and now I’ve made it like this:





I would make a small change to your Automation. When your motion sensor changes to not present I would switch off both the Light and LED. That would simplify the Automation a little bit.

I’ve rebuild the automation as following with only IF.

alias: test_LUCE BAGNO
description: ""
trigger:
  - type: present
    platform: device
    device_id: 7ed3e228a768fe31cf61b5ad024cd633
    entity_id: 84a223fd896a65b707612a6a4349a89a
    domain: binary_sensor
  - type: not_present
    platform: device
    device_id: 7ed3e228a768fe31cf61b5ad024cd633
    entity_id: 84a223fd896a65b707612a6a4349a89a
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 30
condition: []
action:
  - if:
      - condition: time
        after: "06:30:00"
        before: "22:00:00"
      - type: is_illuminance
        condition: device
        device_id: 7ed3e228a768fe31cf61b5ad024cd633
        entity_id: fb55b6401fcb2de89af15cfd6fe1f328
        domain: sensor
        below: 25
      - type: is_present
        condition: device
        device_id: 7ed3e228a768fe31cf61b5ad024cd633
        entity_id: 84a223fd896a65b707612a6a4349a89a
        domain: binary_sensor
    then:
      - type: turn_on
        device_id: eb7bf39da2de79749f13c93e10972a1a
        entity_id: 033ac8a695c50983561913b48f59a1ee
        domain: switch
  - if:
      - condition: time
        after: "22:00:00"
        before: "06:30:00"
      - type: is_illuminance
        condition: device
        device_id: 7ed3e228a768fe31cf61b5ad024cd633
        entity_id: fb55b6401fcb2de89af15cfd6fe1f328
        domain: sensor
        below: 25
      - type: is_present
        condition: device
        device_id: 7ed3e228a768fe31cf61b5ad024cd633
        entity_id: 84a223fd896a65b707612a6a4349a89a
        domain: binary_sensor
    then:
      - service: light.turn_on
        metadata: {}
        data: {}
        target:
          device_id: b5957a76de9fc3650dc2d495b470b6af
  - if:
      - type: is_not_present
        condition: device
        device_id: 7ed3e228a768fe31cf61b5ad024cd633
        entity_id: 84a223fd896a65b707612a6a4349a89a
        domain: binary_sensor
    then:
      - type: turn_off
        device_id: eb7bf39da2de79749f13c93e10972a1a
        entity_id: 033ac8a695c50983561913b48f59a1ee
        domain: switch
      - service: light.turn_off
        metadata: {}
        data: {}
        target:
          device_id: b5957a76de9fc3650dc2d495b470b6af
mode: single

I’m testing it at the moment and it “seems” to work.
I will check this evening if it works as intended.