Skip to content

Commit

Permalink
feat: add Formaldehyde, Consumable and Voltage sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jc2k authored Jul 25, 2022
1 parent c7b4d72 commit 8292de7
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/xiaomi_ble/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,13 @@ def obj1010(
"""Formaldehyde"""
if len(xobj) == 2:
(fmdh,) = FMDH_STRUCT.unpack(xobj)
return {"formaldehyde": fmdh / 100}
device.update_sensor(
key="formaldehyde",
name="Formaldehyde",
native_unit_of_measurement=Units.CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER,
native_value=fmdh / 100,
)
return {}
else:
return {}

Expand All @@ -625,7 +631,13 @@ def obj1013(
xobj: bytes, device: XiaomiBluetoothDeviceData, device_type: str
) -> dict[str, Any]:
"""Consumable (in percent)"""
return {"consumable": xobj[0]}
device.update_sensor(
key="consumable",
name="Consumable",
native_unit_of_measurement=Units.PERCENTAGE,
native_value=xobj[0],
)
return {}


def obj1014(
Expand Down Expand Up @@ -693,7 +705,13 @@ def obj100a(
batt = xobj[0]
volt = 2.2 + (3.1 - 2.2) * (batt / 100)
device.update_predefined_sensor(SensorLibrary.BATTERY__PERCENTAGE, batt)
return {"voltage": volt}
device.update_sensor(
key="voltage",
name="Voltage",
native_unit_of_measurement=Units.ELECTRIC_POTENTIAL_VOLT,
native_value=volt,
)
return {}


def obj100d(
Expand Down

0 comments on commit 8292de7

Please sign in to comment.