diff --git a/custom_components/ble_monitor/ble_parser/teltonika.py b/custom_components/ble_monitor/ble_parser/teltonika.py index c027c23d0..3f290cdea 100644 --- a/custom_components/ble_monitor/ble_parser/teltonika.py +++ b/custom_components/ble_monitor/ble_parser/teltonika.py @@ -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 diff --git a/custom_components/ble_monitor/const.py b/custom_components/ble_monitor/const.py index f11b78e49..c2f686270 100755 --- a/custom_components/ble_monitor/const.py +++ b/custom_components/ble_monitor/const.py @@ -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", @@ -1930,6 +1942,7 @@ class BLEMonitorBinarySensorEntityDescription( "illuminance", "impedance", "moisture", + "movement counter", "non-stabilized weight", "opening percentage", "pitch", diff --git a/custom_components/ble_monitor/sensor.py b/custom_components/ble_monitor/sensor.py index d5a16e2b0..3fb2e52cf 100644 --- a/custom_components/ble_monitor/sensor.py +++ b/custom_components/ble_monitor/sensor.py @@ -356,6 +356,7 @@ class BaseSensor(RestoreSensor, SensorEntity): # | | |**major # | | |**minor # | | |**count + # | | |**movement counter # | | |**score # | | |**air quality # | | |**text diff --git a/custom_components/ble_monitor/test/test_teltonika.py b/custom_components/ble_monitor/test/test_teltonika.py index 47850e9c8..9875d09f1 100644 --- a/custom_components/ble_monitor/test/test_teltonika.py +++ b/custom_components/ble_monitor/test/test_teltonika.py @@ -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 diff --git a/docs/_devices/Teltonika_eye_beacon.md b/docs/_devices/Teltonika_eye_beacon.md index ba5d318f3..b7e571734 100644 --- a/docs/_devices/Teltonika_eye_beacon.md +++ b/docs/_devices/Teltonika_eye_beacon.md @@ -11,7 +11,7 @@ broadcasted_properties: - pitch - magnetic field detected - moving - - count + - movement counter - battery low - rssi broadcasted_property_notes: