stas-demydiuk / domoticz-zigbee2mqtt-plugin

zigbee2mqtt plugin for domoticz
MIT License
136 stars 100 forks source link

Aqara 1-button wired switch (no neutral, QBKG04LM) wireless mode #281

Closed taranton closed 4 years ago

taranton commented 4 years ago

1-button Aqara wired switch won’t work as wireless in decoupled mode. Domoticz not receiving any codes from it. I found that there is no QBKG04LM.py file for it and it’s working just as simple on/off. But when you send json command to turn wireless mode it keep silent. I checked and modified init.py file and made a simple QBKG04LM.py myself and managed to receive “click” for every push of button in wireless mode. But still there are “release” and “hold” actions, that could be used, I think. Is it possible to add QBKG04LM.py to distributive? This switch is well-documented on zigbee2mqtt page in docs. And I have one and will make all possible tests, if it is necessary.

stas-demydiuk commented 4 years ago

@taranton I've updated plugin with support for decoupled mode of your switch. I wonder if you could update plugin and check.

taranton commented 4 years ago

@stas-demydiuk Thank you for helping! Just updated. Removed switch from domoticz and added back after update. I received three devices:_signal, _switch and _action. I'm getting "Click" for every physically action from _action and _switch not working at all. Yesterday I made a dummy On/Off switch and and wrote two simple scripts with json commands to turn it on: mosquitto_pub -m "{\"state\":\"On\"}" -t zigbee2mqtt/WallSwitchEntrance/set

and to turn off: mosquitto_pub -m "{\"state\":\"Off\"}" -t zigbee2mqtt/WallSwitchEntrance/set

In such way I can switch the relay physically On/Off while I still can receive clicks from the button. Bad part that I can't check it's state in this simple way.

stas-demydiuk commented 4 years ago

Could you please provide MQTT messages from device when you do these actions

kovainfo commented 4 years ago

I have the same problem.

I got the impression that after the update the command to turn on is not sent at all.

I watched the log from zigbee2mqtt: sudo journalctl -u zigbee2mqtt.service -f and when you try to press the switch (in the Domotics) nothing was displayed at all in the log.

P.S. Откатился на предыдущую версию - всё заработало :)

taranton commented 4 years ago

Could you please provide MQTT messages from device when you do these actions

@stas-demydiuk , sure, here they are:

{"linkquality":49,"state":"ON"}
{"linkquality":49,"state":"OFF"}

and for clicks:

{"linkquality":49,"state":"ON","click":"single","action":"hold"}
{"linkquality":52,"state":"ON","click":"single","action":"release"}

@kovainfo , yes, switch is not receiving anything from domoticz after update. Are you using it in decoupled mode? this mode should be turned on or off with special mqtt commands (examples for bash):

mosquitto_pub -m "{ \"operation_mode\": { \"button\": \"single\", \"state\": \"control_relay\"  }}" -t zigbee2mqtt/WallSwitchEntrance/system/set
mosquitto_pub -m "{ \"operation_mode\": { \"button\": \"single\", \"state\": \"decoupled\"  }}" -t zigbee2mqtt/WallSwitchEntrance/system/set

where "decoupled" is wireless mode and "control_relay" is standard switch mode. and there is a special mqtt topic for those commands - zigbee2mqtt/[switch_name]/system/set

P.S. Если я правильно понял вопрос от Стаса - эти сообщения сверху на мои команды через командную строку или mqtt explorer. То есть в режиме decoupled домотикз не переключает физический выключатель, но через mqtt explorer - без проблем.

stas-demydiuk commented 4 years ago

Could you please try now

kovainfo commented 4 years ago

@taranton No, the problem was that nothing was switched through domoticz at all! and no matter what mode the switch is in

@stas-demydiuk I'm going to try now. I have all types of Aqara switches

kovainfo commented 4 years ago

@stas-demydiuk new PR is worked for me @taranton ?

taranton commented 4 years ago

@stas-demydiuk Now its working great! Thank you for update) Switch is working like a charm and action returning "release" and "hold", so now we can use more options and scenarios) By the way, is there any possibility to implement operation_mode switching between control_relay and decoupled in plugin? Or is it only possible through external scripts, like I did before?

stas-demydiuk commented 4 years ago

I would suggest to use external script as this is most likely one-time operation