pplucky
(Pplucky)
July 16, 2017, 10:17pm
2227
What I did to understand what event is being triggerred, was to create a new MQTT sensor and then add an automation for each possible event to publish it to the MQTT which is shown on the frontend.
sensor:
- platform: mqtt
state_topic: "xiaomi_cube_state"
name: "Cube State"
automation:
- alias: 'Flip 90'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_xxxxxxxxxxxxxx
action_type: flip90
action:
- service: mqtt.publish
data:
topic: "xiaomi_cube_state"
payload: "Flip 90"
retain: "True"
- alias: 'Flip 180'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_xxxxxxxxxxxxxx
action_type: flip180
action:
- service: mqtt.publish
data:
topic: "xiaomi_cube_state"
payload: "Flip 180"
retain: "True"
- alias: 'Move'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_xxxxxxxxxxxxxx
action_type: move
action:
- service: mqtt.publish
data:
topic: "xiaomi_cube_state"
payload: "Move"
retain: "True"
- alias: 'Tap Twice'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_xxxxxxxxxxxxxx
action_type: tap_twice
action:
- service: mqtt.publish
data:
topic: "xiaomi_cube_state"
payload: "Tap Twice"
retain: "True"
- alias: 'Shake Air'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_xxxxxxxxxxxxxx
action_type: shake_air
action:
- service: mqtt.publish
data:
topic: "xiaomi_cube_state"
payload: "Shake Air"
retain: "True"
- alias: 'Swing'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_xxxxxxxxxxxxxx
action_type: swing
action:
- service: mqtt.publish
data:
topic: "xiaomi_cube_state"
payload: "Swing"
retain: "True"
- alias: 'Alert'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_xxxxxxxxxxxxxx
action_type: alert
action:
- service: mqtt.publish
data:
topic: "xiaomi_cube_state"
payload: "Alert"
retain: "True"
- alias: 'Free Fall'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_xxxxxxxxxxxxxx
action_type: free_fall
action:
- service: mqtt.publish
data:
topic: "xiaomi_cube_state"
payload: "Free Fall"
retain: "True"
- alias: 'Rotate'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_xxxxxxxxxxxxxx
action_type: rotate
action:
- service: mqtt.publish
data:
topic: "xiaomi_cube_state"
payload: "Rotate"
retain: "True"
In your frontend, it shows something like this:
Has anyone played around and can explain what is the alert and swing? Alert is shown sometimes, but I never got swing to appear.
Xiaomi only explains 6/9 functions identified in HA (and in Mi Home app only these 6 appear logged):
Can anyone share any more insights?
1 Like
syssi
July 17, 2017, 6:56am
2228
The alert event is something like an earth quake. If I put the cube on a table and put my cup of coffee next to the cube the event appears.
1 Like
mihalski
(Michal Dobrzynski)
July 17, 2017, 7:37am
2229
The luminosity sensor in the gateway was just updated in the component. Adjusted to be from 0-1000 instead of 300-1300.
Also, I recommend not swinging the cube down and then suddenly stopping at night or a VERY loud Chinese woman will start screaming and scare/wake the household.
According to Google Translate she says “Everything is normal”.
mihalski
(Michal Dobrzynski)
July 17, 2017, 8:09am
2230
Has anyone noticed that there is a firmware update?
Or am I just late to the party?
1 Like
pplucky
(Pplucky)
July 17, 2017, 8:20am
2231
I had not noticed yet, but maybe this includes the API for the new Aqara sensors…
emontes
(E Montes)
July 17, 2017, 8:25am
2232
I checked yesterday and there was nothing, nice
Let’s see if the new sensors are supported now.
Can confirm new update available to download and install
emontes
(E Montes)
July 17, 2017, 8:31am
2234
The temperature sensor and the switch are showing up:
2017-07-17 09:28:55 DEBUG (Thread-11) [custom_components.xiaomi] << {‘model’: ‘weather.v1’, ‘sid’: ‘158d0001a21e25’, ‘cmd’: ‘read_ack’, ‘data’: ‘{“voltage”:3035,“temperature”:“2486”,“humidity”:“5110”,“pressure”:“0”}’, ‘short_id’: 53066}
2017-07-17 09:28:55 ERROR (Thread-11) [custom_components.xiaomi] Unsupported devices : weather.v1
2017-07-17 09:28:55 DEBUG (Thread-11) [custom_components.xiaomi] >> b’{“cmd”:“read”,“sid”:“158d0001a67341”}’
2017-07-17 09:28:55 DEBUG (Thread-11) [custom_components.xiaomi] << {‘model’: ‘sensor_switch.aq2’, ‘sid’: ‘158d0001a67341’, ‘cmd’: ‘read_ack’, ‘data’: ‘{“voltage”:3115}’, ‘short_id’: 41894}
2017-07-17 09:28:55 ERROR (Thread-11) [custom_components.xiaomi] Unsupported devices : sensor_switch.aq2
2017-07-17 09:28:55 DEBUG (Thread-11) [custom_components.xiaomi] << {‘model’: ‘weather.v1’, ‘sid’: ‘158d0001a21e25’, ‘cmd’: ‘read_ack’, ‘data’: ‘{“voltage”:3035,“temperature”:“2486”,“humidity”:“5110”,“pressure”:“0”}’, ‘short_id’: 53066}
Just need support now.
2 Likes
mihalski
(Michal Dobrzynski)
July 17, 2017, 8:46am
2235
I have 3 Square square switches. One was added before the update… It’s in English… The other two were just added now and appear in Chinese
Also… This looks promising:
2017-07-17 18:45:26 DEBUG (Thread-25) [custom_components.xiaomi] MCAST (report) << {'cmd': 'report', 'model': 'sensor_switch.aq2', 'sid': '158d000123df04', 'short_id': 11905, 'data': '{"status":"click"}'}
1 Like
emontes
(E Montes)
July 17, 2017, 8:54am
2236
mihalski:
ents.xiaomi] MCAST (report) << {‘cmd’: ‘report’, ‘model’: ‘sensor_switch.aq2’, ‘sid’: ‘158d000123df04’, ‘short_id’: 11905, ‘data’: ‘{“status”:“click”}’}
It’s funny, I added mine before the upgrade and it doesn’t show up on my list on the Mii home app but looks like it has been added to the gateway as it shows up as unsupported on the HA logs.
syssi
July 17, 2017, 8:57am
2237
Yeay! I have added the device support for sensor_switch.aq2 and weather.v1.
https://github.com/Danielhiversen/homeassistant/pull/22
2 Likes
emontes
(E Montes)
July 17, 2017, 8:58am
2238
Nice one, syssi, thanks a lot!
syssi
July 17, 2017, 8:59am
2239
Can you do me a favour? Please push the button three and four times and post the associated events. Thanks!
@mihalski I also have the new square switch here is the corresponding clicks
Single
{"cmd":"report","model":"sensor_switch.aq2","sid":"158d000124xxxx","short_id":5872,"data":"{\"status\":\"click\"}"}
Double
{"cmd":"report","model":"sensor_switch.aq2","sid":"158d000124xxxx","short_id":5872,"data":"{\"status\":\"double_click\"}"}
Looks like it only supports double and single clicks. Tried long press and I did not get a response.
1 Like
emontes
(E Montes)
July 17, 2017, 9:08am
2241
And the pair button as well:
2017-07-17 10:08:48 DEBUG (Thread-14) [custom_components.xiaomi] MCAST (report) << {‘sid’: ‘158d0001a67341’, ‘data’: ‘{“status”:“iam”}’, ‘cmd’: ‘report’, ‘short_id’: 20401, ‘model’: ‘sensor_switch.aq2’}
2017-07-17 10:08:48 DEBUG (Thread-14) [custom_components.xiaomi] MCAST (heartbeat) << {‘sid’: ‘158d0001a67341’, ‘data’: ‘{“voltage”:3115}’, ‘cmd’: ‘heartbeat’, ‘short_id’: 20401, ‘model’: ‘sensor_switch.aq2’}
mihalski
(Michal Dobrzynski)
July 17, 2017, 9:17am
2242
I seem to be getting:
2017-07-17 19:04:24 ERROR (SyncWorker_19) [custom_components.xiaomi] Unsupported devices : sensor_switch.aq2
2017-07-17 19:04:24 ERROR (SyncWorker_19) [custom_components.xiaomi] Unsupported devices : sensor_switch.aq2
2017-07-17 19:04:24 ERROR (SyncWorker_19) [custom_components.xiaomi] Unsupported devices : sensor_switch.aq2
Trying to work out if I messed up somehow with the installation of the updated files.
Check out Daniels GitHub and add the pull request. I have tested it and the square switch now works in home assistant. I love how quick this community is at getting new functions to work.
https://github.com/Danielhiversen/homeassistant/pull/22/files
mihalski
(Michal Dobrzynski)
July 17, 2017, 9:35am
2244
OK. Fixed.
But how do I get debug info for ONLY the xiaomi component? I just tried:
logger:
default: error
logs:
custom_components.xiaomi: debug
But it didn’t work.
mihalski
(Michal Dobrzynski)
July 17, 2017, 9:38am
2245
I’ve got the buttons showing up but they don’t respond to a hold (i.e. should turn on when held).
Also I noticed that if you hold for a LONG time the light starts to flash… Don’t know if that’s an additional event.
mihalski
(Michal Dobrzynski)
July 17, 2017, 10:03am
2246
OK… For some reason after I restarted after configuring the devices with names and all the logging worked (without me having changed it).
Triple click usually shows as double click:
2017-07-17 19:59:11 DEBUG (Thread-3) [custom_components.xiaomi] MCAST (report) << {'cmd': 'report', 'model': 'sensor_switch.aq2', 'sid': '158d000123def4', 'short_id': 1737, 'data': '{"status":"double_click"}'}
2017-07-17 19:59:11 DEBUG (SyncWorker_12) [custom_components.xiaomi] PUSH >> <Entity Switch_158d000123def4: off>: {'status': 'double_click'}
And so does quadruple click:
2017-07-17 19:59:51 DEBUG (Thread-3) [custom_components.xiaomi] MCAST (report) << {'cmd': 'report', 'model': 'sensor_switch.aq2', 'sid': '158d000123def4', 'short_id': 1737, 'data': '{"status":"double_click"}'}
2017-07-17 19:59:51 DEBUG (SyncWorker_15) [custom_components.xiaomi] PUSH >> <Entity Switch_158d000123def4: off>: {'status': 'double_click'}
Also hold comes across as a click:
2017-07-17 20:02:17 DEBUG (Thread-3) [custom_components.xiaomi] MCAST (report) << {'cmd': 'report', 'model': 'sensor_switch.aq2', 'sid': '158d000123def4', 'short_id': 1737, 'data': '{"status":"click"}'}
2017-07-17 20:02:17 DEBUG (SyncWorker_10) [custom_components.xiaomi] PUSH >> <Entity Switch_158d000123def4: off>: {'status': 'click'}
So these seem to be WORSE feature wise than the old round buttons. Unless this is something that a firmware update will fix.