コード例 #1
0
    def __init__(
        self, hass: HomeAssistant, entry: dict, tapoData: Tapo, HDStream: boolean,
    ):
        super().__init__()
        self._controller = tapoData["controller"]
        self._coordinator = tapoData["coordinator"]
        self._ffmpeg = hass.data[DATA_FFMPEG]
        self._entry = entry
        self._hass = hass
        self._enabled = False
        self._hdstream = HDStream
        self._host = entry.data.get(CONF_IP_ADDRESS)
        self._username = entry.data.get(CONF_USERNAME)
        self._password = entry.data.get(CONF_PASSWORD)
        self._enable_stream = entry.data.get(ENABLE_STREAM)
        self._enable_sound_detection = entry.data.get(ENABLE_SOUND_DETECTION)
        self._sound_detection_peak = entry.data.get(SOUND_DETECTION_PEAK)
        self._sound_detection_duration = entry.data.get(SOUND_DETECTION_DURATION)
        self._sound_detection_reset = entry.data.get(SOUND_DETECTION_RESET)
        self._attributes = tapoData["camData"]["basic_info"]

        self.updateCam(tapoData["camData"])

        hass.data[DOMAIN][entry.entry_id]["noiseSensorStarted"] = False

        if self._enable_sound_detection:
            self._noiseSensor = ffmpeg_sensor.SensorNoise(
                self._ffmpeg.binary, self._noiseCallback
            )
            self._noiseSensor.set_options(
                time_duration=int(self._sound_detection_duration),
                time_reset=int(self._sound_detection_reset),
                peak=int(self._sound_detection_peak),
            )
コード例 #2
0
    def __init__(self, hass, manager, config):
        """Initialize FFmpeg noise binary sensor."""

        super().__init__(config)
        self.ffmpeg = ffmpeg_sensor.SensorNoise(manager.binary, self._async_callback)