Skip to content

Commit

Permalink
Merge updates for latest HomeAssistant (#427)
Browse files Browse the repository at this point in the history
* Bump actions/setup-python from 4.2.0 to 4.3.0 (#357)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.2.0 to 4.3.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.2.0...v4.3.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump crazy-max/ghaction-github-labeler from 4.0.0 to 4.1.0 (#359)

Bumps [crazy-max/ghaction-github-labeler](https://github.com/crazy-max/ghaction-github-labeler) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/crazy-max/ghaction-github-labeler/releases)
- [Changelog](https://github.com/crazy-max/ghaction-github-labeler/blob/v4.1.0/CHANGELOG.md)
- [Commits](crazy-max/ghaction-github-labeler@v4.0.0...v4.1.0)

---
updated-dependencies:
- dependency-name: crazy-max/ghaction-github-labeler
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump release-drafter/release-drafter from 5.20.1 to 5.21.1 (#358)

Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 5.20.1 to 5.21.1.
- [Release notes](https://github.com/release-drafter/release-drafter/releases)
- [Commits](release-drafter/release-drafter@v5.20.1...v5.21.1)

---
updated-dependencies:
- dependency-name: release-drafter/release-drafter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix HACS add repository badge (#367)

* Fix flake8 in the build. (#380)

* Fix build badge. (#385)

* Bump actions/checkout from 3.1.0 to 3.2.0 (#383)

Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3.1.0...v3.2.0)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.3.0 to 4.3.1 (#378)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.3.0 to 4.3.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.3.0...v4.3.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.3.1 to 4.4.0 (#387)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.3.1 to 4.4.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.3.1...v4.4.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump release-drafter/release-drafter from 5.21.1 to 5.22.0 (#394)

Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 5.21.1 to 5.22.0.
- [Release notes](https://github.com/release-drafter/release-drafter/releases)
- [Commits](release-drafter/release-drafter@v5.21.1...v5.22.0)

---
updated-dependencies:
- dependency-name: release-drafter/release-drafter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/checkout from 3.2.0 to 3.3.0 (#400)

Bumps [actions/checkout](https://github.com/actions/checkout) from 3.2.0 to 3.3.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3.2.0...v3.3.0)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/setup-python from 4.4.0 to 4.5.0 (#407)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.4.0 to 4.5.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4.4.0...v4.5.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Latest version check: add handling for "disabled" (#417)

This goes alongside blakeblackshear/frigate#5208 to ensure that the HASS integration correctly handles the new "disabled" API response that occurs if the Frigate version update check is disabled.

* Update isort. (#425)

* Fixes for Home Assistant 2023.1.7+, Python 3.9, Python 3.10 (#426)

* Updates for Home Assistant 2023.1.7 and Python 3.9 .

* Fix for Python 3.10.

* Minor type fixes.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Felipe Santos <felipecassiors@gmail.com>
Co-authored-by: James L <24962424+leccelecce@users.noreply.github.com>
  • Loading branch information
4 people committed Jan 28, 2023
1 parent 1a23e3b commit 8b80b6b
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 38 deletions.
2 changes: 1 addition & 1 deletion custom_components/frigate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
name=new_name,
)

hass.config_entries.async_setup_platforms(entry, PLATFORMS)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
entry.async_on_unload(entry.add_update_listener(_async_entry_updated))

return True
Expand Down
4 changes: 2 additions & 2 deletions custom_components/frigate/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ async def async_camera_image(
% ({"h": height} if height is not None and height > 0 else {})
)

with async_timeout.timeout(10):
async with async_timeout.timeout(10):
response = await websession.get(image_url)
return await response.read()

Expand Down Expand Up @@ -366,7 +366,7 @@ async def async_camera_image(
% ({"h": height} if height is not None and height > 0 else {})
)

with async_timeout.timeout(10):
async with async_timeout.timeout(10):
response = await websession.get(image_url)
return await response.read()

Expand Down
4 changes: 2 additions & 2 deletions custom_components/frigate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ async def _handle_request(
) as ws_to_frigate:
await asyncio.wait(
[
self._proxy_msgs(ws_to_frigate, ws_to_user),
self._proxy_msgs(ws_to_user, ws_to_frigate),
asyncio.create_task(self._proxy_msgs(ws_to_frigate, ws_to_user)),
asyncio.create_task(self._proxy_msgs(ws_to_user, ws_to_frigate)),
],
return_when=asyncio.tasks.FIRST_COMPLETED,
)
Expand Down
13 changes: 12 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,24 @@ py-version = "3.8"
runtime-typing = false

[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = [
"tests",
]
norecursedirs = [
".git",
"testing_config",
]
filterwarnings = [
# Can be removed after there is a new pytest-cov release with
# https://github.com/pytest-dev/pytest-cov/issues/561 .
"ignore:.*hookimpl CovPlugin.*old-style configuration options.*:pytest.PytestDeprecationWarning",

# Can be removed once we can update to pytest-asyncio==0.20.3 (which in
# turn requires a release of pytest-homeassistant-custom-component >
# 0.12.49)
"ignore:.*There is no current event loop.*:DeprecationWarning"
]
addopts = "--timeout=10 --cov-report=xml:coverage.xml --cov-report=term-missing --cov=custom_components.frigate --cov-fail-under=100"

[tool.mypy]
Expand All @@ -146,4 +157,4 @@ warn_return_any = true
warn_unreachable = true

# Custom Frigate configuration.
show_error_codes = true
show_error_codes = true
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
aiohttp
aiohttp_cors==0.7.0
aiohttp_cors
attr
homeassistant~=2022.7.0
paho-mqtt==1.6.1
janus
homeassistant==2023.1.7
paho-mqtt
python-dateutil
yarl
pytz==2022.7
9 changes: 5 additions & 4 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
-r requirements.txt
black
flake8
mypy==0.910
mypy
pre-commit
pytest
pytest-homeassistant-custom-component~=0.10.2
pytest-homeassistant-custom-component==0.12.49
pylint-pytest
pylint==2.8.3
pytest-aiohttp==0.3.0
pylint
pytest-aiohttp
pytest-asyncio
types-python-dateutil
types-pytz
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ async def setup_mock_frigate_config_entry(
return config_entry


async def test_entities_are_setup_correctly_in_registry(
async def verify_entities_are_setup_correctly_in_registry(
hass: HomeAssistant,
entities_enabled: set[str] | None = None,
entities_disabled: set[str] | None = None,
Expand Down
24 changes: 12 additions & 12 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections.abc import AsyncGenerator
import logging
from typing import Any
from unittest.mock import Mock, patch
from unittest.mock import AsyncMock, patch

import aiohttp
from aiohttp import web
Expand Down Expand Up @@ -44,7 +44,7 @@ async def test_async_get_stats(
) -> None:
"""Test async_get_config."""
stats_in = {"detection_fps": 8.1}
stats_handler = Mock(return_value=web.json_response(stats_in))
stats_handler = AsyncMock(return_value=web.json_response(stats_in))

server = await start_frigate_server(
aiohttp_server, [web.get("/api/stats", stats_handler)]
Expand Down Expand Up @@ -148,7 +148,7 @@ async def test_async_get_config(
) -> None:
"""Test async_get_event_summary."""
config_in = {"cameras": {"front_door": {"camera_config": "goes here"}}}
config_handler = Mock(return_value=web.json_response(config_in))
config_handler = AsyncMock(return_value=web.json_response(config_in))

server = await start_frigate_server(
aiohttp_server, [web.get("/api/config", config_handler)]
Expand All @@ -170,7 +170,7 @@ async def test_async_get_path(
}
]

recordings_handler = Mock(return_value=web.json_response(recordings_in))
recordings_handler = AsyncMock(return_value=web.json_response(recordings_in))

server = await start_frigate_server(
aiohttp_server, [web.get("/recordings/moo/", recordings_handler)]
Expand All @@ -185,10 +185,10 @@ async def test_api_wrapper_methods(
) -> None:
"""Test the general api_wrapper."""

get_handler = Mock(return_value=web.json_response({"method": "GET"}))
put_handler = Mock(return_value=web.json_response({"method": "PUT"}))
patch_handler = Mock(return_value=web.json_response({"method": "PATCH"}))
post_handler = Mock(return_value=web.json_response({"method": "POST"}))
get_handler = AsyncMock(return_value=web.json_response({"method": "GET"}))
put_handler = AsyncMock(return_value=web.json_response({"method": "PUT"}))
patch_handler = AsyncMock(return_value=web.json_response({"method": "PATCH"}))
post_handler = AsyncMock(return_value=web.json_response({"method": "POST"}))

server = await start_frigate_server(
aiohttp_server,
Expand Down Expand Up @@ -225,7 +225,7 @@ async def test_api_wrapper_exceptions(
server = await start_frigate_server(
aiohttp_server,
[
web.get("/get", Mock(return_value=web.json_response({}))),
web.get("/get", AsyncMock(return_value=web.json_response({}))),
],
)
frigate_client = FrigateApiClient(str(server.make_url("/")), aiohttp_session)
Expand Down Expand Up @@ -272,10 +272,10 @@ async def test_async_retain(
"""Test async_retain."""

post_success = {"success": True, "message": "Post success"}
post_handler = Mock(return_value=web.json_response(post_success))
post_handler = AsyncMock(return_value=web.json_response(post_success))

delete_success = {"success": True, "message": "Delete success"}
delete_handler = Mock(return_value=web.json_response(delete_success))
delete_handler = AsyncMock(return_value=web.json_response(delete_success))

event_id = "1656282822.206673-bovnfg"
server = await start_frigate_server(
Expand All @@ -301,7 +301,7 @@ async def test_async_get_recordings_summary(
"""Test async_recordings_summary."""

summary_success = [{"summary": "goes_here"}]
summary_handler = Mock(return_value=web.json_response(summary_success))
summary_handler = AsyncMock(return_value=web.json_response(summary_success))
camera = "front_door"

server = await start_frigate_server(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
TEST_SERVER_VERSION,
create_mock_frigate_client,
setup_mock_frigate_config_entry,
test_entities_are_setup_correctly_in_registry,
verify_entities_are_setup_correctly_in_registry,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -170,7 +170,7 @@ async def test_binary_sensors_setup_correctly_in_registry(

await setup_mock_frigate_config_entry(hass)

await test_entities_are_setup_correctly_in_registry(
await verify_entities_are_setup_correctly_in_registry(
hass,
entities_enabled={
TEST_BINARY_SENSOR_FRONT_DOOR_MOTION_ENTITY_ID,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
create_mock_frigate_client,
create_mock_frigate_config_entry,
setup_mock_frigate_config_entry,
test_entities_are_setup_correctly_in_registry,
verify_entities_are_setup_correctly_in_registry,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -433,7 +433,7 @@ async def test_cameras_setup_correctly_in_registry(
"""Verify entities are enabled/visible as appropriate."""

await setup_mock_frigate_config_entry(hass)
await test_entities_are_setup_correctly_in_registry(
await verify_entities_are_setup_correctly_in_registry(
hass,
entities_enabled={
TEST_CAMERA_FRONT_DOOR_ENTITY_ID,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
create_mock_frigate_client,
enable_and_load_entity,
setup_mock_frigate_config_entry,
test_entities_are_setup_correctly_in_registry,
verify_entities_are_setup_correctly_in_registry,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -171,7 +171,7 @@ async def test_numbers_setup_correctly_in_registry(

await setup_mock_frigate_config_entry(hass)

await test_entities_are_setup_correctly_in_registry(
await verify_entities_are_setup_correctly_in_registry(
hass,
entities_disabled=DISABLED_NUMBER_ENTITY_IDS,
)
4 changes: 2 additions & 2 deletions tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
create_mock_frigate_client,
enable_and_load_entity,
setup_mock_frigate_config_entry,
test_entities_are_setup_correctly_in_registry,
verify_entities_are_setup_correctly_in_registry,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -535,7 +535,7 @@ async def test_sensors_setup_correctly_in_registry(
"""Verify entities are enabled/visible as appropriate."""

await setup_mock_frigate_config_entry(hass)
await test_entities_are_setup_correctly_in_registry(
await verify_entities_are_setup_correctly_in_registry(
hass,
entities_enabled={
TEST_SENSOR_STEPS_ALL_ENTITY_ID,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
create_mock_frigate_client,
enable_and_load_entity,
setup_mock_frigate_config_entry,
test_entities_are_setup_correctly_in_registry,
verify_entities_are_setup_correctly_in_registry,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -193,7 +193,7 @@ async def test_switches_setup_correctly_in_registry(

await setup_mock_frigate_config_entry(hass)

await test_entities_are_setup_correctly_in_registry(
await verify_entities_are_setup_correctly_in_registry(
hass,
entities_enabled=ENABLED_SWITCH_ENTITY_IDS,
entities_disabled=DISABLED_SWITCH_ENTITY_IDS,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
TEST_UPDATE_FRIGATE_CONTAINER_ENTITY_ID,
create_mock_frigate_client,
setup_mock_frigate_config_entry,
test_entities_are_setup_correctly_in_registry,
verify_entities_are_setup_correctly_in_registry,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -116,7 +116,7 @@ async def test_update_sensor_setup_correctly_in_registry(

await setup_mock_frigate_config_entry(hass)

await test_entities_are_setup_correctly_in_registry(
await verify_entities_are_setup_correctly_in_registry(
hass,
entities_enabled={TEST_UPDATE_FRIGATE_CONTAINER_ENTITY_ID},
entities_visible={TEST_UPDATE_FRIGATE_CONTAINER_ENTITY_ID},
Expand Down

0 comments on commit 8b80b6b

Please sign in to comment.