agittins / bermuda

Bermuda Bluetooth/BLE Triangulation / Trilateration for HomeAssistant
MIT License
407 stars 10 forks source link

Introducing Calibration Entities for RSSI Values to Enhance Device Tracking Accuracy #254

Closed jleinenbach closed 1 month ago

jleinenbach commented 1 month ago

Description:

To improve the accuracy of RSSI (Received Signal Strength Indicator) values and ensure consistency across different devices (e.g., ESP32 vs. Shelly Plug S), I propose adding a new feature to the Bermuda BLE Trilateration system. This feature will introduce calibration entities that allow users to input calibration values. By calibrating the RSSI values, we can achieve more comparable results across various devices and prevent devices from erroneously "jumping" between rooms. This enhancement is particularly crucial for maintaining precise location tracking in environments with multiple types of scanners and trackers.

Benefits:

  1. Improved Accuracy: Calibration will account for the inherent differences in RSSI readings from various devices, leading to more accurate location tracking.
  2. Consistency Across Devices: Standardized calibration values will ensure that RSSI readings are comparable across different hardware, reducing discrepancies.
  3. Reduced False Positives: By calibrating the RSSI values, we can minimize the chances of devices being incorrectly identified as moving between rooms, enhancing the reliability of the tracking system.

Proposed Changes:

  1. Add Calibration Entities: Introduce new entities in the Bermuda integration that store calibration values for each type of device/scanner.
  2. User Interface for Calibration: Implement a user-friendly interface to allow users to input and manage calibration values for their devices.
  3. Modify RSSI Calculation: Adjust the RSSI calculation logic to incorporate the calibration values, ensuring that the reported RSSI values reflect the calibrated readings.

Implementation Details:

  1. Define Calibration Entities:

    • Create a new entity type CalibrationEntity with attributes for the calibration offset and scaling factors.
    • Store these entities in the Bermuda configuration.
  2. User Interface:

    • Extend the configuration flow to include steps for adding and managing calibration values.
    • Provide a form where users can select their devices and input the necessary calibration values (offset and scale).
  3. RSSI Calculation:

    • Modify the existing RSSI calculation logic in the Bermuda integration to apply the calibration values before using the RSSI readings for trilateration.
    • Ensure that the calibrated RSSI values are used consistently throughout the system.

Example:

Below is an outline of the proposed changes in the configuration flow (extracted from the existing implementation):

async def async_step_globalopts(self, user_input=None):
    """Handle global options flow."""
    if user_input is not None:
        self.options.update(user_input)
        return await self._update_options()

    data_schema = {
        vol.Required(
            CONF_MAX_RADIUS,
            default=self.options.get(CONF_MAX_RADIUS, DEFAULT_MAX_RADIUS),
        ): vol.Coerce(float),
        vol.Required(
            CONF_MAX_VELOCITY,
            default=self.options.get(CONF_MAX_VELOCITY, DEFAULT_MAX_VELOCITY),
        ): vol.Coerce(float),
        # Add calibration fields
        vol.Required(
            CONF_RSSI_CALIBRATION_OFFSET,
            default=self.options.get(CONF_RSSI_CALIBRATION_OFFSET, 0.0),
        ): vol.Coerce(float),
        vol.Required(
            CONF_RSSI_CALIBRATION_SCALE,
            default=self.options.get(CONF_RSSI_CALIBRATION_SCALE, 1.0),
        ): vol.Coerce(float),
    }

    return self.async_show_form(
        step_id="globalopts", data_schema=vol.Schema(data_schema)
    )

By implementing these enhancements, we can significantly improve the reliability and accuracy of the Bermuda BLE Trilateration system, providing users with a more consistent and dependable tracking solution.

This feature request was created with the assistance of ChatGPT.

jleinenbach commented 1 month ago

I'm not sure if an integration (Bermuda) can add entities to devices from another integration (e.g., ESPHome). However, if it works, it could be configured like this:

image

Alternatively, it should work with adding a "control" in Home Assistant.

jleinenbach commented 1 month ago

Same suggestion: https://github.com/agittins/bermuda/issues/45

jleinenbach commented 1 month ago

Closing as duplicate.