diff --git a/homeassistant/components/unifiprotect/entity.py b/homeassistant/components/unifiprotect/entity.py index c7ae7344345..12e5ccf9456 100644 --- a/homeassistant/components/unifiprotect/entity.py +++ b/homeassistant/components/unifiprotect/entity.py @@ -1,7 +1,7 @@ """Shared Entity definition for UniFi Protect Integration.""" from __future__ import annotations -from pyunifiprotect.data import ProtectAdoptableDeviceModel +from pyunifiprotect.data import ProtectAdoptableDeviceModel, StateType from homeassistant.core import callback import homeassistant.helpers.device_registry as dr @@ -74,7 +74,7 @@ class ProtectDeviceEntity(Entity): self.device = devices[self.device.id] self._attr_available = ( - self.data.last_update_success and self.device.is_connected + self.data.last_update_success and self.device.state == StateType.CONNECTED ) @callback diff --git a/tests/components/unifiprotect/test_camera.py b/tests/components/unifiprotect/test_camera.py index df1f5aceb95..eb1c640f8a1 100644 --- a/tests/components/unifiprotect/test_camera.py +++ b/tests/components/unifiprotect/test_camera.py @@ -8,6 +8,7 @@ from unittest.mock import AsyncMock, Mock, patch import pytest from pyunifiprotect.data import Camera as ProtectCamera from pyunifiprotect.data.devices import CameraChannel +from pyunifiprotect.data.types import StateType from pyunifiprotect.exceptions import NvrError from homeassistant.components.camera import ( @@ -463,7 +464,7 @@ async def test_camera_ws_update_offline( # camera goes offline new_bootstrap = copy(mock_entry.api.bootstrap) new_camera = camera[0].copy() - new_camera.is_connected = False + new_camera.state = StateType.DISCONNECTED mock_msg = Mock() mock_msg.new_obj = new_camera @@ -477,7 +478,7 @@ async def test_camera_ws_update_offline( assert state and state.state == "unavailable" # camera comes back online - new_camera.is_connected = True + new_camera.state = StateType.CONNECTED mock_msg = Mock() mock_msg.new_obj = new_camera