Skip to content

Commit

Permalink
Add support smoke and gas sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Sep 19, 2020
1 parent eb4654c commit f53a29b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
3 changes: 2 additions & 1 deletion custom_components/xiaomi_gateway3/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def _set_no_motion(self, *args):
def update(self, data: dict = None):
if self._attr not in data:
return
self._state = data[self._attr] == 1
# gas and smoke => 1 and 2
self._state = data[self._attr] >= 1
self.schedule_update_ha_state()

if self._state:
Expand Down
14 changes: 13 additions & 1 deletion custom_components/xiaomi_gateway3/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
DEVICE_CLASS_PRESSURE: 'hPa',
DEVICE_CLASS_ILLUMINANCE: 'lm',
DEVICE_CLASS_POWER: POWER_WATT,
'consumption': ENERGY_WATT_HOUR
'consumption': ENERGY_WATT_HOUR,
'gas density': '% LEL',
'smoke density': '% obs/ft',
}

ICONS = {
'consumption': 'mdi:flash',
'gas density': 'mdi:google-circles-communities',
'smoke density': 'mdi:google-circles-communities',
}


Expand Down Expand Up @@ -43,6 +51,10 @@ def device_class(self):
def unit_of_measurement(self):
return UNITS.get(self._attr)

@property
def icon(self):
return ICONS.get(self._attr)

def update(self, data: dict = None):
if self._attr not in data:
return
Expand Down
14 changes: 14 additions & 0 deletions custom_components/xiaomi_gateway3/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,20 @@
['2.1', '2.1', 'illuminance', 'sensor'],
['3.1', '3.1', 'battery', 'sensor'],
]
}, {
'lumi.sensor_smoke': ["Honeywell", "Smoke Sensor", "JTYJ-GD-01LM/BW"],
'params': [
['0.1.85', 'density', 'smoke density', 'sensor'],
['13.1.85', 'alarm', 'smoke', 'binary_sensor'],
['8.0.2001', 'battery', 'battery', 'sensor'],
]
}, {
'lumi.sensor_natgas': ["Honeywell", "Gas Sensor", "JTQJ-BF-01LM/BW"],
'params': [
['0.1.85', 'density', 'gas density', 'sensor'],
['13.1.85', 'alarm', 'gas', 'binary_sensor'],
['8.0.2001', 'battery', 'battery', 'sensor'],
]
}, { # OTHER MANUFACTURERS
'TRADFRI bulb E27 W opal 1000lm': ["IKEA", "Bulb E27"],
'LWB010': ["Philips", "Hue Bulb E27"],
Expand Down

0 comments on commit f53a29b

Please sign in to comment.