forked from platypush/platypush
Added unit
to bluetooth
mappers whenever available.
This commit is contained in:
parent
d961e2a997
commit
dd3f683006
1 changed files with 11 additions and 4 deletions
|
@ -101,7 +101,14 @@ _property_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
|
||||||
# Maps reported units to transformer methods (second mapper choice).
|
# Maps reported units to transformer methods (second mapper choice).
|
||||||
_unit_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
|
_unit_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
|
||||||
'status': lambda value, _: BinarySensor(value=value),
|
'status': lambda value, _: BinarySensor(value=value),
|
||||||
'int': lambda value, _: NumericSensor(value=value),
|
'int': lambda value, conf: NumericSensor(
|
||||||
|
value=value,
|
||||||
|
unit=conf.get('unit'),
|
||||||
|
),
|
||||||
|
'float': lambda value, conf: NumericSensor(
|
||||||
|
value=value,
|
||||||
|
unit=conf.get('unit'),
|
||||||
|
),
|
||||||
'%': lambda value, conf: NumericSensor(
|
'%': lambda value, conf: NumericSensor(
|
||||||
value=value,
|
value=value,
|
||||||
unit='%',
|
unit='%',
|
||||||
|
@ -114,9 +121,9 @@ _unit_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
|
||||||
# Maps value types to transformer methods (third mapper choice).
|
# Maps value types to transformer methods (third mapper choice).
|
||||||
_value_type_to_entity: Dict[type, Callable[[Any, Dict[str, Any]], Entity]] = {
|
_value_type_to_entity: Dict[type, Callable[[Any, Dict[str, Any]], Entity]] = {
|
||||||
bool: lambda value, _: BinarySensor(value=value),
|
bool: lambda value, _: BinarySensor(value=value),
|
||||||
int: lambda value, _: NumericSensor(value=value),
|
int: lambda value, conf: NumericSensor(value=value, unit=conf.get('unit')),
|
||||||
float: lambda value, _: NumericSensor(value=value),
|
float: lambda value, conf: NumericSensor(value=value, unit=conf.get('unit')),
|
||||||
str: lambda value, _: RawSensor(value=value),
|
str: lambda value, conf: RawSensor(value=value, unit=conf.get('unit')),
|
||||||
bytes: lambda value, _: RawSensor(value=value),
|
bytes: lambda value, _: RawSensor(value=value),
|
||||||
bytearray: lambda value, _: RawSensor(value=value),
|
bytearray: lambda value, _: RawSensor(value=value),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue