From 0c1c1f7845759b01ac1aea5503156a788673b3ec Mon Sep 17 00:00:00 2001 From: Tim Niemueller Date: Thu, 30 Sep 2021 11:36:49 +0200 Subject: [PATCH] Fix Onvif PTZ for Imou cameras (#56592) --- homeassistant/components/onvif/device.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/onvif/device.py b/homeassistant/components/onvif/device.py index 9ebf87a4132..1d08ec04f46 100644 --- a/homeassistant/components/onvif/device.py +++ b/homeassistant/components/onvif/device.py @@ -373,10 +373,13 @@ class ONVIFDevice: ) return - req.Velocity = { - "PanTilt": {"x": pan_val, "y": tilt_val}, - "Zoom": {"x": zoom_val}, - } + velocity = {} + if pan is not None or tilt is not None: + velocity["PanTilt"] = {"x": pan_val, "y": tilt_val} + if zoom is not None: + velocity["Zoom"] = {"x": zoom_val} + + req.Velocity = velocity await ptz_service.ContinuousMove(req) await asyncio.sleep(continuous_duration)