Logi Circle camera with HASS

Internet Connectivity is fine inbound and outbound to the system. I just restarted again and the cameras came up without error this time.

I’m using Nabu Casa for my redirect URI. Maybe they had a problem? Nothing has been done on my system since I originally posted the error and that was after a number of reboots and restarts with the same error. Thanks.

I’m using Nabu Casa for my redirect URI. Maybe they had a problem?

Nah, the redirect URI is only used when you add the integration for the first time. The trace you provided indicating the error was happening when refreshing your access token with Logi’s API.

Glad to hear the problem resolved itself, hopefully that’s the first and last time that happens.

Well, it ran all night and then this morning it went down again:

2019-06-24 08:13:37 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.pool_recording_mode fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 375, in async_device_update            
    await self.async_update() 
  File "/usr/src/homeassistant/homeassistant/components/logi_circle/sensor.py", line 122, in async_update    
    await self._camera.update()
  File "/usr/local/lib/python3.7/site-packages/logi_circle/camera.py", line 73, in update                    
    camera = await self.logi._fetch(url=url)
  File "/usr/local/lib/python3.7/site-packages/logi_circle/__init__.py", line 205, in _fetch                 
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 935, in raise_for_status      
    assert self.reason  # always not None for started response
AssertionError                
2019-06-24 08:13:37 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.front_door_streaming_mode fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 220, in async_update_ha_state          
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 375, in async_device_update            
    await self.async_update() 
  File "/usr/src/homeassistant/homeassistant/components/logi_circle/sensor.py", line 122, in async_update    
    await self._camera.update()
  File "/usr/local/lib/python3.7/site-packages/logi_circle/camera.py", line 73, in update                    
    camera = await self.logi._fetch(url=url)
  File "/usr/local/lib/python3.7/site-packages/logi_circle/__init__.py", line 205, in _fetch                 
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py"935, in raise_for_status      
    assert self.reason  # always not None for started response
AssertionError                
2019-06-24 08:13:37 ERROR (MainThread) [homeassistant.helpers.entity] Upr sensor.pool_wifi_signal_strength fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 22sync_update_ha_state          
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 37sync_device_update            
    await self.async_update() 
  File "/usr/src/homeassistant/homeassistant/components/logi_circle/sens line 122, in async_update    
    await self._camera.update()
  File "/usr/local/lib/python3.7/site-packages/logi_circle/camera.py", l in update                    
    camera = await self.logi._fetch(url=url)
  File "/usr/local/lib/python3.7/site-packages/logi_circle/__init__.py",05, in _fetch                 
    resp.raise_for_status()   
    assert self.reason  # always not None for started response
AssertionError                
2019-06-24 08:13:37 ERROR (MainThread) [homeassistant.helpers.entity] Upr sensor.pool_wifi_signal_strength fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 22sync_update_ha_state          
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 37sync_device_update            
    await self.async_update() 
  File "/usr/src/homeassistant/homeassistant/components/logi_circle/sens line 122, in async_update    
    await self._camera.update()
  File "/usr/local/lib/python3.7/site-packages/logi_circle/camera.py", l in update                    
    camera = await self.logi._fetch(url=url)
  File "/usr/local/lib/python3.7/site-packages/logi_circle/__init__.py",05, in _fetch                 
    resp.raise_for_status()   
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 935,
 in raise_for_status          
    assert self.reason  # always not None for started response
AssertionError                
2019-06-24 08:13:37 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.front_door_wifi_signal_strength fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 220, in async_update_ha_state              
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 375, in async_device_update                
    await self.async_update() 
  File "/usr/src/homeassistant/homeassistant/components/logi_circle/sensor.py", line 122, in async_update        
    await self._camera.update()
  File "/usr/local/lib/python3.7/site-packages/logi_circle/camera.py", line 73, in update                        
    camera = await self.logi._fetch(url=url)
  File "/usr/local/lib/python3.7/site-packages/logi_circle/__init__.py", line 205, in _fetch                     
    resp.raise_for_status()   
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 935,
 in raise_for_status          
    assert self.reason  # always not None for started response
