Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix media browser errors when used with Frigate 0.12 #618

Merged
merged 1 commit into from
Feb 3, 2024

Conversation

NickM-27
Copy link
Collaborator

@NickM-27 NickM-27 commented Feb 2, 2024

fixes #600

Copy link

codecov bot commented Feb 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (02ab137) 100.00% compared to head (0fe132f) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #618   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines         2017      2017           
=========================================
  Hits          2017      2017           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dermotduffy dermotduffy added the bug Something isn't working label Feb 3, 2024
@dermotduffy
Copy link
Collaborator

Planning a new build from master, or should we put this in the dev branch?

@NickM-27
Copy link
Collaborator Author

NickM-27 commented Feb 3, 2024

I figured it would be good to get it out soon, so master made sense

@dermotduffy dermotduffy merged commit e094e9e into master Feb 3, 2024
6 checks passed
@dermotduffy dermotduffy changed the title Fix 0.12 events media browser failure Fix media browser errors when used with Frigate 0.12 Feb 3, 2024
@dermotduffy dermotduffy deleted the fix-media branch February 3, 2024 04:02
@mcauwelier
Copy link

I'm currently on frigate 0.13.2 and frigate-hass-integration 5.0.1 and I still have these media browser errors for clips and snapshots. By downgrading the frigate-hass-integration to 5.0.0 this is resolved.

@NickM-27
Copy link
Collaborator Author

the error definitely won't be the same given the way that the code changed. It is all using safe access

@mcauwelier
Copy link

Below you can find the error for frigate 0.13.2 in combination with frigate-hass-integration 5.0.1:

`Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/frigate/media_source.py:860
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 21:05:14 (1 occurrences)
Last logged: 21:05:14

[547275896384] Error handling message: Unknown error (unknown_error) Matthias Cauwelier from 157.97.122.59 (Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/media_source/init.py", line 177, in websocket_browse_media
media = await async_browse_media(hass, msg.get("media_content_id", ""))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/media_source/init.py", line 125, in async_browse_media
item = await _get_media_item(hass, media_content_id, None).async_browse()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/media_source/models.py", line 79, in async_browse
return await self.async_media_source().async_browse_media(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/frigate/media_source.py", line 692, in async_browse_media
return self._browse_events(
^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/frigate/media_source.py", line 774, in _browse_events
event_items = self._build_event_response(identifier, events)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/frigate/media_source.py", line 860, in _build_event_response
title=f"{dt.datetime.fromtimestamp(event['start_time'], DEFAULT_TIME_ZONE).strftime(DATE_STR_FORMAT)} [{duration}s, {event['label'].capitalize()} {int((event['data'].get('top_score') or event['top_score'])*100)}%]",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^~~
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
`
This seems to be the same as in #600

@NickM-27
Copy link
Collaborator Author

It's not the same exactly, we can see here that the new code is having this issue because somehow top score doesn't exist in either place which is a separate issue and potentially a backend issue. It would be good to know what the metadata is for this event that is causing the error.

@mcauwelier
Copy link

I'm using 'manually' triggered event (https://docs.frigate.video/integrations/api/#post-apieventscamera_namelabelcreate) instead of an event triggered by a motion or an object detection.

perhaps this is the reason why there is no top_score. If you need more info or metadata, could you explain what exactly and where to extract it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants