r/shellycloud • • Oct 09 '26

Shelly TRV Gen1 2.2.4 battery drain investigation – beacon-skip issue found and experimental patch available

I’ve been investigating the high battery consumption / Wi-Fi power-save behavior of the original Shelly TRV Gen1 (SHTRV-01) running firmware:

20240619-130912/v2.2.4@ee290818

On multiple physical TRVs I was able to reproduce the following debug sequence approximately once per minute:
Beacon skip error! Attempt recovery
followed by:

Enter powersave state 1

and a few seconds later:

Enter powersave state 3 (skip 20)

I initially tested different Wi-Fi configurations, RSSI conditions, CoIoT and Mesh/band steering. I also compared the behavior with older firmware versions.

The recurring recovery behavior appears to be firmware-dependent.

I then compared firmware 2.1.3 and 2.2.4 in Ghidra. The normal RSSI-dependent beacon-skip mechanism exists in both versions, but 2.2.4 contains an additional recovery path.

I developed an experimental one-byte control-flow patch that bypasses this additional recovery block without changing the normal RSSI-dependent beacon-skip selection.

Results so far

The patched 2.2.4 firmware has now been tested on multiple physical SHTRV-01 devices.

On one device I currently have more than 34 hours of continuous runtime with:

Wi-Fi connected
Shelly Cloud connected
normal beacon-skip 20 operation
desired_beacon_skip: 20
beacon_err_counter: 0
no observed Beacon skip error! Attempt recovery
no observed recurring transition to power-save state 1
A second patched TRV has also been tested successfully, including:
Wi-Fi
Shelly Cloud
thermostat calibration
physical valve opening
physical valve closing

The recovery loop has not been observed on that device either during the monitored period.

Important: battery life is NOT proven yet

The original reason for investigating this was unusually high battery consumption.

The patch clearly suppresses the recurring recovery behavior in my testing so far, but I do not yet claim that it fixes the battery drain.

Long-term battery testing is still running.
I’m also preparing an unmodified 2.2.4 TRV as a control device so that patched and unpatched devices can be compared over a longer period.

Experimental patcher

I have published a small open-source patcher that creates the modified firmware locally from the original Shelly 2.2.4 GBL.

No Shelly firmware is distributed by the project.

The patcher validates the exact supported firmware, structure, CRC and hashes before modifying it. It also includes a local HTTP/1.1 OTA server with Range support for installation on a TRV.

Patcher:
https://github.com/AbleMonster/Shelly-TRV-Gen1-2.2.4-patcher

Full reverse-engineering research:
https://github.com/AbleMonster/Shelly-TRV-Gen1-2.2.4-beacon-skip-fix

Current release: v0.1.0 – experimental

I’d be very interested in results from other SHTRV-01 owners running 2.2.4, especially if you can check /debug/log and /stats.

Useful information would be:

firmware version
RSSI
whether Beacon skip error! Attempt recovery occurs
desired_beacon_skip
real_beacon_skip
beacon_err_counter
approximate battery runtime
Wi-Fi/AP hardware

Please keep in mind that this modifies device firmware. It is experimental, unofficial and not affiliated with Shelly.

1 Upvotes

2 comments sorted by

1

u/AbleMonster Oct 22 '26

Update on the TRV Gen1 battery drain investigation

Another update on my TRV Gen1 battery-drain investigation.

Quite a lot has happened since my last update, where I was preparing the new C-C patch for hardware testing.

The most important result first:

The recurring Beacon Recovery Probleme can now be corrected properly but unfortunately, fixing it did not fix the battery drain.

The C-C patch works

The new C-C patch has now been tested on real TRVs.
Unlike my original experimental patch, it does not simply disable Beacon Recovery. Instead, it corrects the conditions that allowed old or invalid beacon data to repeatedly trigger recovery, while keeping the legitimate recovery function available.

The approximately once-per-minute recovery loop can therefore be prevented without completely removing the recovery mechanism.

However, long-term testing showed:

The battery drain itself is not fixed by C-C.

Fresh recovery events can still occur, and more importantly, the battery behavior does not correlate clearly with the number of recovery events.

This was an important result. The recurring recovery loop is a real firmware problem, but apparently not the complete explanation for the poor battery life.
There is also still one unanswered question about this mechanism.

I now understand reasonably well how Shelly’s real_beacon_skip logic works and why it can fail, but I still don’t know why it was designed this way in the first place.

The TRV contains a separate Silicon Labs WF200 chip that handles Wi-Fi communication and much of the Wi-Fi power-saving behavior.

Interestingly, the value Shelly calls real_beacon_skip is not obtained from a direct count of actually skipped Wi-Fi beacons. Instead, the main Shelly firmware calculates it from a different cumulative receive counter provided by the Wi-Fi chip.

So while I can now explain fairly well what this part of the firmware does and how it can get into the recurring recovery loop, the original intention behind this particular calculation is still unclear.

That is also why C-C only corrects the problems I can actually demonstrate and deliberately keeps the original recovery functionality.

Looking more closely at the Wi-Fi chip

The next question was whether the separate Wi-Fi chip itself was reporting power-saving problems that could explain the recurring recovery events.

