Skip to content

Commit 94b7c8b

Browse files
committed
Add codespell
1 parent 38e3647 commit 94b7c8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+269
-597
lines changed

.ignore_words.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
adres
2+
adresse
3+
als
4+
alle
5+
conexant
6+
hass
7+
passiv
8+
periode
9+
rouge
10+
ser
11+
sur
12+
te
13+
tht

.pre-commit-config.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,12 @@ repos:
1414
- id: end-of-file-fixer
1515
- id: trailing-whitespace
1616
- id: debug-statements
17+
- repo: https://github.com/PyCQA/isort
18+
rev: 5.12.0
19+
hooks:
20+
- id: isort
21+
- repo: https://github.com/codespell-project/codespell
22+
rev: v2.1.0
23+
hooks:
24+
- id: codespell
25+
args: [--ignore-words=.ignore_words.txt]

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Please not that ESPHome Bluetooth Proxies cannot forward data to BLE monitor. Ch
6868

6969
## Important announcement about the future of BLE monitor
7070

71-
Home Assistant 2022.8 has (improved) support for passive BLE devices directly in Home Assistant. For each brand, a core BLE integration will be developed, such that maintanance can be divided over more people, using the latest Bluetooth packages (bleak). I'm working together with the Home Assistant devs to move sensors from BLE Monitor to Home Assistant core integrations. During the transition, BLE monitor will still be available, but it is possible that the core HA Bluetooth integrations will not work niceley parallel to BLE monitor. **If it is not working together (common symptom is that core integrations stop updating after a while), try to enable active scan in the BLE Monitor.** My advise, when all your sensors are available in Home Assistant, make the move. The aim is to have all sensors moved into Home Assistant as core integration. After the move, BLE monitor will probably be deprecated. If you want to help moving sensors from BLE monitor, feel free to help. Check out the links below.
71+
Home Assistant 2022.8 has (improved) support for passive BLE devices directly in Home Assistant. For each brand, a core BLE integration will be developed, such that maintenance can be divided over more people, using the latest Bluetooth packages (bleak). I'm working together with the Home Assistant devs to move sensors from BLE Monitor to Home Assistant core integrations. During the transition, BLE monitor will still be available, but it is possible that the core HA Bluetooth integrations will not work niceley parallel to BLE monitor. **If it is not working together (common symptom is that core integrations stop updating after a while), try to enable active scan in the BLE Monitor.** My advise, when all your sensors are available in Home Assistant, make the move. The aim is to have all sensors moved into Home Assistant as core integration. After the move, BLE monitor will probably be deprecated. If you want to help moving sensors from BLE monitor, feel free to help. Check out the links below.
7272

7373
**Some interesting links**
7474

custom_components/ble_monitor/__init__.py

+31-81
Original file line numberDiff line numberDiff line change
@@ -4,96 +4,46 @@
44
import json
55
import logging
66
from threading import Thread
7-
import voluptuous as vol
87

98
import aioblescan as aiobs
109
import janus
11-
10+
import voluptuous as vol
1211
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
13-
from homeassistant.const import (
14-
CONF_DEVICES,
15-
CONF_DISCOVERY,
16-
CONF_MAC,
17-
CONF_NAME,
18-
CONF_TEMPERATURE_UNIT,
19-
CONF_UNIQUE_ID,
20-
EVENT_HOMEASSISTANT_STOP,
21-
)
12+
from homeassistant.const import (CONF_DEVICES, CONF_DISCOVERY, CONF_MAC,
13+
CONF_NAME, CONF_TEMPERATURE_UNIT,
14+
CONF_UNIQUE_ID, EVENT_HOMEASSISTANT_STOP)
2215
from homeassistant.core import HomeAssistant
2316
from homeassistant.helpers import config_validation as cv
24-
from homeassistant.helpers.entity_registry import (
25-
async_entries_for_device,
26-
)
17+
from homeassistant.helpers.entity_registry import async_entries_for_device
2718
from homeassistant.util import dt
2819

