Luligu / matterbridge-zigbee2mqtt

Matterbridge zigbee2mqtt plugin
https://github.com/Luligu/matterbridge-zigbee2mqtt/blob/main/README.md
Apache License 2.0
63 stars 8 forks source link

Support wireless button #10

Closed eric14142004 closed 4 months ago

eric14142004 commented 4 months ago

I am trying to figure out how to make use of wireless buttons like:

https://www.zigbee2mqtt.io/devices/E1524_E1810.html#ikea-e1524%252Fe1810 or https://www.zigbee2mqtt.io/devices/E2123.html#ikea-e2123

Currently the logs reports whenever a button is pressed: debug - [13:31:51.176] [sonos_remote]: MQTT message for device sonos_remote payload: { state: 'track_next' } debug - [13:31:51.176] [sonos_remote]: Update endpoint 5 cluster 6-OnOff not found: is z2m converter exposing all features?

However I don't see the device gets status update in HA

Luligu commented 4 months ago

Hi, thank you for your interest. Very interesting devices. Actually the action conversion is limited:

Known issues

Conversion issues between zigbee2MQTT and Matter ecosystems

Scene buttons are exposed only when they send single double and hold actions (this is due to the Home app supporting only these 3 events.) In the next releases the scene buttons with more actions will be mapped to different endpoints like in my plugin homebridge-mqtt-accessories.

Luligu commented 4 months ago

[2.0.12] - 2024-04-30 Added [action]: Added support for devices with more then 3 events/actions. All SwitchCluster actions are mapped in groups of 3 on sub endpoints. The mapping schema is shown in log. [mqtt]: Added handles for group_add, group_remove, group_rename, group_add_member and group_remove_member

Luligu commented 4 months ago

https://github.com/Luligu/matterbridge-zigbee2mqtt?tab=readme-ov-file#conversion-strategies-between-zigbee2mqtt-and-matter-ecosystems

eric14142004 commented 4 months ago

Thanks for the update! I have testes the new changes with wireless gang buttons like https://www.zigbee2mqtt.io/devices/TS0042.html#tuya-ts0042 and they work well.

