pvvx / ZigbeeTLc

Custom firmware for Zigbee 3.0 IoT devices on the TLSR825x chip
Other
365 stars 20 forks source link

LYWSD03MMC Thermometers occassionally re-enable the disabled comfort smiley display (ScheduleProgrammingVisibility) #47

Closed JayFoxRox closed 8 months ago

JayFoxRox commented 8 months ago

I'm on Zigbee2MQTT (1.34.0 commit: aae7312); zStack12 Coordinator revision 20211115.

I have 9 LYWSD03MMC thermometers (called T1 - T9). Each of them is running 3001-0117 (20231215).

Initially I configured them to hide the smiley using https://github.com/pvvx/ZigbeeTLc/issues/28#issuecomment-1896767775 in zigbee2mqtt using the "Dev Console", but it keeps breaking - the smiley keeps coming back randomly (or temporarily?).

They've been running this firmware for about ~7 weeks. Since then, in at least 3 cases, one of those thermometers (a different one each time) suddenly started showing the comfort smiley. First, it happened on 1 thermometer about a week after initial setup of the thermometers. Then it happened 2 more times this week, again, on different thermometers. It's fixable by rewriting 1 to the visibility setting on the affected thermometer.

Each of the affected thermometers report > 70% battery

It's not clear to me if this is a zigbee2mqtt reconfiguration issue or a bug in this firmware or even something like a flash malfunction.

I'd like to provide logs, but my logs are quickly rotating because of issue #46 and I never spotted the moment it changed. I did not try to read back the config attribute on an affected thermometer (I always just rewrote the field to hide the smiley again), but will read it out if it happens again.

JayFoxRox commented 8 months ago

Checked the code, and my theory is that the thermometer doesn't even have the setting saved properly. The code to _save to flash looks "odd" because it uses the same nv_flashReadNew as _restore:

_save: https://github.com/pvvx/ZigbeeTLc/blob/4deaabd695d09ccd1394f0a5d1a568387b4ca2b9/src/sensorEpCfg.c#L388

_restore: https://github.com/pvvx/ZigbeeTLc/blob/4deaabd695d09ccd1394f0a5d1a568387b4ca2b9/src/sensorEpCfg.c#L415

Therefore, I believe the thermometers might have restarted (I didn't try to manually restart them, but would assume they'd show similar behaviour?)

Edit: Checked the telink SDK to see if this was using some weird MMIO or diff-ing approach; but there's indeed a nv_flashWriteNew which should probably have been used instead

pvvx commented 8 months ago

Thanks! The error has been fixed. Ver0.1.1.9.