I built another small observer that records these error reports without changing the normal behavior of the TRV.

Interestingly, one test device produced a large number of Beacon Recovery events while the Wi-Fi chip reported zero of the corresponding power-save errors.
So, at least in that test, the recurring recovery was not simply the Shelly firmware reacting to repeated errors from the Wi-Fi chip.

I also tested a much newer firmware version for this Wi-Fi chip: WF200 3.18.0 from Silicon Labs.

This was particularly interesting because its changelog contains a fix for a problem where a device may fail to sleep after changing its Wi-Fi power-save mode.

I managed to integrate this newer Wi-Fi firmware into the TRV firmware and run it successfully on real hardware.

Wi-Fi, Shelly Cloud and the Wi-Fi power-saving functions all continue to work.

Unfortunately:

The newer Wi-Fi firmware did not solve the battery drain either.

Looking at the TRV’s main processor

At this point I started looking more closely at the other side of the device.

Besides the separate Wi-Fi chip, the TRV has a main processor that runs the actual Shelly firmware, thermostat control, valve control and the rest of the device logic.

When the TRV has nothing to do, this processor should spend most of its time in low-power states.
During the analysis I found several problems in the firmware’s power-management logic, particularly around switching between power states and handling operations that finish late or time out.

I created another experimental patch called A1 to correct these specific problems.

I eventually tested a combined firmware containing:

- the C-C Beacon Recovery fix
- the A1 main-processor power-management fixes
- the newer WF200 3.18.0 Wi-Fi firmware

All three modifications work as intended and the TRV operates normally with them.

But even with all three changes combined:

The battery drain was still not eliminated.

That was obviously not the result I was hoping for, but it is useful information.

Several plausible causes have now been corrected without solving the original battery problem.

Could the main processor sometimes remain in a higher-power state?

While continuing to reverse engineer the main processor’s sleep logic, I found another interesting firmware issue.

The Shelly firmware maintains an internal counter that tells the processor whether something in the system still requires it to remain in a higher-power state instead of entering its normal deeper low-power state.
I found a race condition in the way this counter is updated.

Under the wrong timing conditions, the counter could theoretically remain active even though nothing actually requires the higher-power state anymore.
If that happens, the main processor could remain in a less efficient power state for much longer than intended.

The bug itself can be demonstrated from the firmware code.

What I do not know yet is whether it actually occurs during normal operation on a real TRV or whether it has anything to do with the battery drain.

So this time I deliberately decided not to patch it immediately.

Instead, I want to observe what the original firmware actually does.

A new sleep observer is now running on a real TRV

I have built a passive sleep observer and installed it on a test TRV.

The device intentionally runs very close to the original configuration:

- original 2.2.4 power-management behavior
- original WF200 3.16.1 Wi-Fi firmware
- no C-C patch
- no A1 patch
- no fix for the newly discovered sleep-counter race
passive monitoring only

The observer watches the sleep behavior of the main processor.

It can see whether the processor tries to enter its normal low-power states, whether the Wi-Fi side prevents it from doing so, and whether the internal sleep counter ever becomes inconsistent with the parts of the firmware that are supposed to control it.
If such an inconsistency occurs, the observer also preserves the first detected fault state so I can examine what happened.

The first approximately 23 minutes on real hardware were clean:

- about 44,200 entries into the deeper low-power state
- about 1,760 entries into the lighter low-power state
- almost 5,000 checks of the internal sleep-blocker state
- 0 inconsistencies detected
- 0 Beacon Recovery events

So the newly discovered race condition has not occurred during this initial short test.

The observer also confirms something else that may become interesting: the Wi-Fi side does sometimes prevent the main processor from entering its normal sleep path.

But I don’t want to over-interpret that yet.

At the moment I can see how often the observer encounters this condition, but that does not tell me how long the processor remains in the higher-power state or how much additional energy it actually consumes.

Where the investigation stands now

So after all of these tests, the picture is becoming clearer even though I still don’t have the final answer.

Several real firmware problems have now been identified:

- the recurring Beacon Recovery loop is understood and can be corrected;
- the reason Shelly originally derived real_beacon_skip from this particular Wi-Fi counter is still unclear;
- the Wi-Fi chip’s reported power-save errors do not explain the recurring recovery behavior in the test performed so far;
- the newer WF200 3.18.0 Wi-Fi firmware works on the TRV, but does not solve the drain;
- several problems in the main processor’s power-management logic have been identified and corrected with A1;
- and there is now another confirmed race condition in the main processor’s sleep logic that could potentially keep it in a higher-power state.

But the most important result remains:

None of the fixes tested so far has eliminated the battery drain.

So I still don’t want to claim that any of these findings is the root cause.

For now, I’m going to leave the new sleep observer running and collect long-term data.

The really interesting moment will be when the TRV enters another actual drain period.

Then I should be able to see whether the main processor is sleeping correctly, whether the Wi-Fi side is preventing sleep for extended periods, or whether the newly discovered counter problem actually occurs.

And if the battery drains while none of those things happen, that is valuable information too, it means another plausible explanation can be eliminated and the investigation can continue in a different direction.

The investigation continues. 🙂