Page 1 of 1

Aqara MQTT auto discovery problem with new stable.

Posted: Thursday 03 February 2022 19:46
by solarboy
Greetings fellow Domoticz lovers.

I have just moved to MQTT A.D. from the Zigbee2mqtt plugin and have discovered something that seems to be stopping me fully switch over.

I have 2 Aqara H1 wireless switches (https://www.zigbee2mqtt.io/devices/WRS- ... mi-wrs-r02) that worked with the old plugin but not with the new MQTT autodiscovery.

They expose in Zigbee2mqtt a single "action" field (I am using the "events" operation mode rather than the "command".

With the plugin, this was "discovered" as a single selector switch with the following "levels" ;

0 Off
10 button_1_hold
20 button_1_release
30 button_1_single
40 button_1_double
50 button_1_triple
60 button_2_hold
70 button_2_release
80 button_2_single
90 button_2_double
100 button_2_triple
110 button_3_hold
120 button_3_release
130 button_3_single
140 button_3_double
150 button_3_triple
160 toggle_1

I was able to use this in my scripts as I wanted.

However, with Auto Discovery, the device is "discovered" as a multiple push button devices for each action and also for each switch.

1568 MQTT 0x54ef4410001aec87_action_zigbee2mqtt 239 light switch action_button_1_single Light/Switch Switch Off 1 2022-02-03 18:08:16
1577 MQTT 0x54ef4410001aec87_action_zigbee2mqtt 52 light switch action_button_2_single Light/Switch Switch Off 1 2022-02-03 08:15:39

This in itself isn't a problem as I could modify all my scripts, however, the device only ever is "off" and never changes, even momentarily, to "on" when the switch is pressed.

2022-02-03 17:58:13 Off
2022-02-03 17:58:11 Off
2022-02-03 17:57:28 Off
2022-02-03 17:57:26 Off
2022-02-03 17:57:22 Off
2022-02-03 17:57:20 Off
2022-02-03 17:56:26 Off
2022-02-03 17:56:11 Off
2022-02-03 17:55:35 Off
2022-02-03 17:55:32 Off
2022-02-03 17:55:27 Off

With the old plugin, the momentary status was visible in the logs, for example;

2022-02-03 17:58:13 Off
2022-02-03 17:58:13 button_1_single
2022-02-03 17:58:11 Off
2022-02-03 17:58:11 button_1_single
2022-02-03 17:57:29 Off
2022-02-03 17:57:28 button_1_single
2022-02-03 17:57:26 Off
2022-02-03 17:57:26 button_1_single

I am at a bit of a loss how to proceed to be able to enable the switch state to be available to Domoticz with MQTT auto discovery.

Re: Aqara MQTT auto discovery problem with new stable.

Posted: Friday 04 February 2022 0:42
by solarboy
In case anyone else is looking for a solution to this, I managed a work-around by creating a script triggered by the "off" action (which only occurs after an "on" action) that triggers a virtual switch to "on" and then to "off" after a 1 second delay.

Not the most beautiful solution but it works.

Re: Aqara MQTT auto discovery problem with new stable.

Posted: Friday 04 February 2022 10:22
by EddyG
I have the same 'problem' with all my switches who expose actions.
I also have to make selector switches to be activated by all the action devices (and I have a lot of those devices).
Like https://www.zigbee2mqtt.io/devices/E174 ... ikea-e1743
https://www.zigbee2mqtt.io/devices/TS00 ... uya-ts0044
https://www.zigbee2mqtt.io/devices/WXKG ... i-wxkg01lm
https://www.zigbee2mqtt.io/devices/WXKG ... g02lm_rev1
So for production I still did not make the switch, hoping for a selector solution in the (near) future.

Re: Aqara MQTT auto discovery problem with new stable.

Posted: Friday 04 February 2022 14:07
by solarboy
Yeah, that's a lot of work, my 2 way Aqara switches have 32 separate actions. Other than that the upgrade went well and I am happier than I was with the previous implementation which also had issues originally. If I used my Aqara switches in the default "command" mode, on activation they would toggle every single Zigbee device in my house ! The first time it happened I thought I had a truly serious problem !!

The graphing in the new Domoticz is next level and there are lots of little improvements everywhere, backing up the database is much faster, altering floorplans has lost some glitchiness it used to have. MQTT AD is fabulous.

Re: Aqara MQTT auto discovery problem with new stable.

Posted: Thursday 14 April 2022 19:22
by killerq
Hi all,
i've just also migrated from the plugin and having the same issues with the switches, but, i don't know how, managed to solve the problem in some of them. Note that i'm using DzVents for scripting.

1. In the device section i have all the actions of the switch like separated devices:

1 - Device name click
2 - Device name double_click
3 - Device name triple_click

But also have a strange device like this:

4 - Device name - Type: General Subtype: Text ---> And in the data this holds the button last status!.

So, in the Dz Events, the script 'on' clause will be like this:

on = {
devices = {'Device name*'} --note the * in the name, this will trigger with any of the 'devices'
},

And after that, if I check device.status, it has the correct status and not only 'off', that was all I was getting.

Sorry if is confusing, but explainig this without pictures is difficult :D

More news, I've managed to solve the problem with my aqara switch!

In the script, get the name of the device instead of the status.

So after this:

on = {
devices = {'Device name*'} --note the * in the name, this will trigger with any of the 'devices'
},

in the script, if I check device.name i get the name of the device, this is:

'Device name click' or 'Device name double_click' or 'Device name triple_click' ......

Hope this helps!

Xavi

Re: Aqara MQTT auto discovery problem with new stable.

Posted: Monday 24 April 2023 13:38
by joostvanderlinde
Found a working solution

I created a dzVents event

Code: Select all

return 
{
    on = { devices =  { 445 } }, -- Idx of correct momentary switch

    execute = function(dz)
        dz.devices(210).toggleSwitch() -- Idx of switch to todggle
    end
}
I think I can just add similar code-blocks for every momentary switch I want to get processed