Hi, your doing nothing wrong. This is how these sensors work. You probably expect a state like viberate
, tilt
or free-fall
, but the state will keep off
. The good news is that this sensor has an attribute called last_action
that return the state.
To follow the behavior of Xiaomi sensors, you can turn on logging by adding this to your configuration.yaml
:
logger:
default: info
logs:
xiaomi_gateway: debug
homeassistant.components.xiaomi_aqara: debug
homeassistant.components.switch.xiaomi_aqara: debug
homeassistant.components.sensor.xiaomi_aqara: debug
homeassistant.components.binary_sensor.xiaomi_aqara: debug
In that case you will see something like this in the logging:
DEBUG (Thread-4) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'vibration', 'sid': '158d0002b83c5b', 'short_id': 50317, 'data': '{"status":"vibrate"}'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Vibration_158d0002b83c5b: off>: {'status': 'vibrate'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Bed Activity_158d0002b83c5b: None>: {'status': 'vibrate'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Tilt Angle_158d0002b83c5b: None>: {'status': 'vibrate'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Coordination_158d0002b83c5b: None>: {'status': 'vibrate'}
DEBUG (Thread-4) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'vibration', 'sid': '158d0002b83c5b', 'short_id': 50317, 'data': '{"bed_activity":"202"}'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Vibration_158d0002b83c5b: off>: {'bed_activity': '202'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Bed Activity_158d0002b83c5b: None>: {'bed_activity': '202'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Tilt Angle_158d0002b83c5b: None>: {'bed_activity': '202'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Coordination_158d0002b83c5b: None>: {'bed_activity': '202'}
DEBUG (Thread-4) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'vibration', 'sid': '158d0002b83c5b', 'short_id': 50317, 'data': '{"status":"tilt"}'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Vibration_158d0002b83c5b: off>: {'status': 'tilt'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Bed Activity_158d0002b83c5b: 202.0>: {'status': 'tilt'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Tilt Angle_158d0002b83c5b: None>: {'status': 'tilt'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Coordination_158d0002b83c5b: None>: {'status': 'tilt'}
DEBUG (Thread-4) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'vibration', 'sid': '158d0002b83c5b', 'short_id': 50317, 'data': '{"final_tilt_angle":"16"}'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Vibration_158d0002b83c5b: off>: {'final_tilt_angle': '16'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Bed Activity_158d0002b83c5b: 202.0>: {'final_tilt_angle': '16'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Tilt Angle_158d0002b83c5b: None>: {'final_tilt_angle': '16'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Coordination_158d0002b83c5b: None>: {'final_tilt_angle': '16'}
DEBUG (Thread-4) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'vibration', 'sid': '158d0002b83c5b', 'short_id': 50317, 'data': '{"status":"free_fall"}'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Vibration_158d0002b83c5b: off>: {'status': 'free_fall'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Bed Activity_158d0002b83c5b: 202.0>: {'status': 'free_fall'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Tilt Angle_158d0002b83c5b: 16.0>: {'status': 'free_fall'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Coordination_158d0002b83c5b: None>: {'status': 'free_fall'}
DEBUG (Thread-4) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'vibration', 'sid': '158d0002b83c5b', 'short_id': 50317, 'data': '{"coordination":"-53,-207,1114"}'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Vibration_158d0002b83c5b: off>: {'coordination': '-53,-207,1114'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Bed Activity_158d0002b83c5b: 202.0>: {'coordination': '-53,-207,1114'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Tilt Angle_158d0002b83c5b: 16.0>: {'coordination': '-53,-207,1114'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Coordination_158d0002b83c5b: None>: {'coordination': '-53,-207,1114'}
If you want to make an automation you can trigger it on the following movement_types
: tilt
, free_fall
or
vibrate
. This one will trigger a notification:
automation:
- alias: create notification upon vibrate sensor
trigger:
platform: event
event_type: xiaomi_aqara.movement
event_data:
entity_id: binary_sensor.vibration_158d0002b83c5b
movement_type: vibrate
action:
service: persistent_notification.create
data_template:
message: '{{now().strftime("%Y-%m-%d %H:%M:%S")}}: vibrate'
If you want a sensor that returns the last_action
, you can try this:
sensor:
platform: template
sensors:
viberate_158d0002b83c5b:
friendly_name: vibrate_sensor_action
value_template: '{{ states.binary_sensor.vibration_158d0002b83c5b.attributes["last_action"] }}'
I hope this makes it clear.