However, for special button like those ikea ones, i think the grouping needs so sort of special handling: here is the log when the 'Dot 1' button is pressed: debug - [11:23:55.141] [sonos_remote]: MQTT message for device sonos_remote payload: { action: 'dots_1_initial_press', battery: 52, linkquality: 148, update: { installed_version: 16777269, latest_version: 16777269, state: 'idle' }, update_available: null, voltage: 2500 } debug - [11:23:55.151] [sonos_remote]: Action "dots_1_initial_press" found on switch 3 endpoint 11 action Double debug - [11:23:55.152] [sonos_remote]: Trigger 'Double press' event for sonos_remote debug - [11:23:55.153] [sonos_remote]: MQTT message for device sonos_remote payload: { action: '', battery: 52, linkquality: 148, update: { installed_version: 16777269, latest_version: 16777269, state: 'idle' }, update_available: null, voltage: 2500 } warn - [11:23:55.153] [sonos_remote]: Action "" not found on actions [ 'toggle', 'track_previous', 'track_next', 'volume_up', 'volume_down', 'volume_up_hold', 'volume_down_hold', 'dots_1_initial_press', 'dots_2_initial_press', 'dots_1_long_press', 'dots_2_long_press', 'dots_1_short_release', 'dots_2_short_release', 'dots_1_long_release', 'dots_2_long_release', 'dots_1_double_press', 'dots_2_double_press' ] warn - [11:23:55.153] [sonos_remote]: Action "" not found on actions [ 'toggle', 'track_previous', 'track_next', 'volume_up', 'volume_down', 'volume_up_hold', 'volume_down_hold', 'dots_1_initial_press', 'dots_2_initial_press', 'dots_1_long_press', 'dots_2_long_press', 'dots_1_short_release', 'dots_2_short_release', 'dots_1_long_release', 'dots_2_long_release', 'dots_1_double_press', 'dots_2_double_press' ] warn - [11:23:55.153] [sonos_remote]: Action "" not found on actions [ 'toggle', 'track_previous', 'track_next', 'volume_up', 'volume_down', 'volume_up_hold', 'volume_down_hold', 'dots_1_initial_press', 'dots_2_initial_press', 'dots_1_long_press', 'dots_2_long_press', 'dots_1_short_release', 'dots_2_short_release', 'dots_1_long_release', 'dots_2_long_release', 'dots_1_double_press', 'dots_2_double_press' ] warn - [11:23:55.154] [sonos_remote]: Action "" not found on actions [ 'toggle', 'track_previous', 'track_next', 'volume_up', 'volume_down', 'volume_up_hold', 'volume_down_hold', 'dots_1_initial_press', 'dots_2_initial_press', 'dots_1_long_press', 'dots_2_long_press', 'dots_1_short_release', 'dots_2_short_release', 'dots_1_long_release', 'dots_2_long_release', 'dots_1_double_press', 'dots_2_double_press' ] warn - [11:23:55.160] [sonos_remote]: Action "" not found on actions [ 'toggle', 'track_previous', 'track_next', 'volume_up', 'volume_down', 'volume_up_hold', 'volume_down_hold', 'dots_1_initial_press', 'dots_2_initial_press', 'dots_1_long_press', 'dots_2_long_press', 'dots_1_short_release', 'dots_2_short_release', 'dots_1_long_release', 'dots_2_long_release', 'dots_1_double_press', 'dots_2_double_press' ] warn - [11:23:55.161] [sonos_remote]: Action "" not found on actions [ 'toggle', 'track_previous', 'track_next', 'volume_up', 'volume_down', 'volume_up_hold', 'volume_down_hold', 'dots_1_initial_press', 'dots_2_initial_press', 'dots_1_long_press', 'dots_2_long_press', 'dots_1_short_release', 'dots_2_short_release', 'dots_1_long_release', 'dots_2_long_release', 'dots_1_double_press', 'dots_2_double_press' ] debug - [11:23:55.161] [sonos_remote]: MQTT message for device sonos_remote payload: { state: 'dots_1_initial_press' } debug - [11:23:55.161] [sonos_remote]: Update endpoint 8 cluster 6-OnOff not found: is z2m converter exposing all features? debug - [11:23:55.957] [sonos_remote]: MQTT message for device sonos_remote payload: { action: 'dots_1_short_release', battery: 52, linkquality: 148, update: { installed_version: 16777269, latest_version: 16777269, state: 'idle' }, update_available: null, voltage: 2500 } debug - [11:23:55.959] [sonos_remote]: Action "dots_1_short_release" found on switch 4 endpoint 12 action Long debug - [11:23:55.973] [sonos_remote]: Trigger 'Long press' event for sonos_remote debug - [11:23:55.976] [sonos_remote]: MQTT message for device sonos_remote payload: { action: '', battery: 52, linkquality: 148, update: { installed_version: 16777269, latest_version: 16777269, state: 'idle' }, update_available: null, voltage: 2500 } warn - [11:23:55.976] [sonos_remote]: Action "" not found on actions [ 'toggle', 'track_previous', 'track_next', 'volume_up', 'volume_down', 'volume_up_hold', 'volume_down_hold', 'dots_1_initial_press', 'dots_2_initial_press', 'dots_1_long_press', 'dots_2_long_press', 'dots_1_short_release', 'dots_2_short_release', 'dots_1_long_release', 'dots_2_long_release', 'dots_1_double_press', 'dots_2_double_press' ] warn - [11:23:55.976] [sonos_remote]: Action "" not found on actions [ 'toggle', 'track_previous', 'track_next', 'volume_up', 'volume_down', 'volume_up_hold', 'volume_down_hold', 'dots_1_initial_press', 'dots_2_initial_press', 'dots_1_long_press', 'dots_2_long_press', 'dots_1_short_release', 'dots_2_short_release', 'dots_1_long_release', 'dots_2_long_release', 'dots_1_double_press', 'dots_2_double_press' ] warn - [11:23:55.976] [sonos_remote]: Action "" not found on actions [ 'toggle', 'track_previous', 'track_next', 'volume_up', 'volume_down', 'volume_up_hold', 'volume_down_hold', 'dots_1_initial_press', 'dots_2_initial_press', 'dots_1_long_press', 'dots_2_long_press', 'dots_1_short_release', 'dots_2_short_release', 'dots_1_long_release', 'dots_2_long_release', 'dots_1_double_press', 'dots_2_double_press' ] warn - [11:23:55.977] [sonos_remote]: Action "" not found on actions [ 'toggle', 'track_previous', 'track_next', 'volume_up', 'volume_down', 'volume_up_hold', 'volume_down_hold', 'dots_1_initial_press', 'dots_2_initial_press', 'dots_1_long_press', 'dots_2_long_press', 'dots_1_short_release', 'dots_2_short_release', 'dots_1_long_release', 'dots_2_long_release', 'dots_1_double_press', 'dots_2_double_press' ] warn - [11:23:55.977] [sonos_remote]: Action "" not found on actions [ 'toggle', 'track_previous', 'track_next', 'volume_up', 'volume_down', 'volume_up_hold', 'volume_down_hold', 'dots_1_initial_press', 'dots_2_initial_press', 'dots_1_long_press', 'dots_2_long_press', 'dots_1_short_release', 'dots_2_short_release', 'dots_1_long_release', 'dots_2_long_release', 'dots_1_double_press', 'dots_2_double_press' ] warn - [11:23:55.978] [sonos_remote]: Action "" not found on actions [ 'toggle', 'track_previous', 'track_next', 'volume_up', 'volume_down', 'volume_up_hold', 'volume_down_hold', 'dots_1_initial_press', 'dots_2_initial_press', 'dots_1_long_press', 'dots_2_long_press', 'dots_1_short_release', 'dots_2_short_release', 'dots_1_long_release', 'dots_2_long_release', 'dots_1_double_press', 'dots_2_double_press' ] debug - [11:23:55.978] [sonos_remote]: MQTT message for device sonos_remote payload: { state: 'dots_1_short_release' } debug - [11:23:55.978] [sonos_remote]: Update endpoint 8 cluster 6-OnOff not found: is z2m converter exposing all features?

