sopelj / hass-ember-mug-component

Ember Mug Integration for Home Assistant
MIT License
116 stars 4 forks source link

Handle offline mugs more gracefully #36

Closed iridris closed 1 year ago

iridris commented 1 year ago

Description

I have 2 mugs - when they are both charged, they work perfectly. But after the battery dies and the mug is no longer accessible, there are lots of log messages that fill up my home-assistant.log. The same two logs repeat approximately every 2-3 minutes. Since these are bluetooth battery powered devices, it should be expected that they occasionally go offline and the situation should not cause a flood of log messages.

In addition to the log messages, the HA Devices page will list the integration as having failed to set up. After charging the mug and reloading the integration, that message goes away.

What I Did

Allow the mug to deplete the battery. Observe log messages filling up log file.

Logs / Errors

2023-10-21 04:03:45.497 ERROR (MainThread) [ember_mug.mug] F4:71:0A:A1:6B:42: Ember Ceramic Mug: Failed to connect to the mug:  (F4:71:0A:A1:6B:42) - F4:71:0A:A1:6B:42: Failed to connect after 4 attempt(s): TimeoutError
2023-10-21 04:03:45.497 ERROR (MainThread) [custom_components.ember_mug.coordinator] An error occurred whilst updating the Ember Ceramic Mug:  (F4:71:0A:A1:6B:42) - F4:71:0A:A1:6B:42: Failed to connect after 4 attempt(s): TimeoutError
iridris commented 1 year ago

After installing 8.0.0beta3, one of the two errors I was getting has been eliminated. I'm still getting the other one, it looks like about ~5 minutes.

2023-10-30 19:03:44.505 ERROR (MainThread) [ember_mug.mug] F4:71:0A:A1:6B:42: Ember Ceramic Mug: Failed to connect to the mug:  (F4:71:0A:A1:6B:42) - F4:71:0A:A1:6B:42: Failed to connect after 4 attempt(s): TimeoutError
2023-10-30 19:06:25.620 ERROR (MainThread) [ember_mug.mug] F4:71:0A:A1:6B:42: Ember Ceramic Mug: Failed to connect to the mug:  (F4:71:0A:A1:6B:42) - F4:71:0A:A1:6B:42: Failed to connect after 4 attempt(s): TimeoutError
2023-10-30 19:09:07.087 ERROR (MainThread) [ember_mug.mug] F4:71:0A:A1:6B:42: Ember Ceramic Mug: Failed to connect to the mug:  (F4:71:0A:A1:6B:42) - F4:71:0A:A1:6B:42: Failed to connect after 4 attempt(s): TimeoutError
2023-10-30 19:11:48.277 ERROR (MainThread) [ember_mug.mug] F4:71:0A:A1:6B:42: Ember Ceramic Mug: Failed to connect to the mug:  (F4:71:0A:A1:6B:42) - F4:71:0A:A1:6B:42: Failed to connect after 4 attempt(s): TimeoutError
2023-10-30 19:14:29.684 ERROR (MainThread) [ember_mug.mug] F4:71:0A:A1:6B:42: Ember Ceramic Mug: Failed to connect to the mug:  (F4:71:0A:A1:6B:42) - F4:71:0A:A1:6B:42: Failed to connect after 4 attempt(s): TimeoutError
sopelj commented 1 year ago

Hi! I see what you mean. I charge my mug as soon as I'm done with it so I never noticed this, but I suppose you are correct and it is a battery operated device and should try not to raise too many errors.

I moved the two errors you mentioned to debug level, so you shouldn't see them unless you enable it. The other "warning" and "errors" should only appear if there is something genuinely out of the ordinary happening. I also prevented it from raising an error if it cannot connect to the mug, it simply becomes "unavailable". The error should now only be raiHi! I see what you mean. I charge my mug as soon as I'm done with it so I never noticed this, but I suppose you are correct and it is a battery operated device and should try not to raise too many errors.

I moved the two errors you mentioned to debug level, so you shouldn't see them unless you enable it. The other "warning" and "errors" should only appear if there is something genuinely out of the ordinary happening. I also prevented it from raising an error if it cannot connect to the mug, it simply becomes "unavailable". The error should now only be raise on initial setup.

This does mean when the battery is low it starts to cut out a bit so I'm still trying to test it a bit. I released a beta 3 though if you want to try it out in the meantime.se on initial setup.

This does mean when the battery is low it starts to cut out a bit so I'm still trying to test it a bit. I released a beta 3 though if you want to try it out in the meantime.

sopelj commented 1 year ago

After installing 8.0.0beta3, one of the two errors I was getting has been eliminated. I'm still getting the other one, it looks like about ~5 minutes.

2023-10-30 19:03:44.505 ERROR (MainThread) [ember_mug.mug] F4:71:0A:A1:6B:42: Ember Ceramic Mug: Failed to connect to the mug:  (F4:71:0A:A1:6B:42) - F4:71:0A:A1:6B:42: Failed to connect after 4 attempt(s): TimeoutError
2023-10-30 19:06:25.620 ERROR (MainThread) [ember_mug.mug] F4:71:0A:A1:6B:42: Ember Ceramic Mug: Failed to connect to the mug:  (F4:71:0A:A1:6B:42) - F4:71:0A:A1:6B:42: Failed to connect after 4 attempt(s): TimeoutError
2023-10-30 19:09:07.087 ERROR (MainThread) [ember_mug.mug] F4:71:0A:A1:6B:42: Ember Ceramic Mug: Failed to connect to the mug:  (F4:71:0A:A1:6B:42) - F4:71:0A:A1:6B:42: Failed to connect after 4 attempt(s): TimeoutError
2023-10-30 19:11:48.277 ERROR (MainThread) [ember_mug.mug] F4:71:0A:A1:6B:42: Ember Ceramic Mug: Failed to connect to the mug:  (F4:71:0A:A1:6B:42) - F4:71:0A:A1:6B:42: Failed to connect after 4 attempt(s): TimeoutError
2023-10-30 19:14:29.684 ERROR (MainThread) [ember_mug.mug] F4:71:0A:A1:6B:42: Ember Ceramic Mug: Failed to connect to the mug:  (F4:71:0A:A1:6B:42) - F4:71:0A:A1:6B:42: Failed to connect after 4 attempt(s): TimeoutError

Oh thanks! Sorry. I'll have a look at that one tomorrow.

sopelj commented 1 year ago

I removed that event as well in Beta 4

sopelj commented 1 year ago

Hey @iridris, this was added release v0.8.0 last month. It should cover all the points you mentioned, but feel free to open a new issue if there is something else. Thanks!