diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 151868a1663981f6d7d1ffc16e27c413492b0aa5..1a0bfb16a9be406c50d00e6fafe0510592ebc733 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -33,7 +33,7 @@
     {
       "label": "Flake8",
       "type": "shell",
-      "command": "flake8 homeassistant tests",
+      "command": "pre-commit run flake8 --all-files",
       "group": {
         "kind": "test",
         "isDefault": true
diff --git a/script/lazytox.py b/script/lazytox.py
index 026d4639a065c6b70b86e06f0d77991fdc949274..ca8a160e7dced2f3723459856d27e6b41c62ab88 100755
--- a/script/lazytox.py
+++ b/script/lazytox.py
@@ -120,7 +120,7 @@ async def pylint(files):
 
 async def flake8(files):
     """Exec flake8."""
-    _, log = await async_exec("flake8", "--doctests", *files)
+    _, log = await async_exec("pre-commit", "run", "flake8", "--files", *files)
     res = []
     for line in log.splitlines():
         line = line.split(":")
diff --git a/script/lint b/script/lint
index 8ba14d8939ef875ceef5226114fe1cf4e8b41c08..e4bf74cf602d467de61a5abf03903b6428dce37c 100755
--- a/script/lint
+++ b/script/lint
@@ -15,7 +15,7 @@ printf "%s\n" $files
 echo "================"
 echo "LINT with flake8"
 echo "================"
-flake8 --doctests $files
+pre-commit run flake8 --files $files
 echo "================"
 echo "LINT with pylint"
 echo "================"
diff --git a/setup.cfg b/setup.cfg
index 6d0e5378b44de9f231d9dc9b92d0734f62e4fe62..bb2b1652ffa20c053a420e9365b1d8a4da9ff8c6 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -21,6 +21,7 @@ norecursedirs = .git testing_config
 
 [flake8]
 exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build
+doctests = True
 # To work with Black
 max-line-length = 88
 # E501: line too long