pauln / esphome-linp-doorbell-g04

ESPHome custom component for Linptech G6L-Wifi doorbell (linp-doorbell-g04)
MIT License
14 stars 4 forks source link

Receiver doeasn't always react to the button #3

Closed plantroon closed 1 year ago

plantroon commented 1 year ago

I have 2 receivers. One still has the original firmware - and is further away from the transmitter button (in another room on another floor) - and it reacts to the button press (this is desired). Yet the esphome-flashed receiver which is in the same room as the button does not always react - there's nothing in the esphome logs either when it ignores the button press.

I was wondering if what filters the RF was made less sensitive on this esphome firmware?

I do not care much about repeated presses and stuff like that, I'll have that handled in HASS. I just want the stock-like reliability if it's possible.

P.S.: I was wondering, how did you @pauln open up the casing? I used a drill and pried open mine through the drilled holes. I tried not to destroy it but then wrecked the casing anyway. I will be flashing the other receiver and I want to try to not wreck it.

pauln commented 1 year ago

I reverse-engineered the buttons' RF protocol using rtl_433 and a compatible USB TV tuner dongle, so although I got close enough to decode the buttons I had at hand pretty reliably, there's almost certainly room for improvement. It's also possible that the original firmware does something extra or has wider tolerances to account for the timing likely not being entirely consistent because of the small (and presumably variable) amount of energy supplied by the kinetic generator when you press the button.

You might be able to get some improvement by tweaking the filter and idle timings in the remote_receiver configuration block, but there's not a huge amount of wiggle room before you'll stop being able to decode any presses at all. If you set the log level to VERY_VERBOSE, the protocol decoder should give you some extra logs, starting with a "Potential button press detected" message when it sees something which might be a valid transmission, followed by one or more messages for "0 detected" or "1 detected" if it sees valid-looking bits or "invalid bit detected" if it sees unexpected values. You'll probably find that it sees valid-looking bits in the random background noise when nobody's pressing the button(s), but it might at least let you see whether it's catching (part of) the actual transmissions as well.

As for the case, I've had some luck opening them by squeezing the sides in a vice, but it's not easy to get them to pop open in a clean, reusable way - but I prefer to run it off USB anyway, as I haven't seen them available with an AU/NZ plug (and adapters tend to make them stick out quite a lot), so I 3D printed a replacement case. The older g03 version has convenient 5V pads which it can be powered from, but the newer g04 version only has 3.3V pads exposed (unless there's an unlabelled 5V pad or there's a newer revision with one) so you need a voltage regulator to run them off USB.

plantroon commented 1 year ago

You might be able to get some improvement by tweaking the filter and idle timings in the remote_receiver configuration block, but there's not a huge amount of wiggle room before you'll stop being able to decode any presses at all. If you set the log level to VERY_VERBOSE, the protocol decoder should give you some extra logs, starting with a "Potential button press detected" message when it sees something which might be a valid transmission, followed by one or more messages for "0 detected" or "1 detected" if it sees valid-looking bits or "invalid bit detected" if it sees unexpected values. You'll probably find that it sees valid-looking bits in the random background noise when nobody's pressing the button(s), but it might at least let you see whether it's catching (part of) the actual transmissions as well.

I am getting those potential presses detected (when I press it just right, but our visitors manage it 3 out of 10 times xD) but I don't know where to go from there - do I just play with the remote_receiver settings - filter or idle as well?

Also, the very verbose logging kills the poor thing and my browser as well :D But it's usable

As for the case, I've had some luck opening them by squeezing the sides in a vice, but it's not easy to get them to pop open in a clean, reusable way - but I prefer to run it off USB anyway, as I haven't seen them available with an AU/NZ plug (and adapters tend to make them stick out quite a lot), so I 3D printed a replacement case. The older g03 version has convenient 5V pads which it can be powered from, but the newer g04 version only has 3.3V pads exposed (unless there's an unlabelled 5V pad or there's a newer revision with one) so you need a voltage regulator to run them off USB.

I tried a vice but felt like pushing harder would break it. I tried lots of things and ended up with the drill + prying it open xD but your approach is probably the best - I'd just use the cheap programmer I flashed it with as it had 3.3V (modified CH341 for a few euros). However, I don't really have any device or alternative PSU to connect my receiver to, so the AC it came with is very convenient for me.

pauln commented 1 year ago

I am getting those potential presses detected (when I press it just right, but our visitors manage it 3 out of 10 times xD) but I don't know where to go from there - do I just play with the remote_receiver settings - filter or idle as well?

Are you getting the potential presses logged when the button is pressed but ESPHome doesn't detect it? If so, how many valid bits does it detect (log lines saying "0 detected" or "1 detected" between the "potential button press detected" and "invalid bit detected" log lines) for a "missed" press?

Yes, adjusting the remote_receiver settings is probably the main thing you can try (at least without getting too far into the code).

Also, the very verbose logging kills the poor thing and my browser as well :D But it's usable

Yes, unfortunately it can end up logging a lot at VERY_VERBOSE level. If you're comfortable downloading the code and using it as a custom component (or an external component pointed at a folder on your computer), you could change the calls to ESP_LOGVV in the decoder to ESP_LOGD and set your log level to DEBUG (or use ESP LOGI with a log_level of INFO) to cut down on the logs from other parts of ESPHome.