and here is the log from z2m: Info 2024-04-30 11:28:01MQTT publish: topic 'zigbee2mqtt/sonos_remote', payload '{"action":"dots_1_initial_press","battery":52,"linkquality":148,"update":{"installed_version":16777269,"latest_version":16777269,"state":"idle"},"update_available":null,"voltage":2500}' Info 2024-04-30 11:28:01MQTT publish: topic 'zigbee2mqtt/sonos_remote', payload '{"action":"","battery":52,"linkquality":148,"update":{"installed_version":16777269,"latest_version":16777269,"state":"idle"},"update_available":null,"voltage":2500}' Info 2024-04-30 11:28:01MQTT publish: topic 'zigbee2mqtt/sonos_remote/action', payload 'dots_1_initial_press' Info 2024-04-30 11:28:02MQTT publish: topic 'zigbee2mqtt/sonos_remote', payload '{"action":"dots_1_short_release","battery":52,"linkquality":160,"update":{"installed_version":16777269,"latest_version":16777269,"state":"idle"},"update_available":null,"voltage":2500}' Info 2024-04-30 11:28:02MQTT publish: topic 'zigbee2mqtt/sonos_remote', payload '{"action":"","battery":52,"linkquality":160,"update":{"installed_version":16777269,"latest_version":16777269,"state":"idle"},"update_available":null,"voltage":2500}' Info 2024-04-30 11:28:02MQTT publish: topic 'zigbee2mqtt/sonos_remote/action', payload 'dots_1_short_release'

it seems like "dots_1_initial_press" and "dots_1_short_release" will always happen in a group

Luligu commented 4 months ago

