Skip to content

Commit

Permalink
and more binary sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernst79 committed Sep 23, 2023
1 parent ba0c841 commit 5a6096d
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 82 deletions.
10 changes: 5 additions & 5 deletions custom_components/ble_monitor/ble_parser/bthome_const.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ class MeasTypes:
meas_format="battery",
),
0x16: MeasTypes(
meas_format="battery_charging",
meas_format="battery charging",
),
0x17: MeasTypes(
meas_format="carbon_monoxide",
meas_format="carbon monoxide",
),
0x18: MeasTypes(
meas_format="cold",
Expand All @@ -141,10 +141,10 @@ class MeasTypes:
meas_format="door",
),
0x1B: MeasTypes(
meas_format="garage_door",
meas_format="garage door",
),
0x1C: MeasTypes(
meas_format="gas_detected",
meas_format="gas detected",
),
0x1D: MeasTypes(
meas_format="heat",
Expand All @@ -156,7 +156,7 @@ class MeasTypes:
meas_format="lock",
),
0x20: MeasTypes(
meas_format="moisture_detected",
meas_format="moisture detected",
),
0x21: MeasTypes(
meas_format="motion",
Expand Down
172 changes: 101 additions & 71 deletions custom_components/ble_monitor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ class BLEMonitorBinarySensorEntityDescription(
device_class=BinarySensorDeviceClass.CONNECTIVITY,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
key="door",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble door",
unique_id="do_",
device_class=BinarySensorDeviceClass.DOOR,
force_update=False,
),
BLEMonitorBinarySensorEntityDescription(
key="garage_door",
sensor_class="BaseBinarySensor",
Expand Down Expand Up @@ -188,49 +197,67 @@ class BLEMonitorBinarySensorEntityDescription(
device_class=BinarySensorDeviceClass.HEAT,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
key="light",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble light",
unique_id="lt_",
device_class=BinarySensorDeviceClass.LIGHT,
force_update=False,
),
BLEMonitorBinarySensorEntityDescription(
key="lock",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble lock",
unique_id="lock_",
device_class=BinarySensorDeviceClass.LOCK,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
key="moisture_detected",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="moisture",
unique_id="bmoist_",
unique_id="mo_",
device_class=BinarySensorDeviceClass.MOISTURE,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
key="binary",
key="moisture",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble binary",
unique_id="bi_",
device_class=None,
force_update=True,
name="ble moisture",
unique_id="mo_",
device_class=BinarySensorDeviceClass.MOISTURE,
force_update=False,
),
BLEMonitorBinarySensorEntityDescription(
key="remote single press",
sensor_class="BaseBinarySensor",
key="motion",
sensor_class="MotionBinarySensor",
update_behavior="Instantly",
name="ble remote binary single press",
unique_id="rb_single_press_",
device_class=None,
force_update=True,
name="ble motion",
unique_id="mn_",
device_class=BinarySensorDeviceClass.MOTION,
force_update=False,
),
BLEMonitorBinarySensorEntityDescription(
key="remote long press",
key="moving",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble remote binary long press",
unique_id="rb_long_press_",
device_class=None,
name="moving",
unique_id="bmove_",
device_class=BinarySensorDeviceClass.MOVING,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
key="switch",
key="occupancy",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble switch",
unique_id="sw_",
device_class=BinarySensorDeviceClass.POWER,
name="occupancy",
unique_id="bocc_",
device_class=BinarySensorDeviceClass.OCCUPANCY,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
Expand All @@ -243,77 +270,87 @@ class BLEMonitorBinarySensorEntityDescription(
force_update=False,
),
BLEMonitorBinarySensorEntityDescription(
key="light",
key="plug",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble light",
unique_id="lt_",
device_class=BinarySensorDeviceClass.LIGHT,
name="ble plug",
unique_id="plug_",
device_class=BinarySensorDeviceClass.PLUG,
force_update=False,
),
BLEMonitorBinarySensorEntityDescription(
key="moisture",
key="smoke detector",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble moisture",
unique_id="mo_",
device_class=BinarySensorDeviceClass.MOISTURE,
name="ble smoke detector",
unique_id="sd_",
device_class=BinarySensorDeviceClass.SMOKE,
force_update=False,
),
BLEMonitorBinarySensorEntityDescription(
key="motion",
sensor_class="MotionBinarySensor",
key="vibration",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble motion",
unique_id="mn_",
device_class=BinarySensorDeviceClass.MOTION,
force_update=False,
name="ble vibration",
unique_id="vi_",
icon="mdi:vibrate",
device_class=BinarySensorDeviceClass.VIBRATION,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
key="weight removed",
key="binary",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble weight removed",
icon="mdi:weight",
unique_id="wr_",
name="ble binary",
unique_id="bi_",
device_class=None,
force_update=False,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
key="smoke detector",
key="remote single press",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble smoke detector",
unique_id="sd_",
device_class=BinarySensorDeviceClass.SMOKE,
force_update=False,
name="ble remote binary single press",
unique_id="rb_single_press_",
device_class=None,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
key="fingerprint",
key="remote long press",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble fingerprint",
icon="mdi:fingerprint",
unique_id="fp_",
name="ble remote binary long press",
unique_id="rb_long_press_",
device_class=None,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
key="door",
key="switch",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble door",
unique_id="do_",
device_class=BinarySensorDeviceClass.DOOR,
name="ble switch",
unique_id="sw_",
device_class=BinarySensorDeviceClass.POWER,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
key="weight removed",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble weight removed",
icon="mdi:weight",
unique_id="wr_",
device_class=None,
force_update=False,
),
BLEMonitorBinarySensorEntityDescription(
key="lock",
key="fingerprint",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble lock",
unique_id="lock_",
device_class=BinarySensorDeviceClass.LOCK,
name="ble fingerprint",
icon="mdi:fingerprint",
unique_id="fp_",
device_class=None,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
Expand Down Expand Up @@ -363,16 +400,6 @@ class BLEMonitorBinarySensorEntityDescription(
device_class=None,
force_update=False,
),
BLEMonitorBinarySensorEntityDescription(
key="vibration",
sensor_class="BaseBinarySensor",
update_behavior="Instantly",
name="ble vibration",
unique_id="vi_",
icon="mdi:vibrate",
device_class=BinarySensorDeviceClass.VIBRATION,
force_update=True,
),
BLEMonitorBinarySensorEntityDescription(
key="dropping",
sensor_class="BaseBinarySensor",
Expand Down Expand Up @@ -1572,22 +1599,25 @@ class BLEMonitorBinarySensorEntityDescription(

# Binary Sensors that are automatically added if device is in AUTO_MANUFACTURER_DICT
AUTO_BINARY_SENSOR_LIST = [
"battery_charging",
"carbon_monoxide",
"battery charging",
"carbon monoxide",
"cold",
"connectivity",
"binary",
"door",
"dropping",
"garage_door",
"gas_detected",
"garage door",
"gas detected",
"heat",
"impact",
"light",
"lock",
"motion",
"moisture_detected"
"moisture detected"
"moving",
"occupancy",
"opening",
"plug",
"smoke",
"switch",
"tilt",
Expand Down
Loading

0 comments on commit 5a6096d

Please sign in to comment.