jesserockz / wizmote-esphome

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Two Wizmote simultaneosly

hirkkak opened this issue · comments

Hello, Congratulations for your work, first of all.

I had a wizmote controller and it has been very useful for me to make it work with HA. The fact is that I decided to buy a second controller to have the same functions twice. But it only works when I put the MAC field, which also doesn't support multiple values (or I don't know how to put them). And if I don't fill it, only the first wizmote works. Is there any solution for this? Is there a way to make both work simultaneously?.

Greetings and thank you very much!

EDIT:
After some more testing, the new controller no longer works.
No event is heard (using developer options)
Neither esphome.wizmote_choose nor esphome.wizmote_action
But if both events are shown in the esphome log

Off button of the remote that not works.
[01:10:07][D][esp_now:071]: mac: 6C.29.90.0D.6A.1E (6), data: 81.E3.02.00.00.20.02.01.57.4F.72.5F.E5 (13)

Off button of the remote that works.
[01:10:50][D][esp_now:071]: mac: 6C.29.90.06.0D.AE (6), data: 81.DA.05.00.00.20.02.01.54.6C.E3.F7.B9 (13)

EDIT2: The new controller randomly works(some days it works and other days it doesn't). How can i debug it?

The blueprint is only set up for a single remote. You need to set up two automations from the blueprint, or you could modify the blueprint to support multiple remotes.

As for you other issue, I am not too sure. The logs you are seeing above are showing that the remote is sending and ESPHome is receiving correctly.

I think it is to do with last_sequence being shared amongst all on_esp_now_message calls rather than saving the last_sequence per remote mac address.

Whichever message (remote) has the highest wizmote.sequence number will trigger wizmote on_button.

I have two remote here and only one usually fires events into home assistant yet both remotes are being seen in the esphome logs.

If I keep clicking the non-responsive remote enough times to have a higher sequence number, it will begin to function then the other remote will fail until its sequence number is the highest. This probably explains the behavior @hirkkak is seeing.

I discovered that new remote works only when i reboot HA, until i use any button on the old one.
Then only works the first one until i reboot HA again.

I tried to use same button on the old one for about 100 times, but didn`t work. Any idea?

I think you may need to press the buttons on the new remote many more times. This will not solve the issue but will confirm it is the same one I have observed.

Could you press the number 1 on each remote and post the esphome log output here?

Hi, here is the conclusion.

Button 3, on Working Wiz1 Remote:
[00:39:19][D][esp_now:071]: mac: 6C.29.90.06.0D.AE (6), data: 81.65.06.00.00.20.12.01.54.EF.1E.84.B5 (13)

Button 3, on NON Working Wiz2 Remote:
[00:39:52][D][esp_now:071]: mac: 6C.29.90.0D.6A.1E (6), data: 81.8C.04.00.00.20.12.01.47.17.9E.64.53 (13)

Button 3, on NON Working Wiz2 remote after about 100 clicks.
[00:41:03][D][esp_now:071]: mac: 6C.29.90.0D.6A.1E (6), data: 81.F7.04.00.00.20.12.01.50.BB.93.34.33 (13)

Buttton 3, on WORKING Wiz1:
[00:41:40][D][esp_now:071]: mac: 6C.29.90.06.0D.AE (6), data: 81.66.06.00.00.20.12.01.54.16.CD.0E.DB (13)

Button 3, on NON Working Wiz2 remote after thousands clicks.
[00:45:44][D][esp_now:071]: mac: 6C.29.90.0D.6A.1E (6), data: 81.65.06.00.00.20.12.01.48.4A.A6.9D.10 (13)

Button 3, on WORKING Wiz2 remote after thousands clicks + 2.
[00:46:14][D][esp_now:071]: mac: 6C.29.90.0D.6A.1E (6), data: 81.67.06.00.00.20.12.01.51.6E.F0.FB.20 (13)

So you are right. The highest one, wins!!

Now, if i click 3 times on wiz 1, have to click other 3 on wiz2 to get working and vice versa

The question is? There is some magical and extra easy solution? ;-)

Thx in advance for all, and sorry for delay, away from home.

Hi i replaced '<=' by '==' it seem works perfectly on wizmote.cpp

void WizMoteListener::on_esp_now_message(esp_now::ESPNowPacket packet) {
WizMotePacket wizmote = WizMotePacket::build(packet);
//if (wizmote.sequence <= this->last_sequence_)
if (wizmote.sequence == this->last_sequence_)
return;

this->last_sequence_ = wizmote.sequence;
this->on_button_->trigger(wizmote);
}

Ah sorry, I misunderstood your original issue. Yeah this makes perfect sense that the sequence needs to be unique per remote mac. I will try make some time to fix this.

@jesserockz was this ever corrected?

It doesn't look like the change from @hirkkak was ever pushed, but I went and made it myself and can confirm both of my WIZ remotes now work correctly.

Off topic, and pardon my ignorance but does one need a ESP32 board dedicated to capture the wizmote packets or can Home Assistant's ESPHome do that by itself? @bbass101

I forked the repo and added the fix listed above by @hirkkak and updated the blueprint to support multiple remotes. There is an issue with it: If multiple remotes have a button pressed at the same time, it will appear that the buttons were pressed multiple times. #9

I have an idea on how to better fix it, but it will have a limitation on how many remotes it can support...

Edit: I updated my fork with my idea of a fix. Added an array that fixes the bug I mentioned earlier. Now it supports up to 15 remotes without the multiple button press issues I mentioned. Not the most elegant solution, but it works.