From f7e8cfe5a7e9e16760ca5b76d2e99e675f575b4a Mon Sep 17 00:00:00 2001
From: Fabio Manganiello <fabio@manganiello.tech>
Date: Wed, 22 Mar 2023 14:14:59 +0100
Subject: [PATCH] Don't include `unit` in BLE sensors when they are matched
 against the native type.

It's likely to just include the native type name anyway.
---
 platypush/plugins/bluetooth/_ble/_mappers.py | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/platypush/plugins/bluetooth/_ble/_mappers.py b/platypush/plugins/bluetooth/_ble/_mappers.py
index 8b0d1866..8fb46c96 100644
--- a/platypush/plugins/bluetooth/_ble/_mappers.py
+++ b/platypush/plugins/bluetooth/_ble/_mappers.py
@@ -168,17 +168,11 @@ _property_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
 # Maps reported units to transformer methods (second mapper choice).
 _unit_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
     'status': lambda value, _: BinarySensor(value=value),
-    'int': lambda value, conf: NumericSensor(
-        value=value,
-        unit=conf.get('unit'),
-    ),
-    'float': lambda value, conf: NumericSensor(
-        value=value,
-        unit=conf.get('unit'),
-    ),
+    'int': lambda value, _: NumericSensor(value=value),
+    'float': lambda value, _: NumericSensor(value=value),
     '%': lambda value, conf: NumericSensor(
         value=value,
-        unit='%',
+        unit=conf.get('unit', '%'),
         min=conf.get('min', 0),
         max=conf.get('min', 100),
     ),
@@ -188,9 +182,9 @@ _unit_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
 # Maps value types to transformer methods (third mapper choice).
 _value_type_to_entity: Dict[type, Callable[[Any, Dict[str, Any]], Entity]] = {
     bool: lambda value, _: BinarySensor(value=value),
-    int: lambda value, conf: NumericSensor(value=value, unit=conf.get('unit')),
-    float: lambda value, conf: NumericSensor(value=value, unit=conf.get('unit')),
-    str: lambda value, conf: RawSensor(value=value, unit=conf.get('unit')),
+    int: lambda value, _: NumericSensor(value=value),
+    float: lambda value, _: NumericSensor(value=value),
+    str: lambda value, _: RawSensor(value=value),
     bytes: lambda value, _: RawSensor(value=value),
     bytearray: lambda value, _: RawSensor(value=value),
 }