Hi, that was the hint I need. Now it works!
Only one question why you add a 10 seconds delay?
Xiaomi Gateway with several sensors - how to make it work in Pimatic?
Hi, that was the hint I need. Now it works!
Only one question why you add a 10 seconds delay?
I honestly don’t know… I guess I wanted to be able to switch to the mqtt log before anything happens. It can of course be removed
I am now using the gateway and the motion sensors 24/7. The connection is stable, and the motion detection works great.
There is an issue though. Normally, the sensor sends so called “reports” when it detects a motion. It looks like this
{'data': '{"status":"motion"}', 'cmd': 'report', 'short_id': 1418, 'model': 'sensor_motion.aq2', 'sid': '158d0001656f6f'}
After it detects a motion, it sends no_motion reports, starting at two minutes, stopping at 30 minutes with increasing intervals
{'data': '{"no_motion":"120"}', 'cmd': 'report', 'short_id': 1418, 'model': 'sensor_motion.aq2', 'sid': '158d0001656f6f'}
But, it also sends “heartbeats”, which look like this
{'data': '{"voltage":3025,"status":"motion","lux":"2"}', 'cmd': 'heartbeat', 'short_id': 1418, 'model': 'sensor_motion.aq2', 'sid': '158d0001656f6f'}
The problem with those heartbeats is, that there is no motion, and that they look the same in MQTT. How can I identify those as false alarms in pimatic? Is there a way to access the “cmd” part of the data?
@bioschaf said in Xiaomi Gateway with several sensors - how to make it work in Pimatic?:
Is there a way to access the “cmd” part of the data?
HI, yes. use “cmd” as the attribute name.
Pimatic = Smart Home
Hi,
as “cmd” is not part of the “data”-section, this does not work.
mosquitto_sub -t 'xiaomi/#' -v
does not show it either. It only shows the attributes inside data, e.g.
xiaomi/gateway/34ce008bf45d/ip 192.168.178.28
for the gateway-heartbeat. So I guess the python script needs changing?
Edit: as a workaround, I check if the voltage attribute has been updated when I receive a motion-message. That works, because the attribute is not included in the “real” motion report, only in the heartbeat.
Hi,
I have a problem with the motion detector.
How can I reset the status to 0?
When “status = 1” =
{u'model': u'motion', u'cmd': u'report', u'data': u'{"status":"motion"}', u'short_id': 13528, u'sid': u'deviceID'}
is
and “status = 0” =
{u'model': u'motion', u'cmd': u'report', u'data': u'{"no_motion":"120"}', u'short_id': 13528, u'sid': u'deviceID'}
is.
My problem is, that the topic’s are different.
Try it this way
publish mqtt message "0" on topic "xiaomi/motion/158d00016da129/no_motion" after $someTime and publish mqtt message "" on topic "xiaomi/motion/158d00016da129/status" after $someTime
@OrTiN
Works really well.
Didn’t have the idea to solve it with rules.
Thank you very much.
U r welcome
I’ve made a plugin for the aqara Xiaomi gateway: https://www.npmjs.com/package/pimatic-aqara