mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Added resolution support to Amcrest cameras (#4860)
* Added resolution support to Amcrest cameras * Ordered alphabetically DEFAULT_ options
This commit is contained in:
parent
4114884cdc
commit
3467020dbf
@ -18,16 +18,26 @@ REQUIREMENTS = ['amcrest==1.0.0']
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_PORT = 80
|
CONF_RESOLUTION = 'resolution'
|
||||||
|
|
||||||
DEFAULT_NAME = 'Amcrest Camera'
|
DEFAULT_NAME = 'Amcrest Camera'
|
||||||
|
DEFAULT_PORT = 80
|
||||||
|
DEFAULT_RESOLUTION = 'high'
|
||||||
|
|
||||||
NOTIFICATION_ID = 'amcrest_notification'
|
NOTIFICATION_ID = 'amcrest_notification'
|
||||||
NOTIFICATION_TITLE = 'Amcrest Camera Setup'
|
NOTIFICATION_TITLE = 'Amcrest Camera Setup'
|
||||||
|
|
||||||
|
RESOLUTION_LIST = {
|
||||||
|
'high': 0,
|
||||||
|
'low': 1,
|
||||||
|
}
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_HOST): cv.string,
|
vol.Required(CONF_HOST): cv.string,
|
||||||
vol.Required(CONF_USERNAME): cv.string,
|
vol.Required(CONF_USERNAME): cv.string,
|
||||||
vol.Required(CONF_PASSWORD): cv.string,
|
vol.Required(CONF_PASSWORD): cv.string,
|
||||||
|
vol.Optional(CONF_RESOLUTION, default=DEFAULT_RESOLUTION):
|
||||||
|
vol.All(vol.In(RESOLUTION_LIST)),
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||||
})
|
})
|
||||||
@ -64,13 +74,14 @@ class AmcrestCam(Camera):
|
|||||||
def __init__(self, device_info, data):
|
def __init__(self, device_info, data):
|
||||||
"""Initialize an Amcrest camera."""
|
"""Initialize an Amcrest camera."""
|
||||||
super(AmcrestCam, self).__init__()
|
super(AmcrestCam, self).__init__()
|
||||||
self._name = device_info.get(CONF_NAME)
|
|
||||||
self._data = data
|
self._data = data
|
||||||
|
self._name = device_info.get(CONF_NAME)
|
||||||
|
self._resolution = RESOLUTION_LIST[device_info.get(CONF_RESOLUTION)]
|
||||||
|
|
||||||
def camera_image(self):
|
def camera_image(self):
|
||||||
"""Return a still image reponse from the camera."""
|
"""Return a still image reponse from the camera."""
|
||||||
# Send the request to snap a picture and return raw jpg data
|
# Send the request to snap a picture and return raw jpg data
|
||||||
response = self._data.camera.snapshot()
|
response = self._data.camera.snapshot(channel=self._resolution)
|
||||||
return response.data
|
return response.data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user