Phoscon App - Door and window sensor - How to trigger an event?

Hello all,

I have a Xiaomi Aqara window/door sensor. This is
integrated in the Phoscon app without any problems and detects the status open/closed.

The detection is done within milliseconds in the
the Phoscon app. This is very good.

However, I am relatively new to Phoscon and deConz environment.

I am wondering though, how can I trigger an event,
as soon as a change in status is detected? One possibility is to send an REST API call to deConz every second, but this would cause higher cpu usage. Is there a way to trigger state changes from window / door sensors actively? For e.g. Phoscon App indentifies a status change and runs a python script or requests an url with params?

Do I need additional software? I used the deConz REST API to query the state. The query of the temperatures is done every minute. But a window/door sensor may be more time sensitive, because if I open a door, it is very likely that it will be closed again within a minute and thus no change is detected via the API.

I am using:

  • Debian Linux (headless)
  • deConz
  • Phoscon (web interface)

The deconz REST API makes the value of the last update (“lastupdate”) available at /sensors.

So if I query the status via REST API every minute, I can compare the value of “lastupdate” with the current time and if the difference is < 1 minute, then I can assume that the status has changed once.

I think I read that the battery powered Aqara sensors usually transmit a signal when the status has changed. So I can assume that when a lastupdate value strikes, the door or window was open/closed at least for a short time.

It would be nicer, of course, if there is the possibility of triggering a trigger/event as with CCU3.

This sensor sends an alive signal once an hour, so I get a false positive every hour.

I guess Phoscon has its limits here and at the deconz REST API I didn’t find an entry that says “last state change” but only “lastupdate”.

How did you solve the problem? Do you also use Phoscon or other software for this?

deconz REST API Output:
lastseen and lastupdated have similiar values and will update at least afer each send alive signal. So it seems to be impossible to trigger an event.

			'battery': 100, 
			'on': True, 
			'reachable': True, 
			'temperature': 3200
	'ep': 1, 
	'etag': 'xxx', 
	'lastannounced': None, 
	'lastseen': '2023-09-10T09:28Z', 
	'manufacturername': 'LUMI', 
	'modelid': 'lumi.sensor_magnet.aq2', 
	'name': 'Fenster- / Türkontaktsensor', 
			'lastupdated': '2023-09-10T09:28:32.599', 
			'open': False
	'swversion': '0.0.0_0003', 
	'type': 'ZHAOpenClose', 
	'uniqueid': 'xxx'

I was able to solve the problem by using ioBroker. There is the possibility to connect to the deconz REST API via an adapter and trigger and react to the status messages in near real time.