Motion sensor automation really slow

I am having this automation:

- action:
  - service: switch.turn_on
  alias: Auto-Licht Arbeitszimmer
  condition:
  - after: '16:00'
    before: 08:00
    condition: time
  id: '1519110895398'
  trigger:
  - entity_id: sensor.fibaro_system_fgms001zw5_motion_sensor_burglar_3
    from: '0'
    platform: state
    to: '8'

Its meant to turn on a desk lamp via fibaro’s z-wave wallplug as soon as there is motion detected with fibaro’s z-wave motion sensor.

Basically it works, however the response time is somewhere between 2 and 10 seconds, sometimes it even does not trigger at all and the lamp remains dark.

I enabled the LED indicator on the motion sensor and I can see it reacting quickly each time. I already bumped sensitivity to max and number of pulses to 1 (down from 2) in the motion sensor z-wave options, otherwise the trigger would be even more unreliable/slow.
Also in the HA log everything seems to happen between 1-2 seconds (from motion state change to switch trigger), however I haven’t checked in detail the logs for cases where there is no action at all, or really long reaction times.

So is this purely a z-wave latency issue? Is there some way to speed it up? My appartment is rather small, with a layout maybe like this:

          _____--__________--______
         |m      T    |    T      |
         |            |           |
         | P          |           |
         |            |           |
         |                        |
         |            |           |
____--___|_____   ____|___________|
|       T   |        m|           |
|         pi|                      |
|           |         |___________|
|           |         |           |
|           |                      |
|                     |___________|
|           |            
|__________m|_T_______|

(m = fibaro motion sensor, T = fibaro thermostat, P = fibaro wall plug, pi = USB z-wave controller)

I haven’t checked the z-wave network signal strength on the devices yet, however I hoped that it would be good as the appartment is only 72m².

The USB controller is plugged into a raspberry pi model B. There seems to be no load on the device:

top - 11:26:58 up 1 day,  3:20,  1 user,  load average: 0.08, 0.07, 0.08
Tasks: 106 total,   1 running, 105 sleeping,   0 stopped,   0 zombie
%Cpu(s):  4.3 us,  4.3 sy,  0.0 ni, 91.4 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  434.113 total,   14.793 free,  177.504 used,  241.816 buff/cache
MiB Swap:  887.996 total,  884.617 free,    3.379 used.  239.434 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
  235 pi        25   5  179.0m  94.9m  21.2m S  0.0 21.9   5:09.69 node-red
  369 homeass+  20   0  139.2m  53.4m  12.1m S  1.0 12.3  38:24.69 hass

In the past I have those ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting errors approx every 15 minutes, but since I disabled the discovery service in HA those went away. So I can see nothing in HA logs what would indicate any errors.

I would think this is a device latency issue over z-wave. I have a z-wave motion detector and its response time is almost instant. Maybe .5 second delay. The next thing I noticed is that you are looking at ‘burglar’. On my sensors, that’s not the correct attribute. That’s the attribute that senses physical movement of the device, meaning only vibrations and handling will trigger it. My automations call out the sensor itself being ‘on’. You may need to change the reporting type of your z-wave device to get this functionality in HA.

- alias: Hall Motion Detected During Day
  trigger:
    - platform: state
      entity_id: binary_sensor.hallway_ms_sensor_32_0
      to: 'on'
  condition:
    - condition: time
      after: '07:00:00'
      before: '23:00:00'
  action:
    - service: homeassistant.turn_on
      entity_id: script.hall_motion_day

Thanks for your response. Actually I think this sensor is correct, according to my research it changes from 0 to 8 when motion is detected, and from 8 to 0 if no more motion is detected.
The tamper sensor is a different sensor.

But yesterday I upgraded my setup from raspberry pi B+ to a raspberry pi 3, and now the motion detection really runs well, the switch is triggered almost instantly!
Thats really great, didn’t think the old pi had such an effect on everything.

Nice, Didn’t realize a piB+ was that slow.

@patrick_jane

Just curious, when you upgraded your Rpi B+ to RPi3 did you start fresh by reinstalling everything or how did you do it? Thinking of doing something similar. Thx

you should have a binary sensor that changes from off to on when motion is detected. That is what most people use. This is one of binary_sensor.bedroom_sensor

Just curious, when you upgraded your Rpi B+ to RPi3 did you start fresh by reinstalling everything or how did you do it? Thinking of doing something similar. Thx

I did a fresh & clean install up to the point of the first start of hass out of the python environment. Afterwards I stopped hass, then replaced the ~/homeassistant/.homeassistant folder entirely with the one from the old pi (since I did not know how a fresh install will behave with a pre-existing .homeassistant folder).
After starting up again (and waiting for more module installations) everything was there again as on the old pi.

you should have a binary sensor that changes from off to on when motion is detected. That is what most people use. This is one of binary_sensor.bedroom_sensor

I tried using it, but there seems to be no real difference, or maybe a bit less reliable. I migh test again on the new pi, now that performance issues seem to be out of the way.

@patrick_jane

Did you use hassbian or a virtual install when you did a clean install and what was your previous install on the old pi?

I was following this: https://home-assistant.io/docs/installation/raspberry-pi/

For both pis, since I had/have raspbian installed, and didn’t want to flash a different image.