Xiaomi sensors - update frequency script?

Hi guys,

I’ve got several of the Xiaomi Aqara motion sensors dotted around (brilliant kit for the price!). These include a light level sensor.

They intergrated seamlessly into HA, I didn’t have to add anything other than the gateway config. They appear as 2 entities on the dash, the motion sensor and the Lx light level sensor.

Here’s where I hit a bit of a sumble - if the’ve not been activated for a little while, they take a good 5 seconds or so to trigger automations based of this light level. I have them turning on lights below a certain Lx theshold, but it seems the value only updates currently when the motion sensor is triggered.

Is there a way for me to set these to update say every 60 seconds? A script or option I could add if I added the sensors to my config individually?

1 Like

Hi guys, bit of a follow-up.

I fixed it, sort of! Looks like you can’t get the sensors to poll more frequently, this was explored in another thread I dug up after posting.

However!

I got around this by adding a 0.1sec delay to the trigger. Don’t have my code to hand but basically after the

From: “off”
To: “on”

In the trigger, add

For:
Seconds: 0.1

And this gives HA enough time to update the light level before checking it against the condition. Voila!

2 Likes

Hi,

Just curious, which Xiaomi motion sensors have a light level sensor? I’ve got a bunch of these Xiaomi body sensors but don’t think they measure light level.

Cheers.

Found the answer. I didn’t realise the Aqara ones have an additional LX sensor. All good :grinning:

Hi Promithius,

Could you share your code/configuration? I’m interested.

Regards

Sure thing, here’s one of my examples. I have a 2nd automation that just turns the light off when the sensor goes to off (about 60 seconds, nothing you can do about shortening that, inherent flaw with the Xiaomi kit)

- id: Hallway Upstairs lighting on
  alias: Hallway Upstairs Lighting Automation on
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_158d00022369e3
    from: 'off'
    to: 'on'
    for:
      seconds: 0.1
  condition:
    condition: numeric_state
    entity_id: sensor.illumination_158d00022369e3
    below: 10
  action:
    - service: switch.turn_on
      entity_id: switch.upstairs_hallway
1 Like

I saw you found the answer but just for everyone else, its the Aqara branded ones that come with the stand and have the physical sync button on the side rather than the pin hole to push into to sync.

Thanks! I will try this in my configuration.

I didn’t realize you could set the for: value to seconds: 0.1. I thought HA only updates triggers every second. Are you sure that your value of 0.1 is any different than a 1 second value? That would be useful to me if it is.

Can You please make a video of this? I am new to HA and don’t really understand where to put this line of code and how to edit it. Would solve a lot for me!

Looking forward to hear from you. Hopefully I can take a dump soon without sitting in the dark for a minute or two :slight_smile: