šŸ§Æ Zigbee2MQTT - Xiaomi Cube Controller

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!

Hmm.
Iā€™ll have to see what I have different on mineā€¦

OK. I have left legacy stuff on. When I look at MQTT-explorer the topic zigbee2mqtt/yertle (which is the cube name and is the topic Iā€™m using to grab the changes) has the angle as an attribute. I see it, mine is working.

Screenshot_20221220_054204

What are you seeing?
What topic are you using?
If you are using the equiv of zigbee2mqtt/yertle/action, that wonā€™t work.

Screenshot_20221220_054626

This is the script Iā€™m usingā€¦

I have turned on all Legacy settings:
image
image

It seems that Iā€™m not getting the ā€œangleā€ payload piece. I get the action_angle though:

image

I am using the cube name (Cube1) as the topic:

And again, it looks like ā€œangleā€ isnā€™t included in the payload as it is in yours.

Maybe I could use ā€œaction_angleā€ as the input?

EDIT: Sure enough, "changing the code to use ā€˜{{ trigger.payload_json.action_angle }}ā€™ has it working as expected. :man_shrugging:

Iā€™m having the same exact issue.

This is my automation from the blueprint: dpaste/XtSiD (YAML)

home assistant log errors: Imgur: The magic of the Internet

I looked in mqtt explorer and see the mqtt messages showing it working for shake, tap etc. I also see the home assistant actions showing the expected actions. Thereā€™s some issue with the blueprint that home assistant doesnā€™t like and throws those errors in the log.

I just tried the shake action to control an area with light.toggle like you didā€¦ it works for me OK

      shake:
      - service: light.toggle
        data: {}
        target:
          area_id: office

The only difference I see from your example is my area is using a friendly name, and my Cube name contains no spaces.

For light.toggle, entity_id is a required parameterā€¦

I donā€™t see where it talks about area toggles. But if it worked with a name, I would go with that.

Whatā€™s your cube model or firmware and version / type of Z2M. If I need to change it I can, trying to figure out exactly why, however. I also have action_angle, but was weird about using it because it goes to null sometimes. Maybe itā€™s right when it needs to be, but that would need to be tested.

My cube reports as: MFKZQ01LM
Iā€™m not sure how to extract the firmware version.
Z2M running in HASS, directly installed on Raspberry Pi with Sonoff 3.0 USB dongle:

image

I changed this specific setting in Z2M settings for the cube (it was un-set before):
image

And suddenly, I get this:

image

Success! I guess I should leave all the other Legacy things enabled as well? Everything seems to work with my other Zigbee devices.

1 Like

I deleted everything and started fresh and changed the name in z2m to one with no spaces and it all works. Thanks for the help and man what a great blueprint I really appreciate it!

1 Like