From 886b930e2f982ac6a5d5512da66bb1cac0b91d1b Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 23 Feb 2023 01:27:31 +0100 Subject: [PATCH] Support for `bluetooth` devices with multiple temperature sensors. --- platypush/plugins/bluetooth/ble/_mappers.py | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/platypush/plugins/bluetooth/ble/_mappers.py b/platypush/plugins/bluetooth/ble/_mappers.py index 24ea81ae7f..0f2ff5d613 100644 --- a/platypush/plugins/bluetooth/ble/_mappers.py +++ b/platypush/plugins/bluetooth/ble/_mappers.py @@ -58,6 +58,10 @@ class NullSensor: # Maps property names to transformer methods (first mapper choice). _property_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = { 'activity heart rate': lambda value, _: HeartRateSensor(value=value), + 'atmospheric pressure': lambda value, conf: PressureSensor( + value=value, + unit=conf.get('unit'), + ), 'battery': lambda value, conf: Battery( value=value, unit=conf.get('unit', '%'), @@ -108,6 +112,34 @@ _property_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = { value=value, unit=conf.get('unit', 'C'), ), + 'temperature2': lambda value, conf: TemperatureSensor( + value=value, + unit=conf.get('unit', 'C'), + ), + 'temperature3': lambda value, conf: TemperatureSensor( + value=value, + unit=conf.get('unit', 'C'), + ), + 'temperature4': lambda value, conf: TemperatureSensor( + value=value, + unit=conf.get('unit', 'C'), + ), + 'temperature5': lambda value, conf: TemperatureSensor( + value=value, + unit=conf.get('unit', 'C'), + ), + 'temperature6': lambda value, conf: TemperatureSensor( + value=value, + unit=conf.get('unit', 'C'), + ), + 'temperature7': lambda value, conf: TemperatureSensor( + value=value, + unit=conf.get('unit', 'C'), + ), + 'temperature8': lambda value, conf: TemperatureSensor( + value=value, + unit=conf.get('unit', 'C'), + ), 'voltage': lambda value, conf: VoltageSensor( value=value, unit=conf.get('unit', 'V'),