1
mirror of https://github.com/home-assistant/core synced 2024-07-27 18:58:57 +02:00

Always use datetime and timedelta in camera.proxy instead of int/float (#19571)

This commit is contained in:
Mike Miller 2019-01-11 22:58:14 +02:00 committed by Paulus Schoutsen
parent 14dd8791ec
commit a65d14c0cd

View File

@ -7,6 +7,7 @@ https://www.home-assistant.io/components/camera.proxy/
import asyncio
import logging
from datetime import timedelta
import voluptuous as vol
from homeassistant.components.camera import PLATFORM_SCHEMA, Camera
@ -206,7 +207,7 @@ class ProxyCamera(Camera):
self._cache_images = bool(
config.get(CONF_IMAGE_REFRESH_RATE)
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._headers = (
{HTTP_HEADER_HA_AUTH: self.hass.config.api.api_password}
@ -223,7 +224,8 @@ class ProxyCamera(Camera):
now = dt_util.utcnow()
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
self._last_image_time = now