Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/skykettle-ha.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-08-13 11:32:37 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-08-13 11:32:37 +0300
commit4a7e26b93636b5f26c3e93ca8a633486881e98f4 (patch)
treec0f36be0acfe55ea5963aa71cd9169cbce7b5e92
parentfee42df0b76ea37e0b4a29292c43c3c62f7c44cd (diff)
Removed unused files
-rw-r--r--custom_components/skykettle/ble_scan.py57
-rw-r--r--custom_components/skykettle/config_flow.py6
2 files changed, 2 insertions, 61 deletions
diff --git a/custom_components/skykettle/ble_scan.py b/custom_components/skykettle/ble_scan.py
deleted file mode 100644
index 7f9a11d..0000000
--- a/custom_components/skykettle/ble_scan.py
+++ /dev/null
@@ -1,57 +0,0 @@
-import subprocess
-import asyncio
-import shlex
-import re
-from collections import namedtuple
-
-REGEX_MAC = r"^(([0-9a-fA-F]){2}[:-]?){5}[0-9a-fA-F]{2}$"
-
-BleDevice = namedtuple("BleDevice", ["mac", "name"])
-BleAdapter = namedtuple("BleAdapter", ["name", "mac"])
-
-
-async def ble_scan(device, scan_time=3):
- devopt = ""
- if device: devopt = f"-i {shlex.quote(device)}"
- proc = await asyncio.create_subprocess_shell(
- f"timeout -s INT {int(scan_time)}s hcitool {devopt} lescan",
- stdout=asyncio.subprocess.PIPE,
- stderr=asyncio.subprocess.PIPE)
- stdout, stderr = await proc.communicate()
- out_lines = stdout.decode('utf-8').split('\n')
- err = stderr.decode('utf-8')
-
- res = []
- for l in out_lines:
- cols = l.split(maxsplit=2)
- if len(cols) >= 2 and re.match(REGEX_MAC, cols[0]):
- mac = cols[0]
- name = cols[1].replace('_',' ')
- if name == "(unknown)": name = None
- if len([l for l in res if l.mac == mac]) == 0:
- res.append(BleDevice(mac, name))
-
- if err and not res:
- if "Operation not permitted" in err:
- raise PermissionError(err)
- else:
- raise Exception(err)
-
- return res
-
-async def ble_get_adapters():
- proc = await asyncio.create_subprocess_shell(
- "hcitool dev",
- stdout=asyncio.subprocess.PIPE,
- stderr=asyncio.subprocess.PIPE)
- stdout, stderr = await proc.communicate()
- out_lines = stdout.decode('utf-8').split('\n')
- err = stderr.decode('utf-8')
- if err: raise Exception(err)
-
- devices = []
- for line in out_lines:
- cols = line.split()
- if len(cols) >= 2 and re.match(REGEX_MAC, cols[1]):
- devices.append(BleAdapter(cols[0], cols[1]))
- return devices
diff --git a/custom_components/skykettle/config_flow.py b/custom_components/skykettle/config_flow.py
index 6243670..93c45cc 100644
--- a/custom_components/skykettle/config_flow.py
+++ b/custom_components/skykettle/config_flow.py
@@ -6,15 +6,13 @@ import traceback
import sys
import asyncio
import subprocess
-from homeassistant.components import bluetooth
import voluptuous as vol
+from homeassistant.components import bluetooth
from homeassistant.const import *
-import homeassistant.helpers.config_validation as cv
from homeassistant import config_entries
from homeassistant.core import callback
+import homeassistant.helpers.config_validation as cv
from .const import *
-from .ble_scan import ble_scan
-from .ble_scan import ble_get_adapters
from .kettle_connection import KettleConnection
from .skykettle import SkyKettle