Is There a Way to Add a Device to Home Assistant's Log?

I can’t quite figure this out. I have an Aqara motion sensor I am trying to work with. I am trying to see what data the sensor is sending to Home Assistant. I was wondering if I could have this data appear in Home Assistant’s log for this particular device, or if there is some way I am not aware of?

If anyone has done anything similar before I would love your help!

You can use the service logbook.log to create custom logbook entries.

The aqara motion sensor doesn’t send data to Home Assistant directly, it does so through your ZigBee Gateway. What kind of data do you expect?

I’m just trying to see what signal the sensor is giving for on and off. I am trying to see exactly when it tells the binary sensor to go on.

The sensor communicates to the gateway and the gateway to HA. HA doesn’t now what data is sent between the sensor and the gateway. What do you want to do with this data? What is your end goal?

From what I’ve researched the sensor has a timeout period after motion is detected. When movement happens in front of the sensor, the sensor sends a “DETECTED” signal to Home Assistant. The sensor will stay in DETECTED mode for a certain amount of time before it sends the “CLEAR” signal to Home Assistant. The time it takes the sensor to go from detected to clear after the last movement was detected I call the timeout.

What happens when the timeout is too long, is we get a block of detected data. However, we do not know how much movement was done in that block. We only will know the first and last movement.

The first movement will happen at the start of the block, and the last movement will happen at the end of the block minus the timeout.

Detected Movement Example 1:

For this example the motion sensor has a 1 minute timeout.

Motion is DETECTED on the motion sensor at 12:00:00 PM

Motion is CLEAR on the motion sensor at 12:01:00 PM

The final output in our log file looks something like this:

01/01/2020, 12:00:00 PM,MS001,on

01/01/2020, 12:01:00 PM,MS001,off

From this we can say that our block of motion was 1 minute.

Detected Movement Example 2:

For this example the motion sensor has a 1 minute timeout.

Motion is DETECTED on the motion sensor at 12:00:00 PM

I wave my hand in front of the motion sensor at 12:00:30 PM

Motion is CLEAR on the motion sensor at 12:01:30 PM

The final output in our log file looks something like this:

01/01/2020, 12:00:00 PM,MS001,on

01/01/2020, 12:01:30 PM,MS001,off

From this we can say that our block of motion was 1.5 minutes.

What I’m trying to do is see how the sensor is dealing with that second detected. There is a hack for this sensor that people have done to reduce the timeout down to 5 seconds that I’m having trouble doing, so if I can figure out how to see the data coming from the sensor I can confirm if it is working or not.

This is the hack I am trying to do as an end result. Aqara Motion Sensor Hack for 5 sec - #32 by adrez99

Edit: This link seems so have a logging file for the sensor, but I’m not sure how to get to it. Aqara Motion Sensor Hack for 5 sec · Issue #20036 · home-assistant/core · GitHub