2920
from .ble_parser import BleParser
30-
from .const import (
31-
AUTO_BINARY_SENSOR_LIST,
32-
AUTO_MANUFACTURER_DICT,
33-
AUTO_SENSOR_LIST,
34-
AES128KEY24_REGEX,
35-
AES128KEY32_REGEX,
36-
CONF_ACTIVE_SCAN,
37-
CONF_BATT_ENTITIES,
38-
CONF_BT_AUTO_RESTART,
39-
CONF_BT_INTERFACE,
40-
CONF_DEVICE_ENCRYPTION_KEY,
41-
CONF_DEVICE_USE_MEDIAN,
42-
CONF_DEVICE_REPORT_UNKNOWN,
43-
CONF_DEVICE_RESTORE_STATE,
44-
CONF_DEVICE_RESET_TIMER,
45-
CONF_DEVICE_TRACK,
46-
CONF_DEVICE_TRACKER_SCAN_INTERVAL,
47-
CONF_DEVICE_TRACKER_CONSIDER_HOME,
48-
CONF_HCI_INTERFACE,
49-
CONF_PACKET,
50-
CONF_GATEWAY_ID,
51-
CONF_PERIOD,
52-
CONF_LOG_SPIKES,
53-
CONF_REPORT_UNKNOWN,
54-
CONF_RESTORE_STATE,
55-
CONF_USE_MEDIAN,
56-
CONF_UUID,
57-
CONFIG_IS_FLOW,
58-
DEFAULT_ACTIVE_SCAN,
59-
DEFAULT_BATT_ENTITIES,
60-
DEFAULT_BT_AUTO_RESTART,
61-
DEFAULT_DEVICE_REPORT_UNKNOWN,
62-
DEFAULT_DEVICE_RESTORE_STATE,
63-
DEFAULT_DEVICE_RESET_TIMER,
64-
DEFAULT_DEVICE_TRACK,
65-
DEFAULT_DEVICE_TRACKER_SCAN_INTERVAL,
66-
DEFAULT_DEVICE_TRACKER_CONSIDER_HOME,
67-
DEFAULT_DEVICE_USE_MEDIAN,
68-
DEFAULT_DISCOVERY,
69-
DEFAULT_LOG_SPIKES,
70-
DEFAULT_PERIOD,
71-
DEFAULT_REPORT_UNKNOWN,
72-
DEFAULT_RESTORE_STATE,
73-
DEFAULT_USE_MEDIAN,
74-
DOMAIN,
75-
PLATFORMS,
76-
MAC_REGEX,
77-
MANUFACTURER_DICT,
78-
MEASUREMENT_DICT,
79-
REPORT_UNKNOWN_LIST,
80-
SERVICE_CLEANUP_ENTRIES,
81-
SERVICE_PARSE_DATA,
82-
)
83-
84-
from .bt_helpers import (
85-
BT_INTERFACES,
86-
BT_MULTI_SELECT,
87-
DEFAULT_BT_INTERFACE,
88-
reset_bluetooth
89-
)
90-
91-
from .helper import (
92-
config_validation_uuid,
93-
identifier_clean,
94-
dict_get_or,
95-
dict_get_or_clean,
96-
)
21+
from .bt_helpers import (BT_INTERFACES, BT_MULTI_SELECT, DEFAULT_BT_INTERFACE,
22+
reset_bluetooth)
23+
from .const import (AES128KEY24_REGEX, AES128KEY32_REGEX,
24+
AUTO_BINARY_SENSOR_LIST, AUTO_MANUFACTURER_DICT,
25+
AUTO_SENSOR_LIST, CONF_ACTIVE_SCAN, CONF_BATT_ENTITIES,
26+
CONF_BT_AUTO_RESTART, CONF_BT_INTERFACE,
27+
CONF_DEVICE_ENCRYPTION_KEY, CONF_DEVICE_REPORT_UNKNOWN,
28+
CONF_DEVICE_RESET_TIMER, CONF_DEVICE_RESTORE_STATE,
29+
CONF_DEVICE_TRACK, CONF_DEVICE_TRACKER_CONSIDER_HOME,
30+
CONF_DEVICE_TRACKER_SCAN_INTERVAL, CONF_DEVICE_USE_MEDIAN,
31+
CONF_GATEWAY_ID, CONF_HCI_INTERFACE, CONF_LOG_SPIKES,
32+
CONF_PACKET, CONF_PERIOD, CONF_REPORT_UNKNOWN,
33+
CONF_RESTORE_STATE, CONF_USE_MEDIAN, CONF_UUID,
34+
CONFIG_IS_FLOW, DEFAULT_ACTIVE_SCAN, DEFAULT_BATT_ENTITIES,
35+
DEFAULT_BT_AUTO_RESTART, DEFAULT_DEVICE_REPORT_UNKNOWN,
36+
DEFAULT_DEVICE_RESET_TIMER, DEFAULT_DEVICE_RESTORE_STATE,
37+
DEFAULT_DEVICE_TRACK, DEFAULT_DEVICE_TRACKER_CONSIDER_HOME,
38+
DEFAULT_DEVICE_TRACKER_SCAN_INTERVAL,
39+
DEFAULT_DEVICE_USE_MEDIAN, DEFAULT_DISCOVERY,
40+
DEFAULT_LOG_SPIKES, DEFAULT_PERIOD, DEFAULT_REPORT_UNKNOWN,
41+
DEFAULT_RESTORE_STATE, DEFAULT_USE_MEDIAN, DOMAIN,
42+
MAC_REGEX, MANUFACTURER_DICT, MEASUREMENT_DICT, PLATFORMS,
43+
REPORT_UNKNOWN_LIST, SERVICE_CLEANUP_ENTRIES,
44+
SERVICE_PARSE_DATA)
45+
from .helper import (config_validation_uuid, dict_get_or, dict_get_or_clean,
46+
identifier_clean)
9747

