Xiaomi Cube via Zigbee2mqtt to HA

What is the correct procedure for implementing the Xiaomi cube into Home Assistant via zigbee2mqtt?
I have tried this from the guide https://www.zigbee2mqtt.io/devices/MFKZQ01LM.html
Pairing with z2m is okay.

sensor:
  - platform: "mqtt"
    state_topic: "zigbee2mqtt/xiaomi_cube"
    availability_topic: "zigbee2mqtt/bridge/state"
    value_template: "{{ value_json.action }}"

but i guessed its outdated and tried to change it to:

sensor:
  - platform: "mqtt"
    name: "xiaomi_cube"
    state_topic: "zigbee2mqtt/xiaomi_cube"
    availability_topic: "zigbee2mqtt/bridge/state"
    value_template: "{{ value_json.action }}"
    json_attributes_topic: "zigbee2mqtt/xiaomi_cube"

Anyway nothing happens in HA. State is always “unknown”

In configuration.yaml in z2m I simply have:
‘0x00158d00010b28a2’:
friendly_name: xiaomi_cube

Must something be added?

No one has implemented the Cube in HA from zigbee2mqtt?

I am wondering if you have got this working already, cause I’m currently at the same point where HA is throwing rendering errors like

homeassistant_1  | 2021-04-08 13:18:19 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'action_angle' when rendering '{{ value_json.action_angle }}'
homeassistant_1  | 2021-04-08 13:18:19 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'action_from_side' when rendering '{{ value_json.action_from_side }}'
homeassistant_1  | 2021-04-08 13:18:19 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'action_side' when rendering '{{ value_json.action_side }}'
homeassistant_1  | 2021-04-08 13:18:19 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'action_to_side' when rendering '{{ value_json.action_to_side }}'
homeassistant_1  | 2021-04-08 13:18:19 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'action_angle' when rendering '{{ value_json.action_angle }}'
homeassistant_1  | 2021-04-08 13:18:19 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'action_from_side' when rendering '{{ value_json.action_from_side }}'
homeassistant_1  | 2021-04-08 13:18:19 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'action_side' when rendering '{{ value_json.action_side }}'
homeassistant_1  | 2021-04-08 13:18:19 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'action_to_side' when rendering '{{ value_json.action_to_side }}'

Hi.
Yes it is working and I still use this for integration:

sensor:
  - platform: "mqtt"
    state_topic: "zigbee2mqtt/xiaomi_cube"
    availability_topic: "zigbee2mqtt/bridge/state"
    value_template: "{{ value_json.action }}"

And this as an example for automation:

  - alias: Sonos bio PLAY when Cube FLIP 90
    trigger:
      - platform: mqtt
        topic: 'zigbee2mqtt/xiaomi_cube'
    condition:
      - condition: template
        value_template: '{{ "flip90" == trigger.payload_json.action or "flip180" == trigger.payload_json.action or "tap" == trigger.payload_json.action }}'
    action:
      - service: media_player.volume_set
        data:
          entity_id: media_player.bio
          volume_level: 0.15
      - service: media_player.select_source
        data_template:
          entity_id: media_player.bio
          source: '{{ states.input_select.select_radio_ihc_dag.state }}'
      - service: media_player.media_play
        data:
          entity_id: media_player.bio
1 Like

I have got the same issue with Tuya TRVs. Is anyone experiencing the same?