🧯 Zigbee2MQTT - Xiaomi Cube Controller

According to the error,you are sending it a brightness value not a brightness_pct value. Since different lights have different full brightness values, I used the percent instead because that is always 100% for max.
The simplest change if there is no brightness_pct value in the attributes, just scale the value you send or change the script so it works with your 100% value.


Well look at that link and make sure the legacy stuff is all correct.

Yes, that was it. I had to enable “Home Assistant legacy triggers”. Seemed to have missed that. The other legacy checkbox was ticked though. In the documentation it’s called something else so might be an idea to update that for HA 2022.10.

Thanks for all the help. Looking forward to digging into the features now.

1 Like

I couldn’t find anything in the docs that was different than my installation.

Oopsie! Thankyou for the quick reply :slight_smile:

I am having the same issue that all triggers are failing because of a Template condition failed. Also, the template to report last action is never populating. When I enabled “legacy enitity attributes,” some of my zigbee devices stopped reporting, as did the Cube. After turning it off again, all my devices connect, including the Cube. I can see the payloads in the Zigbee2MQTT logs, and they correctly pass the intended action and traces show that all of the firings fail with a template condition not met.
Argh!!! I’m out of ideas!
I’m on the latest HA, 10.5 and all integrations up to date. I have kept it very simple and used the blueprint UI only to create one action to keep it simple.
Anyone have any ideas? Thanks in advance :slight_smile:

There are other blueprints that function via MQTT straight up. That version might be for you at this point. One of my plans for winter projects is to set these and try to EXACTLY understand what happens when the legacy settings are set one way or another and code around it.

I may change the triggers or I may go to MQTT straight-up myself. I don’t know yet.

On the TODO list.

Cheers, thank for the response! I’ll wait to see what the community comes up with. I may play around with it some as well as time permits. If I find something curious or helpful, I’ll contribute it here :slight_smile:

Thanks again!

Hi is it possible with this blueprint to brighten a light by rotating clockwise and dim counterclockwise? How? Thanks. I see the instruction in post 1, but how to add this??

EDIT I changed the blueprint automation manually, but where to change the script integration?

what am I missing?

I don’t know where you pasted that code. I don’t know if there is typo in it because it is a picture.
i can show you exactly where I have this in my configuration.yaml, maybe that will help you. It goes in the script: integration
It is also possible that the lights you are controlling do not have a brightness control.

In editor

I copy pasted your code

Found the Bug. You are correct, my friend, It seems HA has changed the syntax and data_template: no longer works, needs to be just data:.

The code in message 1 is fixed, but if you just make that change it will work fir you.


November 30, 2022 > Update. Added ZHA Cube Controller version to library.

So Brian and everyone else, St. Nick brings you treats this day. Well, I do, but who’s counting…

I have re-Written the back end of this blueprint to use MQTT Based triggering.

Why you might ask?

Well because there were plenty of people that had their Z2M running in HA Legacy mode which is supposed to be the least favored method (but works great for this). There are others of you that are running Z2M in non-Legacy mode (which looks painful to implement). But everyone has the MQTT Trigger mode available regardless of how you have your triggers set. So rather than excluding anyone, that’s what I used.

As a special bonus, on my system anyway, it responds faster.

As a special treat this blueprint created it’s own number entity to store the last_side variable which the legacy mode did for me before, now I have to do it, but for those of us that are geeks out there you can see how to generate a number entity using MQTT Discovery for your own needs should you need it.

Feel free to ask questions.here. If you found a bug please add it to Github as an issue so I can take care of it.

Please Click the :orange_heart: at the end of the Top Post if you find this Useful

1 Like

I have updated blueprint, but they don’t work. MQTT receives data, but automation does not see them.:face_with_monocle:
Any ideas?

Screenshot 2022-12-06 183946

There are always null triggers.
Z2M usually has a wake-up trigger, then the actual trigger, then a null trigger on every action. (sometimes more…)
That’s why the condition is there to only act on real actions & avoid log spam.
Look thru other triggers and see if the action shows in one of those.

In the second screenshot, I showed that the topic is specified correctly)

There are two errors in the system logs

Logger: homeassistant.components.automation.cube
Source: helpers/script.py:409
Integration: Автоматизация ([documentation](https://www.home-assistant.io/integrations/automation), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+automation%22))
First occurred: 6 декабря 2022 г., 18:10:21 (36 occurrences)
Last logged: 6 декабря 2022 г., 18:37:35

cube: Error executing script. Error rendering template for variables at pos 1: TemplateError: str: Must provide a device or entity ID
Logger: homeassistant.components.automation.cube
Source: components/automation/__init__.py:572
Integration: Автоматизация ([documentation](https://www.home-assistant.io/integrations/automation), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+automation%22))
First occurred: 6 декабря 2022 г., 18:10:21 (36 occurrences)
Last logged: 6 декабря 2022 г., 18:37:35

Error while executing automation automation.cube: TemplateError: str: Must provide a device or entity ID

Just to double check everything, I deleted the copy on my HA instance, I pushed the download blue button in the top post here, installed it, built a tap action, and it worked, no log errors. I need to see your automation if I am to find anything further.

Can you post that to me in a personal message here or on my discord? I will help you troubleshoot further.

Update…Later that Evening…
I found a place where non ASCII characters could effect the friendly name, so I added a filter and I increased the HA rev requirement in case that was causing an issue.
You may want to try it again, maybe I found it. I don’t have a way to know as it works here.

December 11, 2022 > Update. Added Device Tracker Blueprint to the list.

  • 2022-12-12: Add Update Method Note, minor code change.
    • Name of Blueprint may have changed meaing you have to re-download with a new link.
    • If name changed, it is similar. Variables have not changed.

OMG! I just realized that you updated your blueprint! This is wonderful. I’m so grateful to you. It works perfectly.

Thank you so much :slight_smile:

I do have one error, though, in configuring the example you have of rotate for dimmer control. I haven’t spent much time digging into it. I get this error in the logs when the action is triggered:

2022-12-19 15:40:41.036 ERROR (MainThread) [homeassistant.components.script.cube_dimmer_control] cube_dimmer_control: Error executing script. Error for call_service at pos 1: Error rendering data template: TypeError: can’t multiply sequence by non-int of type ‘float’

I assume this refers to the variable: angle. I tried replacing
{% set step_size = angle * 0.4 %}
{% set step_size = (float(angle)) * 0.4 %}
which also failed – I’m sure I have the syntax wrong. Maybe the value isn’t being passed correctly, however?
EDIT: I changed the line to:
{% set step_size = float(angle) * 0.4 %}
and got this error:
2022-12-19 23:16:26.407 ERROR (MainThread) [homeassistant.components.script.cube_dimmer_control] cube_dimmer_control: Error executing script. Error for call_service at pos 1: Error rendering data template: ValueError: Template error: float got invalid input ‘’ when rendering template '{% set step_size = float(angle) * 0.4 %}

So, it looks as if the value of ‘angle’ isn’t being passed at all from the template in the automation:

      - service: script.cube_dimmer_control
          angle: '{{ trigger.payload_json.angle }}'
          light: light.office_inside

Any advices are welcomed!

Thank you so much again James for all your work!