Skip to content

Commit

Permalink
Add movement counter
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernst79 committed Oct 8, 2023
1 parent 0a24b6b commit 8caa137
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/ble_parser/teltonika.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def parse_teltonika(self, data, complete_local_name, source_mac, rssi):
# 15 least significant bits represent count of movement events.
moving = sensor_data[0] & (1 << 7)
count = ((sensor_data[0] & 0b01111111) << 8) + sensor_data[1]
result.update({"moving": moving, "count": count})
result.update({"moving": moving, "movement counter": count})
sensor_data = sensor_data[2:]
if flags & (1 << 5): # bit 5
# Movement sensor angle
Expand Down
13 changes: 13 additions & 0 deletions custom_components/ble_monitor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,18 @@ class BLEMonitorBinarySensorEntityDescription(
suggested_display_precision=0,
state_class=SensorStateClass.MEASUREMENT,
),
BLEMonitorSensorEntityDescription(
key="movement counter",
sensor_class="StateChangedSensor",
update_behavior="StateChange",
name="movement counter",
unique_id="mv_cnt_",
icon="mdi:counter",
native_unit_of_measurement=None,
device_class=None,
suggested_display_precision=0,
state_class=SensorStateClass.MEASUREMENT,
),
BLEMonitorSensorEntityDescription(
key="score",
sensor_class="StateChangedSensor",
Expand Down Expand Up @@ -1930,6 +1942,7 @@ class BLEMonitorBinarySensorEntityDescription(
"illuminance",
"impedance",
"moisture",
"movement counter",
"non-stabilized weight",
"opening percentage",
"pitch",
Expand Down
1 change: 1 addition & 0 deletions custom_components/ble_monitor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ class BaseSensor(RestoreSensor, SensorEntity):
# | | |**major
# | | |**minor
# | | |**count
# | | |**movement counter
# | | |**score
# | | |**air quality
# | | |**text
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/test/test_teltonika.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_teltonika_eye(self):
assert sensor_msg["humidity"] == 18
assert sensor_msg["magnetic field detected"] == 0
assert sensor_msg["moving"] == 0
assert sensor_msg["count"] == 3275
assert sensor_msg["movement counter"] == 3275
assert sensor_msg["roll"] == -57
assert sensor_msg["pitch"] == 11
assert sensor_msg["voltage"] == 3.03
Expand Down
2 changes: 1 addition & 1 deletion docs/_devices/Teltonika_eye_beacon.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ broadcasted_properties:
- pitch
- magnetic field detected
- moving
- count
- movement counter
- battery low
- rssi
broadcasted_property_notes:
Expand Down

0 comments on commit 8caa137

Please sign in to comment.