Hack: emulating shorter cool-down of Ikea TRADFRI motion detector

I noticed that the TRADFRI motion detector (E1745), fires Update events if it detects motion, during the 3min cooldown period. The cool-down for the update events is about 97s. I like to use this behaviour to restart a timer (let’s say duration 2 mins), which is used to switch off the light after it finishes. The automation is mostly clear to me. I am only struggling to build a trigger which fires with any “Attribute Updated event”. I cannot figure out from the logs which attribute is updated. So far I tried.

platform: state
entity_id:
  - binary_sensor.ikea_of_sweden_tradfri_motion_sensor_motion
id: Motion
enabled: true

I guess not working, as no values is updated

This is an alternative idea, which I don’t know how to complete

platform: event
  event_type: ???? WHAT HERE FOR UPDATE EVENT ????
  event_data:
    entity_id: binary_sensor.ikea_of_sweden_tradfri_motion_sensor_motion

I am trying to run my HASS on minimal code. So, using standard HASS functions or templates without any additional python code or plugins would be great.


JM

How did you notice that?
If you noticed an event in the developer tools, that’s exactly on the same event you should trigger…

But then you speak about attributes. If you do a state trigger, it’ll trigger if solely an attribute is changed as well.

An event has no duration, so not sure what you mean by “cooldown”, here

Hi Cris,

I am sorry I forgot the actual logbook output. The following can occur, it there is motion at least 97s after the 3mins cool down period started:

IKEA of Sweden TRADFRI motion sensorAttribute Updated event was fired

11:39:54 - 2 hours ago

IKEA of Sweden TRADFRI motion sensor On With Timed Off event was fired with parameters: {'on_off_control': 0, 'on_time': 1800, 'off_wait_time': 0}

11:39:54 - 2 hours ago

IKEA of Sweden TRADFRI motion sensor Motion detected
11:37:21 - 2 hours ago

JM

After several years of writing complex state machines tracking MOTION and NO_MOTION in openHAB working around unreliable retriggering with Fibaro Z-Wave PIRs with multiple timers, I found the simplest solution is the default in HASS - reverse the logic.

MOTION turns ON.
NO_MOTION for a time turns OFF.

That way, the re-triggerable timer is built-into HASS and needs no logic.

What log is this? Doesn’t look like a HA one…

TBH, with mmWave like the ld2410 at 5€ and less, the time of building state machines for PIR is coming to an end, with no regrets :wink:

Yes - know what you mean. The ability to sense presence as well as motion is really interesting.

Reid’s YT video showing one mmW sensor triggering on specific zones in a large room is quite impressive.

mmW might mean I’m going to have to fill in the holes in the living room door frames eventually - door reed switches are the current workaround to sense presence that the PIRs can’t. :slight_smile:

I switch to timer based state machines, as I can simulate presence using the same timer. I also prefer to see what’s going on in a room regarding counting down no motion timer, easy to debug.

Anyway, I though, as people complaining about the long cool down of the Ikea motion sensor, it would be a good idea to make this hack work and bringing the switch off time down to approximately 100s, without trying to hack the firmware.

Any of you have an idea how to use one of the events below as a trigger?

IKEA of Sweden TRADFRI motion sensorAttribute Updated event was fired

IKEA of Sweden TRADFRI motion sensor On With Timed Off event was fired with parameters: {'on_off_control': 0, 'on_time': 1800, 'off_wait_time': 0}

I don’t use ZHA, but in MQTT Explorer you can see they keep firing events as long as there is motion. Only after they see no motion for 3 minutes the send the ‘No motion’ event.

  1. Where do you see those “events”? Only in that log?
  2. Where does this log come from?

Logbook on the device card

Screenshot 2023-07-14 at 15.39.06

Go to developer tools and listen to zha_event

When the event in question does pop, you’ll have all the needed data for your trigger.

in z2m you can nowadays configure the cooldown delay :slight_smile:

Almost there, I tried different approaches. Found this one the most clear:

Using the event data

event_type: zha_event
data:
  device_ieee: 90:ab:96:ff:fe:18:9b:a8
  unique_id: 90:ab:96:ff:fe:18:9b:a8:1:0x0006
  device_id: 88340f1303dde533fd23c9ae37b4bc75
  endpoint_id: 1
  cluster_id: 6
  command: attribute_updated
  args:
    attribute_id: 0
    attribute_name: on_off
    value: 1
  params: {}
origin: LOCAL
time_fired: "2023-07-14T15:42:37.358764+00:00"
context:
  id: 01H5AH2ZSE6V3KGWC34K7DJXNN
  parent_id: null
  user_id: null


event_type: zha_event
data:
  device_ieee: 90:ab:96:ff:fe:18:9b:a8
  unique_id: 90:ab:96:ff:fe:18:9b:a8:1:0x0006
  device_id: 88340f1303dde533fd23c9ae37b4bc75
  endpoint_id: 1
  cluster_id: 6
  command: on_with_timed_off
  args:
    - 0
    - 1800
    - 0
  params:
    on_off_control: 0
    on_time: 1800
    off_wait_time: 0
origin: LOCAL
time_fired: "2023-07-14T15:42:37.356957+00:00"
context:
  id: 01H5AH2ZSCR0F6P14KGHN3J0J3
  parent_id: null
  user_id: null

and the the event trigger

platform: event
event_type: zha_event
event_data:
  data:
    device_id: 88340f1303dde533fd23c9ae37b4bc75
    command: attribute_updated
    args:
      attribute_id: 0
      attribute_name: on_off
      value: 1

So far nothing worked. Any idea?

Look better

You mean something like this?

platform: event
event_type: zha_event
event_data:
  data:
    device_id: 88340f1303dde533fd23c9ae37b4bc75

Trigger does not fire.

The following zha_event works now in an automation:

To note: I could not make it work in the template editor.

1 Like

Actually the zha events I see coming from Ikea tradfri motions sensors ( Firmware: 0x24040005 ) are of this type:

event_type: zha_event
data:
  device_ieee: xx:xx...
  unique_id: xx:xx:...
  device_id: xxxxxxxx
  endpoint_id: 1
  cluster_id: 6
  command: on_with_timed_off
  args:
    - 0
    - 1800
    - 0
  params:
    on_off_control: 0
    on_time: 1800
    off_wait_time: 0

They come with intervals sometimes as short as 46 seconds, but most of the times every 48 seconds.
It therefore seems that the actual blind time of these sensors is 46 seconds.
At the end of the 46 seconds:

  • the sensor doesn’t send anything if there was recent motion during that interval.
  • it just starts reporting new motion when it occurs

In an automation, triggers of this type do work:

trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: xxxxxxxx
      command: on_with_timed_off