I tried a vice but felt like pushing harder would break it. I tried lots of things and ended up with the drill + prying it open xD

I think I had the most luck squeezing the edges at the very front of the case (the face with the buttons, not the power prongs), but it was quite a long time ago so I'm not actually sure how well it went back together even when I opened one reasonably cleanly - I have a feeling that it might not have gone back together very securely, so you'd probably have to glue it back together (especially if you stick with mains power) even in the best case.

plantroon commented 1 year ago

I am getting those potential presses detected (when I press it just right, but our visitors manage it 3 out of 10 times xD) but I don't know where to go from there - do I just play with the remote_receiver settings - filter or idle as well?

Are you getting the potential presses logged when the button is pressed but ESPHome doesn't detect it? If so, how many valid bits does it detect (log lines saying "0 detected" or "1 detected" between the "potential button press detected" and "invalid bit detected" log lines) for a "missed" press?

It says 0 detected every time, just this:

[09:05:38][VV][remote.linptech_g6l:044]: Potential button press detected
[09:05:38][VV][remote.linptech_g6l:053]: 0 detected
[09:05:38][VV][remote.linptech_g6l:055]: invalid bit detected
[09:05:38][VV][remote.linptech_g6l:044]: Potential button press detected
[09:05:38][VV][remote.linptech_g6l:053]: 0 detected
[09:05:38][VV][remote.linptech_g6l:055]: invalid bit detected
[09:05:38][VV][remote.linptech_g6l:044]: Potential button press detected
[09:05:38][VV][remote.linptech_g6l:053]: 0 detected
[09:05:38][VV][remote.linptech_g6l:055]: invalid bit detected

Yes, adjusting the remote_receiver settings is probably the main thing you can try (at least without getting too far into the code).

Any hint on which one to increase/decrease and at what increments?

pauln commented 1 year ago

It says 0 detected every time, just this:

Was that when the button was pressed? If so, that's interesting - it suggests that it's not managing to detect any "1" bits, which is strange.

Any hint on which one to increase/decrease and at what increments?

It's been quite a while since I did the initial work on decoding the protocol and building the decoder, so I'm not really sure sorry - but if you're seeing the "potential button press detected" logs all the time (when nobody is pressing the button), you might want to increase the filter by a few us (not too much, as the shortest pulses in the protocol are only ~37us - so if you get too close to that, you might filter out actual transmissions). You might also want to try increasing the tolerance (the default is 25%, but I didn't include it in the sample yaml as I found that the default worked pretty well for me).

plantroon commented 1 year ago

It says 0 detected every time, just this:

Was that when the button was pressed? If so, that's interesting - it suggests that it's not managing to detect any "1" bits, which is strange.

Oh I forgot to clarify. Yes, only when the button was pressed. To be honest, I don't even care about false detections, I'd filter them out eventually, somehow. This is only for me and notifications which I don't mind getting too many of, and the other receiver is for the other members of the household still on stock firmware and working fine.

Any hint on which one to increase/decrease and at what increments?

It's been quite a while since I did the initial work on decoding the protocol and building the decoder, so I'm not really sure sorry - but if you're seeing the "potential button press detected" logs all the time (when nobody is pressing the button), you might want to increase the filter by a few us (not too much, as the shortest pulses in the protocol are only ~37us - so if you get too close to that, you might filter out actual transmissions). You might also want to try increasing the tolerance (the default is 25%, but I didn't include it in the sample yaml as I found that the default worked pretty well for me).

In my short time debugging this I did not see any false "Potential button press detected". I am going towards making it more "tolerant", not trying to filter out noise. So can I tweak tolerance setting to have those "potential button press detected" register as actual button press? Well, I am gonna try. Thanks for all the help so far.

pauln commented 1 year ago

In my short time debugging this I did not see any false "Potential button press detected". I am going towards making it more "tolerant", not trying to filter out noise. So can I tweak tolerance setting to have those "potential button press detected" register as actual button press?

That suggests that you're probably not having noise issues - so the timing is probably a little bit off. In that case, I'd try increasing the tolerance - maybe try 33% first, and maybe even 50% if that still doesn't reliably detect button presses. Hopefully you won't need to go any higher than that.

pauln commented 1 year ago

Out of interest, if you have a button which isn't stuck to anything (so you can see the back of it), can you check whether the details match mine? (Original + Google Translate version for reference) g6l-tw g6l-tw-translated

plantroon commented 1 year ago

Out of interest, if you have a button which isn't stuck to anything (so you can see the back of it)

My buttons have the stock 3M tape on them - I took it down from one of them to see and there's no text on the back - or maybe I am looking wrong? Where is it - the middle or around the sides somewhere? I didn't fully take off the 3M tape yet but I don't see any text under it either.

My receiver has this: Screenshot_20221110-110813_Google

pauln commented 1 year ago

The text is right in the middle (visible through a big hole in the middle of the tape) on my buttons - the circle visible in the photos is the inside edge of a ring of (thick foam) tape. Don't worry if you can't see any details on the buttons - I just wondered whether they might've made a new version with a new model number. Hopefully adjusting the tolerance will do the trick.

plantroon commented 1 year ago

Nothing on the buttons: 20221110_124258

plantroon commented 1 year ago

I can report that it's been working flawlessly since I set the tolerance to 33% about 4 days ago. Thanks a lot.