Add ONVIF PTZ Stop support (#39734)

This commit is contained in:
Ville Skyttä 2020-11-20 23:59:11 +02:00 committed by GitHub
parent b4381c5005
commit cab186d28f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 2 deletions

View file

@ -35,6 +35,7 @@ from .const import (
LOGGER, LOGGER,
RELATIVE_MOVE, RELATIVE_MOVE,
SERVICE_PTZ, SERVICE_PTZ,
STOP_MOVE,
ZOOM_IN, ZOOM_IN,
ZOOM_OUT, ZOOM_OUT,
) )
@ -54,7 +55,13 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
vol.Optional(ATTR_DISTANCE, default=0.1): cv.small_float, vol.Optional(ATTR_DISTANCE, default=0.1): cv.small_float,
vol.Optional(ATTR_SPEED, default=0.5): cv.small_float, vol.Optional(ATTR_SPEED, default=0.5): cv.small_float,
vol.Optional(ATTR_MOVE_MODE, default=RELATIVE_MOVE): vol.In( vol.Optional(ATTR_MOVE_MODE, default=RELATIVE_MOVE): vol.In(
[CONTINUOUS_MOVE, RELATIVE_MOVE, ABSOLUTE_MOVE, GOTOPRESET_MOVE] [
CONTINUOUS_MOVE,
RELATIVE_MOVE,
ABSOLUTE_MOVE,
GOTOPRESET_MOVE,
STOP_MOVE,
]
), ),
vol.Optional(ATTR_CONTINUOUS_DURATION, default=0.5): cv.small_float, vol.Optional(ATTR_CONTINUOUS_DURATION, default=0.5): cv.small_float,
vol.Optional(ATTR_PRESET, default="0"): cv.string, vol.Optional(ATTR_PRESET, default="0"): cv.string,

View file

@ -39,5 +39,6 @@ CONTINUOUS_MOVE = "ContinuousMove"
RELATIVE_MOVE = "RelativeMove" RELATIVE_MOVE = "RelativeMove"
ABSOLUTE_MOVE = "AbsoluteMove" ABSOLUTE_MOVE = "AbsoluteMove"
GOTOPRESET_MOVE = "GotoPreset" GOTOPRESET_MOVE = "GotoPreset"
STOP_MOVE = "Stop"
SERVICE_PTZ = "ptz" SERVICE_PTZ = "ptz"

View file

@ -28,6 +28,7 @@ from .const import (
LOGGER, LOGGER,
PAN_FACTOR, PAN_FACTOR,
RELATIVE_MOVE, RELATIVE_MOVE,
STOP_MOVE,
TILT_FACTOR, TILT_FACTOR,
ZOOM_FACTOR, ZOOM_FACTOR,
) )
@ -433,6 +434,8 @@ class ONVIFDevice:
"Zoom": {"x": speed_val}, "Zoom": {"x": speed_val},
} }
await ptz_service.GotoPreset(req) await ptz_service.GotoPreset(req)
elif move_mode == STOP_MOVE:
await ptz_service.Stop(req)
except ONVIFError as err: except ONVIFError as err:
if "Bad Request" in err.reason: if "Bad Request" in err.reason:
LOGGER.warning("Device '%s' doesn't support PTZ.", self.name) LOGGER.warning("Device '%s' doesn't support PTZ.", self.name)

View file

@ -29,6 +29,6 @@ ptz:
description: "PTZ preset profile token. Sets the preset profile token which is executed with GotoPreset" description: "PTZ preset profile token. Sets the preset profile token which is executed with GotoPreset"
example: "1" example: "1"
move_mode: move_mode:
description: "PTZ moving mode. One of ContinuousMove, RelativeMove, AbsoluteMove or GotoPreset" description: "PTZ moving mode. One of ContinuousMove, RelativeMove, AbsoluteMove, GotoPreset, or Stop"
default: "RelativeMove" default: "RelativeMove"
example: "ContinuousMove" example: "ContinuousMove"