Fix overridden state methods - camera (#60352)

pull/60358/head
Marc Mueller 2021-11-25 18:47:57 +01:00 committed by GitHub
parent f292691b7b
commit b724672dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 21 deletions

View File

@ -18,11 +18,6 @@ class HomeKitCamera(AccessoryEntity, Camera):
"""Define the homekit characteristics the entity is tracking."""
return []
@property
def state(self):
"""Return the current state of the camera."""
return "idle"
async def async_camera_image(
self, width: int | None = None, height: int | None = None
) -> bytes | None:

View File

@ -10,12 +10,7 @@ import aiohttp
import async_timeout
import voluptuous as vol
from homeassistant.components.camera import (
PLATFORM_SCHEMA,
STATE_IDLE,
STATE_RECORDING,
Camera,
)
from homeassistant.components.camera import PLATFORM_SCHEMA, STATE_IDLE, Camera
from homeassistant.components.camera.const import DOMAIN
from homeassistant.const import CONF_NAME, CONF_TIMEOUT, CONF_WEBHOOK_ID
from homeassistant.core import callback
@ -99,7 +94,6 @@ class PushCamera(Camera):
self._last_trip = None
self._filename = None
self._expired_listener = None
self._state = STATE_IDLE
self._timeout = timeout
self.queue = deque([], buffer_size)
self._current_image = None
@ -125,15 +119,10 @@ class PushCamera(Camera):
"""HTTP field containing the image file."""
return self._image_field
@property
def state(self):
"""Return current state of the camera."""
return self._state
async def update_image(self, image, filename):
"""Update the camera image."""
if self._state == STATE_IDLE:
self._state = STATE_RECORDING
if self.state == STATE_IDLE:
self._attr_is_recording = True
self._last_trip = dt_util.utcnow()
self.queue.clear()
@ -143,7 +132,7 @@ class PushCamera(Camera):
@callback
def reset_state(now):
"""Set state to idle after no new images for a period of time."""
self._state = STATE_IDLE
self._attr_is_recording = False
self._expired_listener = None
_LOGGER.debug("Reset state")
self.async_write_ha_state()
@ -162,7 +151,7 @@ class PushCamera(Camera):
) -> bytes | None:
"""Return a still image response."""
if self.queue:
if self._state == STATE_IDLE:
if self.state == STATE_IDLE:
self.queue.rotate(1)
self._current_image = self.queue[0]