Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.79k stars 1.64k forks source link

Xiaomi MiJia wireless switch long press release event #71

Closed mihalski closed 6 years ago

mihalski commented 6 years ago

Thank you for a great new way to use out devices!

I'm pretty certain that the Xiaomi MiJia wireless switch has a long press release event to go with the long press. Any chance we could get it added to the bridge?

I came across this when using the Node-RED implementation some time ago.

Regards, Michal

ciotlosm commented 6 years ago

@mihalski do you see anything in logs when doing long press?

mihalski commented 6 years ago

Sure:

018-5-28 21:27:57 INFO MQTT publish, topic: 'zigbee2mqtt/0x00158d00019dee01', payload: '{"click":"long"}'

But nothing when I release.

ciotlosm commented 6 years ago

I've never encountered something extra besides the long press. Do you have any code reference to such release event? Maybe from a different framework that you were using?

mihalski commented 6 years ago

Actually it seems the HomeAssistant integration supports it too. The long click is click_type "long_click_press" and the release from the long click is click_type "hold". Or maybe BOTH release and hold exist because even though the Home Assistant webpages is malformed I can see those entries.

screen shot 2018-05-28 09 54 39 pm

Maybe the problem is how many different click types you can have? Instead of triple and quadruple it has long_click_release and hold? Although I think that in my automatons hold is acting as long_click_release.. But that's another issue.

https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/binary_sensor/xiaomi_aqara.py

https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/xiaomi_aqara.py

ciotlosm commented 6 years ago

@mihalski the "triple" and "quadruple" are for Aqara button not for MiJia. The MiJia only has singular click or long_press.

Thanks for the links, those should be useful.

mihalski commented 6 years ago

It's the round button that has all the EXTRA features. I have both.

Round button can do single, double, triple, quadruple and long press with the gateway and hold and long_press_release on some other frameworks.

The round button is MUCH better.

PS. Square button can do single, double and triple.

mihalski commented 6 years ago

Also, they always seem to return battery of 100.00... I don't think this is right.

james-fry commented 6 years ago

The round button is MUCH better.

Agree. I have both. Round is better functioning. Square IMO looks better

ciB89 commented 6 years ago

Can't the round button be emulated on the square button? The functionality should only be different firmware, right?

Koenkk commented 6 years ago

long_release added for WXKG01LM, for the battery it will also return the voltage.

mihalski commented 6 years ago

That was an amazing request to implementation turnaround! Thank you.

I know this is closed but I didn't want to start a new thread in case it was a stupid suggestion.

How about adding a long_press duration (in ms including initial 300ms for long_press) to the mqtt publish data? This could allow some creative usage and I think it would be better to calculate on the bridge than by whatever is consuming the mqtt.

Just my 2c worth.

Koenkk commented 6 years ago

@mihalski done! https://github.com/Koenkk/zigbee-shepherd-converters/commit/da87e9bd1806c4d5ff89863093d0565d97de3710

mihalski commented 6 years ago

You guys are the best!

I'm getting so excited about the momentum of this project that I'm thinking of buying more ZigBee devices.

ciB89 commented 6 years ago

Currently some buttons are on sale on gearbest for approx. 5 euros

mihalski commented 6 years ago

@ciB89 Thanks. Unfortunately it's the square Aqara ones which lack a lot of functionality (and double clicks mis-register sometimes).

Xiaomi needs a 3rd button with the functionality of the round one but the appearance of the square one.

ciB89 commented 6 years ago

The round ones are also on sale, just a few cents more expensive. Are there any other?

mihalski commented 6 years ago

Yes! You're right! Thank you. No, the others are wall switches. These are currently the only two buttons available.