Xiaomi Human / Body / Motion Sensor - Timeout

Makes sense, so that’s why I noticed a shorter time out as you did. I’m trying out a Hue motion sensor right now to overcome this problem. But it’s big and expensive…

Hi all,

I have the xiaomi Window & Door sensor as well as the body movement sensor.

They work ok as long as you don’t want to specify a time range in which they should trigger any action.

First you can’t specify a time range, only starting time till midnight, which I don’t want (i.e. I may want to trigger an action overnight so I know if someone entered my home) but even worst, if I choose to set the ‘Effective time period’ this is using China time zone, so I can’t not trigger anything when I want to.

Even weirder is that log is ‘mapped’ to my mobile’s time zone, but results notifications are using China TZ (as well as sensor behaviour).

Do you know how to solve that?

Other devices (like bulbs, plugs or vacuum cleaner) do actually use my mobile’s time zone correctly.

Thanks!

Im just a bit shocked about last post. The gateway send information to :cn:? Well if u wanna stop this u just block the internet access for the gateway … I don’t want that Chinese people know when my robot cleans our home :house_with_garden:

I use my Xiaomi Motion Sensors for time based events. These are all configure in Home Assistant rather than the Xiaomi app though. For example:

- alias: bathroom_night_light_on
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_158d12315e7bg1
    to: 'on'
  condition:
    condition: and
    conditions:
      - condition: time
        after: '23:00:00'
        before: '06:00:00'
      - condition: state
        entity_id: sun.sun
        state: 'below_horizon'
  action:
    service: light.turn_on
    entity_id: light.bathroom_mirror_lights

I hope this helps.

3 Likes

Is there any way to fix the delay of the sensor?
I read trough all thread, but I simly couldnt understand/find a way to do it.
I’m using official component for xiaomi in HASSIO.

Unless anything has changed…

…although you can tweak it so that the maximum turn off time is 1m5s rather than 1m30s.

How can I achieve that? Is it possible to do it with official component?
Better to have ot on 1min than 2.

…I’m not sure however if this will have an affect on performance. Give it a try, see what you find.

I’v seen this, just not shure where to add that code?
Do I have to install appdeamon addon first?

No need to install anything, it’s one of the files that forms Home Assistant. You can find it with this command:

sudo find / -name xiaomi.py

There are a few files with this name, you want the one in the binary_sensor folder. Mine was located here:

/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/binary_sensor/xiaomi.py

I hope this helps.

I will try to figure this out today. I’m using HASS.IO on Pi3, can it be done on that setup?

I’m not sure about HASS.IO I’m afraid. If you can’t find it then perhaps someone more familiar with HASS.IO can help.

Meybe there is a smarter way of using motion sensor? The trouble I’m having is that lights turn off when I’m in the room, and won’t turn on on motion… Is there a way to have lights on as long as motion sensors is in ON position?

1 Like

That shouldn’t happen. Turning off the lights can be bounded to an automation with a timer setting of around 30s - 1 min. That way the lights will turn off approximately in 2 minutes when no motion is detected. The sensor should be available at that moment as the 1 min internal time has already passed and it should respond to motion immediately. Can you post the automations you use to turn the lights off and turning them on. Maybe something is missing.

If it helps, here is a simplified version of the automation I use to turn lights on and off with a Xiami Motion Sensor:

- alias: bathroom_night_light_on
  initial_state: true
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_258d46515e6fe1
    to: 'on'
  action:
    service: light.turn_on
    entity_id: light.bathroom_mirror_lights

- alias: bathroom_night_light_off
  initial_state: true
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_258d46515e6fe1
    to: 'off'
  action:
    service: light.turn_off
    entity_id: light.bathroom_mirror_lights

As you can see there’s not much to it and it works well for me.

1 Like

Trouble is that I have 2 motion sensors turning on same light. 1 is Xiaomi motion sensor, and 1 DIY multisensor (BRUH Multisensor).
Here is my automation, meybe there is a better way of doing this? I have the same automation for night light, after 22h.
https://pastebin.com/3yC464fa

Maybe try dividing the automations into two for each sensor. Another thing to try might be deleting the " from: " parts.

Ill try dividing automation, and will remove that line in automation. Ill se if that gonna sort it out.

Maybe if you have 2 sensors and 1 light you could try something like this for the off part of the automation:

Trigger = Either of the motion sensors turning off (as you have done).
Condition = Both of the motion sensors are now off.

Just an idea -

I use a xiaomi motion sensor to enable a scene (single philips hue bulb) as a ‘night light’ should one of us get up in the middle of the night for a drink.

Once the motion sensor turns off, the light turns off.

So that the motion sensor doesnt turn off the light when it’s being used outside of the ‘night light’ scene, I created a new sensor and in the activation automation set it to ‘on’.

In my turn off automation, I check the value of the sensor as a condition.