mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 02:37:08 +00:00
Always use datetime and timedelta in camera.proxy instead of int/float (#19571)
This commit is contained in:
parent
14dd8791ec
commit
a65d14c0cd
@ -7,6 +7,7 @@ https://www.home-assistant.io/components/camera.proxy/
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from datetime import timedelta
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.camera import PLATFORM_SCHEMA, Camera
|
from homeassistant.components.camera import PLATFORM_SCHEMA, Camera
|
||||||
@ -206,7 +207,7 @@ class ProxyCamera(Camera):
|
|||||||
self._cache_images = bool(
|
self._cache_images = bool(
|
||||||
config.get(CONF_IMAGE_REFRESH_RATE)
|
config.get(CONF_IMAGE_REFRESH_RATE)
|
||||||
or config.get(CONF_CACHE_IMAGES))
|
or config.get(CONF_CACHE_IMAGES))
|
||||||
self._last_image_time = 0
|
self._last_image_time = dt_util.utc_from_timestamp(0)
|
||||||
self._last_image = None
|
self._last_image = None
|
||||||
self._headers = (
|
self._headers = (
|
||||||
{HTTP_HEADER_HA_AUTH: self.hass.config.api.api_password}
|
{HTTP_HEADER_HA_AUTH: self.hass.config.api.api_password}
|
||||||
@ -223,7 +224,8 @@ class ProxyCamera(Camera):
|
|||||||
now = dt_util.utcnow()
|
now = dt_util.utcnow()
|
||||||
|
|
||||||
if (self._image_refresh_rate and
|
if (self._image_refresh_rate and
|
||||||
now < self._last_image_time + self._image_refresh_rate):
|
now < self._last_image_time +
|
||||||
|
timedelta(seconds=self._image_refresh_rate)):
|
||||||
return self._last_image
|
return self._last_image
|
||||||
|
|
||||||
self._last_image_time = now
|
self._last_image_time = now
|
||||||
|
Loading…
x
Reference in New Issue
Block a user