AssertionError
2019-06-24 08:13:44 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 33, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 216, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 115, in handle
    result = await result     
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py",e 478, in get                 
    return await self.handle(request, camera)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py",e 495, in handle              
    image = await camera.async_camera_image()
  File "/usr/src/homeassistant/homeassistant/components/logi_circle/camera.pline 133, in async_camera_image
    return await self._camera.live_stream.download_jpeg()
  File "/usr/local/lib/python3.7/site-packages/logi_circle/live_stream.py",  39, in download_jpeg         
    image = await self.logi._fetch(url=url, raw=True, headers=ACCEPT_IMAGE_HR, params=params)             
  File "/usr/local/lib/python3.7/site-packages/logi_circle/__init__.py", lin5, in _fetch                  
    resp.raise_for_status()   
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", li35, in raise_for_status       
    assert self.reason  # always not None for started response
AssertionError  

It kept looping the last error until I finally restarted Home Assistant. Now the cameras won’t come up with the same error as before:

2019-06-24 15:35:06 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Logi Circle (eba75f46-b568-43ac-b51b-438d967ec1ae) for logi_circle
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 273, in async_setup
    hass, self)
  File "/usr/src/homeassistant/homeassistant/components/logi_circle/__init__.py", line 124, in async_setup_entry
    await logi_circle.synchronize_cameras()
  File "/usr/local/lib/python3.7/site-packages/logi_circle/__init__.py", line 74, in synchronize_cameras
    await self.cameras
  File "/usr/local/lib/python3.7/site-packages/logi_circle/__init__.py", line 85, in cameras
    raw_cameras = await self._fetch(ACCESSORIES_ENDPOINT)
  File "/usr/local/lib/python3.7/site-packages/logi_circle/__init__.py", line 205, in _fetch
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 93
5, in raise_for_status      
    assert self.reason  # always not None for started response
AssertionError
2019-06-24 15:35:07 ERROR (SyncWorker_13) [homeassistant.core] Error doing job: Unclosed client session
2019-06-24 15:35:10 ERROR (SyncWorker_13) [homeassistant.core] Error doing job: Unclosed connector

I’ve rebooted and restarted several times. Thought maybe it was a provider problem, but I don’t see any outages reported on their network interconnects.

Back to working again this morning. No changes, just a restart of Home Assistant.

Back to getting errors in the log again. Ran fine all day and then this. Cameras are still working with HA though this time:

I’m not sure what I can do to help. I’ve had zero errors in my HA instance, and I have automations that regularly ping the API.

This really sounds like a networking issue. Here’s the line it’s falling over at aiohttp: https://github.com/aio-libs/aiohttp/blob/eb9aa227e40b2f9a375686b0f7e22891bbeadf28/aiohttp/client_reqrep.py#L894

Whatever networking issue you’re experiencing, it’s unusual, since it has no corresponding message (eg. OK for 200, Not Found for 404, etc). I have no idea what would cause this.

I missed the log you attached. This error is more meaningful:

aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.circle.logi.com:443 ssl:None [Try again]

From my rough understanding of aiohttp error classes, this suggests that the connection could not be created. As in, a network request was never even made. A quick googling of that “Try again” message suggests it might be DNS?

Quick heads up on a small breaking change in HA 0.95 - the cached tokens are now saved in the config folder explicitly, rather than the working directory.

If your working directory is anything other than the config folder, you will we need to re-add the integration to recreate the token. This resolves an issue on docker or hassio where tokens would be blown away whenever you upgraded. For anyone who’s had to manually set the working directory in their startup scripts to workaround this, you can safely remove it once you’ve upgraded to 0.95. Sorry for the trouble.

Any chance it’s related to this issue? Looks like making changes to resolv.conf would possibly speed up the lookups.

https://github.com/home-assistant/home-assistant/issues/12607

Hi. I am trying to make a button to toggle the camera on and off but I get the following error “Failed to call service camera/turn_on. ‘Camera’ object has no attribute ‘set_streaming_mode’”. I am quite new to this so any help would be appreciated. Thanks

The Logi Circle doesn’t currently work with the camera turn on/off service. Evan is submitting a PR to get it fixed. You can create a switch and turn off recording mode which works fine for now:

switch:
  - platform: template
    switches:
      logi_circle_recording_mode_front_door:
        friendly_name: Front Camera Record
        value_template: "{{ states('sensor.front_door_recording_mode') }}"
        turn_on:
          service: logi_circle.set_config
          data:
            entity_id: camera.front_door 
            mode: RECORDING_MODE
            value: true
        turn_off:
          service: logi_circle.set_config
          data:
            entity_id: camera.front_door
            mode: RECORDING_MODE
            value: false
1 Like

My instincts would be to run HA outside of docker first (eg. a python venv) to verify that resolves the issue before experimenting with docker DNS’s config.

