icloud3 icon indicating copy to clipboard operation
icloud3 copied to clipboard

'NoneType' object has no attribute 'loop'

Open SoCuul opened this issue 1 year ago • 2 comments

Hi!

Recently I've noticed the following error being spammed in my logs.

2024-04-05 00:00:04.526 ERROR (SyncWorker_9) [custom_components.icloud3] 'NoneType' object has no attribute 'loop'
Traceback (most recent call last):
  File "/config/custom_components/icloud3/sensor.py", line 1259, in async_update_sensor
    self.schedule_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1213, in schedule_update_ha_state
    self.hass.loop.call_soon_threadsafe(self.async_write_ha_state)
    ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'loop'

SoCuul avatar Apr 06 '24 03:04 SoCuul

Another person noticed that a few days ago. I can not reproduce it but it looks like a sensor was being updated when it didn't exist, when it had not been set up yet or when there was no data to use.

I added some code to see if the sensor had been set up before doing anything and also put another error check in to try to catch it. This was just changed at the request of balloob. See if it helps and let me know if you still see the error msg.

Unzip sensor.zip into the icloud3 directory and restart HA

sensor.zip

gcobb321 avatar Apr 07 '24 17:04 gcobb321

Hey, sorry for the late response!

I just got around to trying it, and it seems to fix the error. Thanks :)

SoCuul avatar Apr 12 '24 05:04 SoCuul