9848
_LOGGER = logging.getLogger(__name__)
9949

custom_components/ble_monitor/binary_sensor.py

+14-41
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,25 @@
11
"""Passive BLE monitor binary sensor platform."""
2-
from datetime import timedelta
32
import asyncio
43
import logging
4+
from datetime import timedelta
55

6-
from homeassistant.components.binary_sensor import (
7-
BinarySensorEntity
8-
)
9-
10-
from homeassistant.const import (
11-
CONF_DEVICES,
12-
CONF_NAME,
13-
CONF_MAC,
14-
CONF_UNIQUE_ID,
15-
ATTR_BATTERY_LEVEL,
16-
STATE_OFF,
17-
STATE_ON,
18-
)
6+
from homeassistant.components.binary_sensor import BinarySensorEntity
7+
from homeassistant.const import (ATTR_BATTERY_LEVEL, CONF_DEVICES, CONF_MAC,
8+
CONF_NAME, CONF_UNIQUE_ID, STATE_OFF,
9+
STATE_ON)
1910
from homeassistant.helpers.event import async_call_later
2011
from homeassistant.helpers.restore_state import RestoreEntity
2112
from homeassistant.util import dt
2213

23-
from .helper import (
24-
identifier_normalize,
25-
identifier_clean,
26-
detect_conf_type,
27-
dict_get_or,
28-
dict_get_or_normalize,
29-
)
30-
31-
from .const import (
32-
AUTO_MANUFACTURER_DICT,
33-
AUTO_BINARY_SENSOR_LIST,
34-
CONF_PERIOD,
35-
CONF_RESTORE_STATE,
36-
CONF_DEVICE_RESTORE_STATE,
37-
CONF_DEVICE_RESET_TIMER,
38-
CONF_UUID,
39-
DEFAULT_DEVICE_RESET_TIMER,
40-
KETTLES,
41-
MANUFACTURER_DICT,
42-
MEASUREMENT_DICT,
43-
RENAMED_FIRMWARE_DICT,
44-
RENAMED_MANUFACTURER_DICT,
45-
RENAMED_MODEL_DICT,
46-
BINARY_SENSOR_TYPES,
47-
DOMAIN,
48-
BLEMonitorBinarySensorEntityDescription,
49-
)
14+
from .const import (AUTO_BINARY_SENSOR_LIST, AUTO_MANUFACTURER_DICT,
15+
BINARY_SENSOR_TYPES, CONF_DEVICE_RESET_TIMER,
16+
CONF_DEVICE_RESTORE_STATE, CONF_PERIOD, CONF_RESTORE_STATE,
17+
CONF_UUID, DEFAULT_DEVICE_RESET_TIMER, DOMAIN, KETTLES,
18+
MANUFACTURER_DICT, MEASUREMENT_DICT, RENAMED_FIRMWARE_DICT,
19+
RENAMED_MANUFACTURER_DICT, RENAMED_MODEL_DICT,
20+
BLEMonitorBinarySensorEntityDescription)
21+
from .helper import (detect_conf_type, dict_get_or, dict_get_or_normalize,
22+
identifier_clean, identifier_normalize)
5023

5124
_LOGGER = logging.getLogger(__name__)
5225