Hi. MQTT message for device sonos_remote payload: { action: '' this is wrong there is no action sent from z2m so this why you see action not found. The buttons are mapped as you see in the log when the plugin starts from what z2m exposes. Then if z2m send action '' there is nothing to do.

(update and update_available are not useful you can put them in featureBlackList if you want to have the log cleaner).

eric14142004 commented 4 months ago

Well I did noticed the action '', but that's not the main problem. The problem is "dots_1_initial_press" and "dots_1_short_release" will always happen together.

From the logs I provided: 11:28:01: MQTT publish "dots_1_initial_press" 11:28:02: MQTT publish "dots_1_short_release"

I didn't pressed the button two times, "dots_1_short_release" will be published after the button got released.

However, "dots_1_initial_press" and "dots_1_short_release" are mapped to two different buttons in matterbridge: info - [13:56:34.712] [sonos_remote]: -- Button 1: Single Press <=> toggle info - [13:56:34.713] [sonos_remote]: -- Button 1: Double Press <=> track_previous info - [13:56:34.714] [sonos_remote]: -- Button 1: Long Press <=> track_next info - [13:56:34.718] [sonos_remote]: -- Button 2: Single Press <=> volume_up info - [13:56:34.719] [sonos_remote]: -- Button 2: Double Press <=> volume_down info - [13:56:34.723] [sonos_remote]: -- Button 2: Long Press <=> volume_up_hold info - [13:56:34.724] [sonos_remote]: -- Button 3: Single Press <=> volume_down_hold info - [13:56:34.725] [sonos_remote]: -- Button 3: Double Press <=> dots_1_initial_press info - [13:56:34.725] [sonos_remote]: -- Button 3: Long Press <=> dots_1_long_press info - [13:56:34.728] [sonos_remote]: -- Button 4: Single Press <=> dots_1_short_release info - [13:56:34.729] [sonos_remote]: -- Button 4: Double Press <=> dots_1_long_release info - [13:56:34.732] [sonos_remote]: -- Button 4: Long Press <=> dots_1_double_press info - [13:56:34.735] [sonos_remote]: -- Button 5: Single Press <=> dots_2_initial_press info - [13:56:34.736] [sonos_remote]: -- Button 5: Double Press <=> dots_2_long_press info - [13:56:34.738] [sonos_remote]: -- Button 5: Long Press <=> dots_2_short_release info - [13:56:34.741] [sonos_remote]: -- Button 6: Single Press <=> dots_2_long_release info - [13:56:34.742] [sonos_remote]: -- Button 6: Double Press <=> dots_2_double_press

This means two buttons will be triggered at the same time.

Luligu commented 4 months ago

image This is what you should see in Matterbridge log when an event is triggered.

eric14142004 commented 4 months ago

No, that's a scene button, not IKEA SYMFONISK remote. The way z2m publish topic for scene button and SYMFONISK is different.

z2m does not even publish action 'single' for SYMFONISK remote, the actions it exposes are documented here: https://www.zigbee2mqtt.io/devices/E2123.html#ikea-e2123

most of the scene buttons don't have a status of press release, but SYMFONISK does:

Screenshot 2024-05-02 at 12 47 40 PM

So one of the way to deal with it I image is to avoid mapping any mqtt topics that have suffix/prefix "_release", otherwise it will always end up trigger multiple actions, I found that homebridge-z2m has a similar handling for this: https://github.com/itavero/homebridge-z2m/blob/c02eb2d668dd3e8a021aac529a6bc45aca14a661/src/converters/action_helper.ts

Screenshot 2024-05-02 at 12 58 04 PM
Luligu commented 4 months ago

Ok, I got it. image Can you send me this part of the console log about your IKEA SYMFONISK please?

eric14142004 commented 4 months ago

Hello,

I did in my previous response, plesae let me know if you need more logs, thanks!

info - [13:56:34.712] [sonos_remote]: -- Button 1: Single Press <=> toggle info - [13:56:34.713] [sonos_remote]: -- Button 1: Double Press <=> track_previous info - [13:56:34.714] [sonos_remote]: -- Button 1: Long Press <=> track_next info - [13:56:34.718] [sonos_remote]: -- Button 2: Single Press <=> volume_up info - [13:56:34.719] [sonos_remote]: -- Button 2: Double Press <=> volume_down info - [13:56:34.723] [sonos_remote]: -- Button 2: Long Press <=> volume_up_hold info - [13:56:34.724] [sonos_remote]: -- Button 3: Single Press <=> volume_down_hold info - [13:56:34.725] [sonos_remote]: -- Button 3: Double Press <=> dots_1_initial_press info - [13:56:34.725] [sonos_remote]: -- Button 3: Long Press <=> dots_1_long_press info - [13:56:34.728] [sonos_remote]: -- Button 4: Single Press <=> dots_1_short_release info - [13:56:34.729] [sonos_remote]: -- Button 4: Double Press <=> dots_1_long_release info - [13:56:34.732] [sonos_remote]: -- Button 4: Long Press <=> dots_1_double_press info - [13:56:34.735] [sonos_remote]: -- Button 5: Single Press <=> dots_2_initial_press info - [13:56:34.736] [sonos_remote]: -- Button 5: Double Press <=> dots_2_long_press info - [13:56:34.738] [sonos_remote]: -- Button 5: Long Press <=> dots_2_short_release info - [13:56:34.741] [sonos_remote]: -- Button 6: Single Press <=> dots_2_long_release info - [13:56:34.742] [sonos_remote]: -- Button 6: Double Press <=> dots_2_double_press

Well I did noticed the action '', but that's not the main problem. The problem is "dots_1_initial_press" and "dots_1_short_release" will always happen together.

From the logs I provided: 11:28:01: MQTT publish "dots_1_initial_press" 11:28:02: MQTT publish "dots_1_short_release"

I didn't pressed the button two times, "dots_1_short_release" will be published after the button got released.

However, "dots_1_initial_press" and "dots_1_short_release" are mapped to two different buttons in matterbridge: info - [13:56:34.712] [sonos_remote]: -- Button 1: Single Press <=> toggle info - [13:56:34.713] [sonos_remote]: -- Button 1: Double Press <=> track_previous info - [13:56:34.714] [sonos_remote]: -- Button 1: Long Press <=> track_next info - [13:56:34.718] [sonos_remote]: -- Button 2: Single Press <=> volume_up info - [13:56:34.719] [sonos_remote]: -- Button 2: Double Press <=> volume_down info - [13:56:34.723] [sonos_remote]: -- Button 2: Long Press <=> volume_up_hold info - [13:56:34.724] [sonos_remote]: -- Button 3: Single Press <=> volume_down_hold info - [13:56:34.725] [sonos_remote]: -- Button 3: Double Press <=> dots_1_initial_press info - [13:56:34.725] [sonos_remote]: -- Button 3: Long Press <=> dots_1_long_press info - [13:56:34.728] [sonos_remote]: -- Button 4: Single Press <=> dots_1_short_release info - [13:56:34.729] [sonos_remote]: -- Button 4: Double Press <=> dots_1_long_release info - [13:56:34.732] [sonos_remote]: -- Button 4: Long Press <=> dots_1_double_press info - [13:56:34.735] [sonos_remote]: -- Button 5: Single Press <=> dots_2_initial_press info - [13:56:34.736] [sonos_remote]: -- Button 5: Double Press <=> dots_2_long_press info - [13:56:34.738] [sonos_remote]: -- Button 5: Long Press <=> dots_2_short_release info - [13:56:34.741] [sonos_remote]: -- Button 6: Single Press <=> dots_2_long_release info - [13:56:34.742] [sonos_remote]: -- Button 6: Double Press <=> dots_2_double_press

This means two buttons will be triggered at the same time.

Luligu commented 4 months ago

So basically, if I understand correctly, you would like some mechanism to exclude not only an exposed feature but a single element of the action expose like dots_1_short_release or whatever you decide to put on this list? But if you don't set any automation in your controller for dots_1_short_release is the same. Isn't it? Just ignore Button 4: Single Press in your controller.

BTW In the the release of a few hours ago I added to ignore actions with empty value.

eric14142004 commented 4 months ago

You do have a point here, and that how I was using the remote these few days :laughing:

I think it is more like something nice to have.

What keep bothers me here is it is hard to keep track of which buttons are mapped to which homekit buttons when creating automation, I had to either look at the mapping table from the logs, or just keep pressing the button and see which two buttons got triggered in the Home app.

Luligu commented 4 months ago

I use another system there. Instead of the Home app, use the Eve app: there you press a button and the app shows it graphically even if there is no automation attached. It's super easy with the Eve app cause you have all subendpoints visible on the same page. Or use zigbee2mqtt-automations that is more powerfull and faster cause is directly inside z2m. https://github.com/Luligu/zigbee2mqtt-automations?tab=readme-ov-file#zigbee2mqtt-automations

eric14142004 commented 4 months ago

That is a wonderful advice, I don't have to keep pressing those buttons anymore.

Luligu commented 4 months ago

Glad everything is ok. Thanks you for your interest.