šŸ§Æ 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.

@duceduc

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.

Klagio

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 %}
with
{% 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:

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

Any advices are welcomed!

Thank you so much again James for all your work!