From ded054c7da775fbb1f507fbce7a2c3717a124320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Thu, 4 Jul 2024 16:51:59 +0200 Subject: [PATCH] Fix #572: ffmpeg for sound detection doesn't terminate on Home Assistant restart --- custom_components/tapo_control/binary_sensor.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/custom_components/tapo_control/binary_sensor.py b/custom_components/tapo_control/binary_sensor.py index 2087594..946c7d2 100644 --- a/custom_components/tapo_control/binary_sensor.py +++ b/custom_components/tapo_control/binary_sensor.py @@ -9,6 +9,11 @@ BinarySensorDeviceClass, ) +from homeassistant.components.ffmpeg import ( + FFmpegManager, + get_ffmpeg_manager, +) + from homeassistant.const import STATE_ON, STATE_OFF from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.entity import DeviceInfo @@ -117,8 +122,10 @@ def __init__(self, entry: dict, hass: HomeAssistant, config_entry): self._sound_detection_reset = config_entry.data.get(SOUND_DETECTION_RESET) self.latestCamData = entry["camData"] + manager = get_ffmpeg_manager(hass) + self._noiseSensor = ffmpeg_sensor.SensorNoise( - self._ffmpeg.binary, self._noiseCallback + manager.binary, self._noiseCallback ) self._noiseSensor.set_options( time_duration=int(self._sound_detection_duration),