deCONZ IKEA motion sensor state change not detected

Hey there,

I’m pretty new to home assistant but I’ve found a solution to all my problems so far. But now I’m stuck and I need your help.

I’ve successfully installed Home Assistant 0.80.0 and deCONZ (2.05.39 / 22.9.2018 - with RaspBee FW 26240500) - both as docker containers and they are working well. I can use the IKEA remote and all bulbs and toggle and automate them in hass.
But the motion sensor wouldn’t do what I want:

The motion sensor is correctly displayed in hass frontend, I can see that it’s state changes when I move in front of it. But when I want to use this to trigger an automation it’s not working.

Normally it should work like this:

trigger:
  platform: state
  entity_id: sensor.tradfri_motion
  to: 'on'

But when observing the state dev tool and the logs, I can see that the state is always on - it doesn’t matter if the motions sensor detects something or not.
The logs are showing, that the sensor is signaling movement by the tag “presence = true”.

... [pydeconz.deconzdevice] tradfri_motion: update presence with True
... [pydeconz.websocket] Websocket data: {"e":"changed","id":"2","r":"sensors","state":{"dark":true,"lastupdated":"2018-10-16T21:40:09","presence":true},"t":"event"}

Therefore I tried to make use of that and use it as a trigger:

trigger:
  platform: template
  value_template: '{{ states.binary_sensor.tradfri_motion_sensor_.presence == True }}'

But unfortunately this is not working as expected.

So I think the deCONZ component is not correctly implementing the motion sensor via the deCONZ API (and therefore observing the state is not helpful), but it should be possible to get a trigger working anyway?

The attributes shown for the sensor in the frontend are:

battery_level: 100
on: true
dark: true
friendly_name: tradfri_motion
device_class: motion

Does anyone have an idea how to solve this?

Thanks in advance! :slight_smile:

Does the little guy for the sensor change between standing and running?

In my configuration, the TRÅDFRI motion sensors appear as binary sensors, but you mention your entity_id as sensor.tradfri_motion. Shouldn’t this be binary_sensor.tradfri_motion?

1 Like

@Robban: Jep, the little guy is running when motion is detected.

@Fury1SOG: Yes, it is a binary sensor. Listed as “binary_sensor.tradfri_motion_sensor_” in the entity list.

Your automation trigger is referring to sensor.tradfri_motion, not binary_sensor.tradfri_motion.

Yes you’re right!
Since I’ve seen it in all tutorials with “sensor” not “binary_sensor” I did not spend so much time trying it.
Anyway I’ve already tried it with “binary_sensor.tradfri_motion_sensor” and it did not work -> because I did not see the trailing underscore! It has to be: “binary_sensor.tradfri_motion_sensor_”
Now it is working:

platform: state
entity_id: binary_sensor.tradfri_motion_sensor_
to: 'on'

Thanks very much and sorry for the noob question!

Anyway:

  • Is this underscore by design? Or is it caused by deCONZ API?
  • Is it by design that the name in hass is different to it in the Phoscon/deCONZ app? I named it “tradfri_motion” there. The names of all other entities were copied 1:1

I am happy to hear that it is working :grinning:
Perhaps there was a space after “tradfri_motion” in deCONZ? I believe all spaces are converted to underscore when the sensor is added to HA.
You can edit the sensor names in the /config/.storage/core.entity_registry file, by the way. (just make sure not to break the file…)

No there was no space after the name and I named it “tradfri_motion” and it got “tradfri_motion_sensor_” in hass. It’s is no problem - you just have to know about it and take care of it. :grinning:

Thanks for the tip with the registry file! I’ve just renamed it. :blush:

1 Like

It is because deconz don’t always add a proper number to the end to devices

1 Like

Hi!
Sorry for hijacking this thread but I’m playing around with the motion sensor as well having it set up through Deconz. I’m trying to utilize a condition with the “sensor.daylight” but can’t for the life of me figure out how to write a proper attributes template. For simplicity I’d like to use the “daylight: true” state.

Any one really good at this? (I’m really new to automations.)
I did try it with the sun conditions as well but every time the automation just stops firing. I even tried setting it up with the automation config but that kind of butchered my previous model.

- id: bathroom_on_daylight
  alias: Badrumssensor på dagtid
  trigger:
  - entity_id: binary_sensor.tradfri_motion_sensor
    platform: state
    to: 'on'
  action:
    entity_id: light.yeelight_color2_04cf8c7b5fe9
    service: homeassistant.turn_on
    data:
      brightness: 200
      rgb_color: [ 255, 200, 156 ]

This works really well, but as soon as I add any kind of condition it just stops.

Can you post the condition you’re trying to use?

Thanks for the reply!
I got it working, sort of, using the time condition:

  condition:
  - condition: time
    after: '07:00:00'
    before: '19:00:00'
    weekday:
      - sat
      - sun

It feels kind of rugged though, having to create several automations for different times of day as well as weekdays. I guess it would be possible to write a single automation using template-states for lighting the bathroom lamp at different times?

Previously I had tried using the “sensor.daylight” for something like this:

  condition:
  - condition: state
    entity_id: sensor.daylight
    daylight: true
    #also tried state true

But I later on realized that this was an attribute of the sensor and not a state.

No sure if this is what you’re after but I use this to set brightness based on two sliders and the sun.

light_hallway_brightness_sunrise:
  name: Sunrise brightness
  icon: mdi:lightbulb-on-outline
  min: 0
  max: 100
  step: 5
light_hallway_brightness_sunset:
  name: Sunset brightness
  icon: mdi:lightbulb-on-outline
  min: 0
  max: 100
  step: 5
  action:
    service: light.turn_on
    entity_id: group.hallway_lights
    data_template:
      brightness: >
        {% if states.sun.sun.attributes.elevation > 0 %}
        {{states.input_number.light_hallway_brightness_sunrise.state | int * 2.55 | round(0) }}
        {% else %}
        {{states.input_number.light_hallway_brightness_sunset.state | int * 2.55 | round(0) }}
        {% endif %}
1 Like

Thanks! Looks interesting. I’ll play with it to see what I can do :slight_smile:

how can I show the status from tradfri of the battery on a card or all things in DEV?

hi to all, i have similar problem, my motion sensor do not change state after one minute (set in the HW config gear)

53

i use Home Assistant 102.1 in docker container and use the latest version of deCONZ with conbee 2 usb key…

i will try with a cc2531 usb key…

I do not think you can change state change time via hassio (I can’t, no such option under config gear icon!). I think it is controlled on sensor itself - on old one there is small ‘know’ on the back you can use to adjust timing, on new one it is fixed.
As alternative you use some automation or script that would only react to state change to on and then reset its status based on delay or timer back to off.

I got an Tradfri motion to test, but found it to have too long a delay making it pretty much useless for triggering lights etc. I’ve found the hue sensors to be the best for this.

Indeed, Ikea not working good, I use the xiaomi instead, also instant detection for lights

i’ve tested it and the movement are instantly triggered but despite having set the release of a minute on the ring behind the sensor it does not stop detecting movement, or rather it appears after hours / days as if there is someone who continues to move in front…