Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
528988a
UNIT and ID type changes
dlashua Dec 12, 2016
186984c
make unit a positive int
dlashua Dec 13, 2016
6acfd50
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
dlashua Sep 4, 2018
3d5690b
Support Xiaomi Vibration Sensor
dlashua Sep 4, 2018
9e36434
adding whitespace before comma
dlashua Sep 4, 2018
34b8c65
adding whitespace before comma
dlashua Sep 4, 2018
c435400
remove trailing whitespace
dlashua Sep 4, 2018
34c40eb
removed warning for unknown models
dlashua Sep 4, 2018
3b00151
readded warning so that only device output is removed
dlashua Sep 4, 2018
ad15cec
readding warning for unmapped device model
dlashua Sep 4, 2018
52b7906
used warning instead of warn
dlashua Sep 4, 2018
b0bd32a
double check that value doesn't match one of the expected values
dlashua Sep 5, 2018
e729548
Added unsupported model name to warning message
dlashua Sep 5, 2018
4183648
Don't pass in "hass" to XiaomiVibration.
dlashua Sep 5, 2018
f6933d0
be consistent with tabs and spaces
dlashua Sep 5, 2018
556bf3f
line too long for houndci-bot
dlashua Sep 5, 2018
9842eb2
clean up trailing whitespace
dlashua Sep 5, 2018
9365357
making additional changes requested.
dlashua Sep 5, 2018
e0d02a3
add more spacing to make houndci-bot happy
dlashua Sep 5, 2018
106040b
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
dlashua Sep 6, 2018
f7160b6
Merge branch 'dev' into xiaomiVibration
dlashua Sep 6, 2018
cc71ce1
Add additional model name
syssi Oct 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions homeassistant/components/binary_sensor/xiaomi_aqara.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
'dual_channel', hass, gateway))
elif model in ['cube', 'sensor_cube', 'sensor_cube.aqgl01']:
devices.append(XiaomiCube(device, hass, gateway))
elif model in ['vibration', 'vibration.aq1']:
devices.append(XiaomiVibration(device, 'Vibration',
'status', gateway))
else:
_LOGGER.warning('Unmapped Device Model %s', model)

add_entities(devices)


Expand Down Expand Up @@ -311,6 +317,38 @@ def parse_data(self, data, raw_data):
return False


class XiaomiVibration(XiaomiBinarySensor):
"""Representation of a Xiaomi Vibration Sensor."""

def __init__(self, device, name, data_key, xiaomi_hub):
"""Initialize the XiaomiVibration."""
self._last_action = None
super().__init__(device, name, xiaomi_hub, data_key, None)

@property
def device_state_attributes(self):
"""Return the state attributes."""
attrs = {ATTR_LAST_ACTION: self._last_action}
attrs.update(super().device_state_attributes)
return attrs

def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
value = data.get(self._data_key)
if value not in ('vibrate', 'tilt', 'free_fall'):
_LOGGER.warning("Unsupported movement_type detected: %s",
value)
return False

self.hass.bus.fire('xiaomi_aqara.movement', {
'entity_id': self.entity_id,
'movement_type': value
})
self._last_action = value

return True


class XiaomiButton(XiaomiBinarySensor):
"""Representation of a Xiaomi Button."""

Expand Down
12 changes: 12 additions & 0 deletions homeassistant/components/sensor/xiaomi_aqara.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
elif device['model'] in ['gateway', 'gateway.v3', 'acpartner.v3']:
devices.append(XiaomiSensor(device, 'Illumination',
'illumination', gateway))
elif device['model'] in ['vibration']:
devices.append(XiaomiSensor(device, 'Bed Activity',
'bed_activity', gateway))
devices.append(XiaomiSensor(device, 'Tilt Angle',
'final_tilt_angle', gateway))
devices.append(XiaomiSensor(device, 'Coordination',
'coordination', gateway))
else:
_LOGGER.warning("Unmapped Device Model ")
add_entities(devices)


Expand Down Expand Up @@ -84,6 +93,9 @@ def parse_data(self, data, raw_data):
value = data.get(self._data_key)
if value is None:
return False
if self._data_key in ['coordination', 'status']:
self._state = value
return True
value = float(value)
if self._data_key in ['temperature', 'humidity', 'pressure']:
value /= 100
Expand Down