1
mirror of https://github.com/home-assistant/core synced 2024-08-31 05:57:13 +02:00

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,
RELATIVE_MOVE,
SERVICE_PTZ,
STOP_MOVE,
ZOOM_IN,
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_SPEED, default=0.5): cv.small_float,
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_PRESET, default="0"): cv.string,

View File

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

View File

@ -28,6 +28,7 @@ from .const import (
LOGGER,
PAN_FACTOR,
RELATIVE_MOVE,
STOP_MOVE,
TILT_FACTOR,
ZOOM_FACTOR,
)
@ -433,6 +434,8 @@ class ONVIFDevice:
"Zoom": {"x": speed_val},
}
await ptz_service.GotoPreset(req)
elif move_mode == STOP_MOVE:
await ptz_service.Stop(req)
except ONVIFError as err:
if "Bad Request" in err.reason:
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"
example: "1"
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"
example: "ContinuousMove"