Open DAVe3283 opened 3 months ago
I can confirm the exact same behavior as detailed above.
Took some time to dig into this and I have some better info. I did verify that this only occurs on ESPHome 2024.5.0 or newer (most of my testing is on the dev branch).
Rebooting does NOT change the behavior as I initially thought. It is perfectly repeatable on a given firmware, either always working, or never working. The frequent rebooting was causing Home Assistant to get the initial bootup "Unknown" value, but it appears the value publishes exactly as it should if I let it run long enough.
The actual bug experienced appears to be the main loop()
function of the custom component will run and work perfectly, but log messages will not output.
UNLESS... I add a delay to the function, anywhere. A delay (1)
has no effect, and the log messages from the loop function don't print.
However, a delay(30)
causes the log messages to work as expected.
I was able to compile the firmware back-to-back with only that change, flashing back and forth between the 2, and verify the log messages only print with the delay of 30 ms.
Binary difference between working and non-working firmware:
The key value here is at offset 13B98. Per Ghidra, they both disassemble to movi.n
(narrow move immediate) with the operand 0x1 (1 decimal) or 0x1e (30 decimal), indicating the only real change is the function parameter to delay()
, as expected:
I believe the remaining 2 differences are simply checksums (but if anyone knows for sure I would love to learn).
This strongly implies a bug in the logger, network code, or some other part of the ESPHome core. Simply changing the parameter passed to delay()
should have absolutely no effect on if log messages print or not.
I do not know enough about the ESPHome core to debug further than this. This might be something @jesserockz or @bdraco need to look at. I would be happy to provide full source code or whatever I can to help, but I have exhausted my skill/knowledge at this point.
Flashed one of my ESP8266 devices to 2024.6.1 and this issue is not present, at least on the one device. I'll update a few more when I get a chance and see if they are also fixed.
The problem
Logging is not behaving correctly in ESPHome 2024.5.0 or newer (including the latest dev branch). Some debug messages do not print that should print, including when a sensor publishes a value to Home Assistant.
Cleaning build files and recompiling does not have an effect on behavior.
Reverting to ESPHome 2024.4.2 causes the device to work correctly again, with all debug messages printing to the log.
I run a nearly identical piece of hardware with an ESP32 instead of an ESP8266, and the behavior seems limited to the 8266.
Which version of ESPHome has the issue?
2024.5.0
What type of installation are you using?
Home Assistant Add-on
Which version of Home Assistant has the issue?
2024.5.4
What platform are you using?
ESP8266
Board
D1 Mini
Component causing the issue
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
Hardware is a home-made open source air quality sensor (HAKS) using this firmware.