custom_components/ble_monitor/ble_parser/__init__.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Parser for passive BLE advertisements."""
2-
from typing import Optional
32
import logging
3+
from typing import Optional
44

55
from .acconeer import parse_acconeer
66
from .airmentor import parse_airmentor
@@ -11,10 +11,10 @@
1111
from .bluemaestro import parse_bluemaestro
1212
from .blustream import parse_blustream
1313
from .bparasite import parse_bparasite
14+
from .bthome import parse_bthome
1415
from .const import JAALEE_TYPES, TILT_TYPES
1516
from .govee import parse_govee
1617
from .helpers import to_mac, to_unformatted_mac
17-
from .bthome import parse_bthome
1818
from .hhcc import parse_hhcc
1919
from .holyiot import parse_holyiot
2020
from .hormann import parse_hormann
@@ -29,21 +29,21 @@
2929
from .mikrotik import parse_mikrotik
3030
from .miscale import parse_miscale
3131
from .moat import parse_moat
32-
from .oras import parse_oras
3332
from .oral_b import parse_oral_b
33+
from .oras import parse_oras
3434
from .qingping import parse_qingping
3535
from .relsib import parse_relsib
3636
from .ruuvitag import parse_ruuvitag
37-
from .sensorpush import parse_sensorpush
3837
from .sensirion import parse_sensirion
39-
from .switchbot import parse_switchbot
38+
from .sensorpush import parse_sensorpush
4039
from .smartdry import parse_smartdry
40+
from .switchbot import parse_switchbot
4141
from .teltonika import parse_teltonika
4242
from .thermobeacon import parse_thermobeacon
4343
from .thermopro import parse_thermopro
4444
from .tilt import parse_tilt
45-
from .xiaomi import parse_xiaomi
4645
from .xiaogui import parse_xiaogui
46+
from .xiaomi import parse_xiaomi
4747

4848
_LOGGER = logging.getLogger(__name__)
4949

custom_components/ble_monitor/ble_parser/acconeer.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
import logging
33
from struct import unpack
44

5-
from .helpers import (
6-
to_mac,
7-
to_unformatted_mac,
8-
)
5+
from .helpers import to_mac, to_unformatted_mac
96

107
_LOGGER = logging.getLogger(__name__)
118

custom_components/ble_monitor/ble_parser/airmentor.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
"""Parser for Air Mentor BLE advertisements"""
22
import logging
3-
from struct import unpack
43
import math
4+
from struct import unpack
55

6-
from .helpers import (
7-
to_mac,
8-
to_unformatted_mac,
9-
)
6+
from .helpers import to_mac, to_unformatted_mac
107

118
_LOGGER = logging.getLogger(__name__)
129

custom_components/ble_monitor/ble_parser/almendo.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
"""Parser for Almendo bluSensor BLE advertisements"""
22
import logging
33
from struct import unpack
4-
from .helpers import (
5-
to_mac,
6-
to_unformatted_mac,
7-
)
4+
5+
from .helpers import to_mac, to_unformatted_mac
86

97
_LOGGER = logging.getLogger(__name__)
108

custom_components/ble_monitor/ble_parser/altbeacon.py

+5-22
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,11 @@
33
from struct import unpack
44
from typing import Final
55

6-
from .const import (
7-
CONF_MAC,
8-
CONF_TYPE,
9-
CONF_PACKET,
10-
CONF_FIRMWARE,
11-
CONF_MANUFACTURER,
12-
CONF_DATA,
13-
CONF_RSSI,
14-
CONF_UUID,
15-
CONF_TRACKER_ID,
16-
CONF_MAJOR,
17-
CONF_MINOR,
18-
CONF_MEASURED_POWER,
19-
20-
MANUFACTURER_DICT,
21-
DEFAULT_MANUFACTURER,
22-
)
23-
from .helpers import (
24-
to_mac,
25-
to_uuid,
26-
to_unformatted_mac,
27-
)
6+
from .const import (CONF_DATA, CONF_FIRMWARE, CONF_MAC, CONF_MAJOR,
7+
CONF_MANUFACTURER, CONF_MEASURED_POWER, CONF_MINOR,
8+
CONF_PACKET, CONF_RSSI, CONF_TRACKER_ID, CONF_TYPE,
9+
CONF_UUID, DEFAULT_MANUFACTURER, MANUFACTURER_DICT)
10+
from .helpers import to_mac, to_unformatted_mac, to_uuid
2811

2912
_LOGGER = logging.getLogger(__name__)
3013

custom_components/ble_monitor/ble_parser/amazfit.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
import logging
33
from struct import unpack
44

5-
from .helpers import (
6-
to_mac,
7-
to_unformatted_mac,
8-
)
5+
from .helpers import to_mac, to_unformatted_mac
96

107
_LOGGER = logging.getLogger(__name__)
118

custom_components/ble_monitor/ble_parser/atc.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
"""Parser for ATC BLE advertisements"""
22
import logging
33
from struct import unpack
4+
45
from Cryptodome.Cipher import AES
56

6-
from .helpers import (
7-
to_mac,
8-
to_unformatted_mac,
9-
)
7+
from .helpers import to_mac, to_unformatted_mac
108

119
_LOGGER = logging.getLogger(__name__)
1210

custom_components/ble_monitor/ble_parser/bluemaestro.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
import logging
33
from struct import unpack
44

5-
from .helpers import (
6-
to_mac,
7-
to_unformatted_mac,
8-
)
5+
from .helpers import to_mac, to_unformatted_mac
96

107
_LOGGER = logging.getLogger(__name__)
118

0 commit comments

Comments
 (0)