Evan,
I’m still having intermittent problems with the Logi Circle cameras hanging up with the same errors as before. They will sometimes run fine for days without error, but sometimes they will be unavailable for a day or more before a Hassio restart gets them to connect again. This weekend they’ve shown up in Hassio as unavailable more than available starting Friday morning. Yesterday they couldn’t connect most of the day, finally connected late afternoon, and then dropped out again early this morning. Numerous restarts and reboots this morning and no connection. I turned on debug, rebooted and get this in the log:

2019-07-14 09:56:57 DEBUG (MainThread) [logi_circle] Request https://api.circle.logi.com/api/accessories (GET) returned 429 with content type application/json                
2019-07-14 09:56:57 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Logi Circle (eba75f46-b568-43ac-b51b-438d967ec1ae) for logi_circle               
Traceback (most recent call last):                                                                                                                                            
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 153, in async_setup                                                                                     
    hass, self)                                                                                                                                                               
  File "/usr/src/homeassistant/homeassistant/components/logi_circle/__init__.py", line 124, in async_setup_entry                                                              
    await logi_circle.synchronize_cameras()                                                                                                                                   
  File "/usr/local/lib/python3.7/site-packages/logi_circle/__init__.py", line 74, in synchronize_cameras                                                                      
    await self.cameras                                                                                                                                                        
  File "/usr/local/lib/python3.7/site-packages/logi_circle/__init__.py", line 85, in cameras                                                                                  
    raw_cameras = await self._fetch(ACCESSORIES_ENDPOINT)                                                                                                                     
  File "/usr/local/lib/python3.7/site-packages/logi_circle/__init__.py", line 205, in _fetch                                                                                  
    resp.raise_for_status()                                                                                                                                                   
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 935, in raise_for_status                                                                       
    assert self.reason  # always not None for started response                                                                                                                
AssertionError                                                                                                                                                                
2019-07-14 09:56:57 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=logi_circle>  

The “429” response to HTTPS GET doesn’t look right does it? There’s a full debug log here if it helps:

https://www.dropbox.com/s/630aallozancas9/home-assistant%20-%20copy.log?dl=0

Thanks,
Greg

So after thinking about this for a few minutes, maybe the 429 rate limit response explains what I’m seeing? I tend to have a window up tail’ng the home_assistant.log and this morning the log was streaming connection attempts every second or so until I restarted Hassio. (sorry, didn’t think to copy off the log before reboot) After some period of time I’m assuming my rate limit time expires and a Hassio restart allows the cameras to connect again? Then I’m back running again until the next network (or whatever) issue causes the connection to start retrying again every couple seconds. Sometimes I’ll only see the error once or twice in the log and the cameras are still available in Hassio. So is the rate limit coming from Logitech or NabuCasa?

Logitech. How many Logi Circle devices do you have?

Two cameras.

Hm, OK. I thought maybe if you had a ton of devices, the API wrapper might be creating too many requests - but 2 is fine (I have 4).

I tried to reproduce this but couldn’t. I briefly creating a static route so that the logi API host nowhere, but after the connection attempt failed, it waited until the next refresh interval to retry (as it should).

Did you try running HA outside of docker (eg. in a venv) like I previously suggested? Might be useful to determine whether the underlying network issue is docker-specific or somewhere else.

I’ll get a single connection error once in a while and as you experienced it recovers fine. For some reason, every so often it goes into a loop trying to reconnect and then I get rate limited. The cameras have been running fine all day today after I restarted Hassio this morning. I just got a RPI 4 and I’ve been letting “burn in” with Hassbian for the last couple days. Plan is to switch over some time this week, so we’ll see if that makes any difference.

Spoke to soon…Just noticed my home_assistant.log streaming errors and now I’m rate limited again. Here’s the log:

Would it help if I ran logger in debug and if so what components should I specify?

Can I suggest we take this conversation over to a github issue to avoid cluttering this thread? Feel free to raise something at https://github.com/evanjd/python-logi-circle.

As for your log, the only thing meaningful I can tell from it is that the repeated connection attempts originate from a browser. This could mean:

  • There’s an issue on the front-end that’s causing it to retry in rapid succession (likely unrelated to the logi circle integration - I have no code that touches the UI, camera images flow through generic interfaces exposed by the camera platform)
  • You have multiple instances of the HA Web UI open, and they’re all spamming the camera for an image at the same time when HA’s backend is restarted.

There’s no retry logic built into the Logi Circle integration or the API wrapper. If a request fails, it just returns the error back to its calling function. So this loop you’re seeing is coming from something else.