Device support for different new sensors of the xiaomi aqara gateway (#8577)
* The gateway configuration accepts a MAC address or a SID value in uppercase already. The ringtone services accepts the same values now. I hope it will avoid confusion. * Device support for the new wall switches with neutral lead (ctrl_ln1, ctrl_ln2) added. * Measurement unit from pressure of weather.v1 fixed. * Device support for sensor_magnet.aq2 added. * Device support for sensor_motion.aq2 (motion and lux) added. * Code reformatted. * The ringtone service (start/stop) uses the parameter gw_mac instead of gw_sid now. * Version of the required library updated.
This commit is contained in:
1 parent
f6a5e0887d
commit
fada6d3f49
4 files changed
+33
-9
No files matched your search
@@ -17,13 +17,16 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
'temperature', gateway))
|
||||
devices.append(XiaomiSensor(device, 'Humidity',
|
||||
'humidity', gateway))
|
||||
if device['model'] == 'weather.v1':
|
||||
elif device['model'] == 'weather.v1':
|
||||
devices.append(XiaomiSensor(device, 'Temperature',
|
||||
'temperature', gateway))
|
||||
devices.append(XiaomiSensor(device, 'Humidity',
|
||||
'humidity', gateway))
|
||||
devices.append(XiaomiSensor(device, 'Pressure',
|
||||
'pressure', gateway))
|
||||
elif device['model'] == 'sensor_motion.aq2':
|
||||
devices.append(XiaomiSensor(device, 'Illumination',
|
||||
'lux', gateway))
|
||||
elif device['model'] == 'gateway':
|
||||
devices.append(XiaomiSensor(device, 'Illumination',
|
||||
'illumination', gateway))
|
||||
@@ -47,6 +50,8 @@ class XiaomiSensor(XiaomiDevice):
|
||||
return '%'
|
||||
elif self._data_key == 'illumination':
|
||||
return 'lm'
|
||||
elif self._data_key == 'lux':
|
||||
return 'lx'
|
||||
elif self._data_key == 'pressure':
|
||||
return 'hPa'
|
||||
|
||||
@@ -69,7 +74,7 @@ class XiaomiSensor(XiaomiDevice):
|
||||
return False
|
||||
elif self._data_key == 'pressure' and value == 0:
|
||||
return False
|
||||
if self._data_key in ['temperature', 'humidity']:
|
||||
if self._data_key in ['temperature', 'humidity', 'pressure']:
|
||||
value /= 100
|
||||
elif self._data_key in ['illumination']:
|
||||
value = max(value - 300, 0)
|
||||
|
||||
Reference in new issue
Block a user