jesserockz / wizmote-esphome

Apache License 2.0
66 stars 30 forks source link

Improved support of multiple remotes #9

Closed jonofmac closed 1 year ago

jonofmac commented 1 year ago

The official version breaks when multiple remotes are used. This patch is not perfect, but works with multiple remotes with the following limitation: Filtering out duplicate messages does not work when multiple remotes are pressed at the same time, causing what appears to be multiple presses. This occurs only when multiple remotes have a button pressed at the same time.

Updates were made to the .cpp file to check for duplicate espnow messages.

Updates were also made to the blueprint yml file to add verification of remote mac address for all triggers, not just the first.

jonofmac commented 1 year ago

I went and added an array that keeps track of unique MAC addresses and sequence IDs, for up to 15 remotes (though the value is a static define in the .h file. This fixes the duplicate button pressing issues and appears to support multiple remotes correctly. I decided to use a fixed array size to eliminate the risk of a memory issue for long-running instances.

sippe2 commented 1 year ago

Awesome improvement. 👍 Just wondering is it possible to create "double click" or even "triple click" feature to number buttons? It would be clever way to call eg. scenes and so on.

jonofmac commented 1 year ago

Awesome improvement. 👍 Just wondering is it possible to create "double click" or even "triple click" feature to number buttons? It would be clever way to call eg. scenes and so on.

Absolutely is possible. You don't even need updates to these files to do it. The events for all button presses are sent to home assistant. You just need to update the blueprint code to add the ability to count the number of presses within a timer window.

I've got a few different versions of the blueprint depending on what I want it to control. I've got one that will store the last group number for an hour and then it changes to a default group. That way if someone picks up a remote and just presses on, it'll be default turn on lights.

The double and triple click functionality can be implemented entirely in a blueprint, but I haven't personally done it.

My PR request here simply allows the esp32 to recognize different remotes and pass that info on to home assistant so that different remotes can be recognized. Home assistant parses the button press events.

jesserockz commented 1 year ago

Apologies for the delay here. My own repos get forgotten by me a lot as I am so busy with the main ESPHome ones.

jrspowers commented 1 year ago

Awesome improvement. 👍 Just wondering is it possible to create "double click" or even "triple click" feature to number buttons? It would be clever way to call eg. scenes and so on.

Absolutely is possible. You don't even need updates to these files to do it. The events for all button presses are sent to home assistant. You just need to update the blueprint code to add the ability to count the number of presses within a timer window.

I've got a few different versions of the blueprint depending on what I want it to control. I've got one that will store the last group number for an hour and then it changes to a default group. That way if someone picks up a remote and just presses on, it'll be default turn on lights.

The double and triple click functionality can be implemented entirely in a blueprint, but I haven't personally done it.

My PR request here simply allows the esp32 to recognize different remotes and pass that info on to home assistant so that different remotes can be recognized. Home assistant parses the button press events.

Hey, could you share the blueprint you've created? It sounds interesting.