šŸ§Æ Zigbee2MQTT - Xiaomi Cube Controller

First, thank you for this blueprint, Iā€™m just starting with zigbee and Iā€™ve learned a lot from this (also saves a lot of work :+1:). I was having trouble with the number.last_side entity not working, then realized it was turning unavailable after some minutes, in the end it was because for some reason my mqtt broker was sending the LWM for homeassistant/status topic, and HA was recording mqtt client disconnected in the logs, the issue fixed itself after updating HA to the latest version.

Anyway, all that to say I was analyzing the blueprint and noticed that the last_side entity is not using the action_from_side data reported when flip90 action is triggered, this creates a scenario when, if you lift the cube and change sides then flip 90Āŗ from and to specific sides (group 3 actions) will not trigger because there was no action to sync the last side entity.

So I added an extra condition in the last_side variable:

last_side: >
    {# Check if there is action_from_side data and use that first.#}
    {% if trigger.payload_json.action_from_side is number %}
      {{ trigger.payload_json.action_from_side | int(0) }}
    {# The first time it will not be there, so make sure its 0 instead of undefined. #}
    {% elif not num_ha_val in ["undefined", "unknown", "unavailable", "none", "null", ""] %}
      {{ num_ha_val }}
    {% else %}
      0
    {% endif %}

With this the flip90 actions are more reliable.

Also, the slide action for side 3 is in the wrong group.

Did you do a pull request on github? Iā€™ll go look at it so I know what you are saying exactly.

Iā€™m not very used to git yet but I made the pull request to ease things up.

1 Like

Woah, just got my old cube and ā€¦ found this. Thanks!

1 Like
Logger: homeassistant.helpers.template
Source: helpers/template.py:2742
First occurred: 15:36:08 (13 occurrences)
Last logged: 16:12:46

Template variable warning: list object has no element 1 when rendering '{{ieee_id_long.split('_')[1] }}'

Could this be fixed? Please.

Hi Routout,

The error is complaining about the device name. Verify you have the device properly configured as a ZHA device.

I donā€™t have any other reports of an issue with this one and have not changed anything for months.

Hi! Itā€™s z2m device. This warning have been in the logs for ages. I just updated the script, deleted old automation and pasted old yaml in the configuration and this still pops up.

OK, if you would please write an issue for it. I need to dig in and make all the YAML changes to current non legacy, so will look at it then.

I donā€™t see it in my log, so give me info about your device and related so I can track it. It may be a problem with how you have named the device or something, donā€™t know.
Iā€™ll be contacting you when I work on it.

1 Like

Z2M version 2.x has dropped. This means if you install that, you will need to make a change to your configuration in order to use :fire_extinguisher: Zigbee2MQTT - Xiaomi Cube Controller.

I have not yet made changes to accommodate for the update, and my changes are going to be likely using the Home Assistant experimental event entities.

So to accommodate the change, I will be asking you to change 2 buttons in the Z2M :gear: set-up screen in the User Interface (UI) screen.

Please click both these:

Home Assistant legacy action sensors So that it will work now until I update this and

Home Assistant experimental event entities for later so it works after I update this.

Also leave Enabled checked as well. It should look similar to that photo when you are done.

Sorry for any inconvenience this is causing you. I wanted the dust to settle a bit so that I could see the final version of the change before I updated my stuff. In the end I think this is a positive change and will make programming these devices a lot easier for everyone.

1 Like

I can not get it to work - it registers the _action, but the initial check for a change in state yields a ā€œfalseā€, and as such it never proceeds beyond this ANDā€¦

Any thoughts???

It started working again after I put this line in the /config/zigbee2mqtt/configuration yaml, somewhere in the ā€œadvanced:ā€ block.

homeassistant_legacy_entity_attributes: true

Hello Jos, Tony P,

So, did you read the post directly above?
I have not edited these yet, and when I do it will likely use the event type triggers, so click botn the empty boxes like the post suggests.

Sorry Jos, just noticed these were 2 posters not just 1. Thanks for helping out.

Yes I read your post and clicked the both checkmark boxes but still had the same problem as @toppot. After I added the mentioned line about the legacy_entity_attributes, your (marvelous) template started working again. If I put this parameter on false again, the first step in the automation always result in a ā€œfalseā€.

I found this parameter Here. I first put all the parameters to ā€œtrueā€, so everything was working again and then set the parameter one by one to false again until the automation stopped working :slight_smile:

This is the relevant part of my current configuration.yaml

homeassistant:
  enabled: true
  experimental_event_entities: true
  legacy_action_sensor: true

and

advanced:
# ----
  homeassistant_legacy_entity_attributes: true
  homeassistant_legacy_triggers: false
  legacy_api: false
  legacy_availability_payload: false
# ---
  log_level: info

This is good info, thanks. Are you using a docker to host Z2M?

Because on mine, I seemed to only have to change the parameter I showed above in the UI to make mine work. I didnā€™t change the Add-on Configuration.yaml.
However if this works, it is indeed a good way to go.

Thanks again for contributing this.

I use the official HA add-on (and yes thatā€™s a docker container). Iā€™m using HA on HA-OS.

Same, but I think when you change the button in the UI, thatā€™s all you need. I didnā€™t have to change the config and there is no legacy attributes button in the UI that I changed anyway. Yes that condition is a legacy attribute.

I actually didnā€™t have any of these 4 legacy parameters in my config (nice find @jsuanet ) - and did set both the checkmarks in the UIā€¦

So probably a good idea to make this info/resolution part of the "how to get it fixed " post - and make it sticky :sunglasses:

(Running HA-OS virtualized in a HA (High Availability) environmentā€¦ thus with a LAN Zigbee adapterā€¦ and Z2M via the official repoā€¦)

After the conversation of yesterday I removed the extra parameters in the zigbee2mqtt, keep the two checkboxes checked and restarted HA and magically the template works, just as you described in your original post. The only thing what differs from my first attempt is the version number of the zigbee2mqqt add-on, this is now 2.0.0-2, but based on the information in the changelog I canā€™t explain the different behavior. But nevermind it is working :slight_smile:

And I did what you described, and mine still doesnā€™t workā€¦ Perhaps I should debug a bit whatā€™s going onā€¦ :man_shrugging:t3: