Hi for my first time to use blueprint I have choice your project for dimmer a lightbulb.
I have imported the blueprint and installed it.
Modified the row 65 inserting the name of the light that I want manage (light.mylbulbname)
I have create this automation
I donāt have a lot to go on.
You are putting it in an automation not in my blueprint which is fine, it will still work if set correct.
The trigger must provide the angle in the form you are looking for it. You are triggering this automation from an MQTT event which does not contain the angle data. Iām guessing your problem starts there.
I am guessing you are running Z2M (because of the MQTT Trigger). Whatever you are using, the trigger you select for this dimmer blueprint has to contain the angle data for you to be able to use this blueprint to change the brightness.
I donāt want to assume anything, but the answers above also require that you loaded the dimmer blueprint and ran it to set up the script to call that you named (script.dimmer_control_4_magic_cube_and_other_things_2023_04_23).
or you have loaded the sample in the instructions into your scripts library using that name.
Like I said, you didnāt give me much to go on, so lots of guesses there. If you can tell me more about your use case, I can help you more.
Also tell me your goal here, as then helps guide the discussion.
Sorry for the missing info but Iām not an expert.
My final goal is to pilot as many lights as there are faces of the cube. turning the cube on a face I would like to dwell the corresponding light.
I try to summarize all the steps I followed from the link https://community.home-assistant.io/t/zigbee2mqtt-xiaomi-cube-controller/393203.
I downloaded the blueprint indicated in the section āDimmer Controlā
I also downloaded the script
In the script.yaml file I inserted the following code:
dimmer_control_4_magic_cube_and_other_things_2023_04_23:
alias: dimmer_control_4_magic_cube_seminterrato
use_blueprint:
path: SirGoodenough/dimmer_control_4_magic_cube.yaml
icon: mdi:cube
mode: single
into the file SirGoodenough/dimmer_control_4_magic_cube.yaml I entered the name of the light I want to fly.
blueprint:
name: dimmer_control_4_magic_cube_and_other_things - 2023-04-23
author: SirGoodenough
domain: script
homeassistant:
min_version: 2023.3.0
source_url: https://github.com/SirGoodenough/HA_Blueprints/blob/615c6d6062dd1e7e5238d15078be7d18373d15ba/Scripts/dimmer_control_4_magic_cube.yaml
description: "This script was invented to be used with my Magic Cube Blueprints.
I released it as a standalone Script Blueprint because I saw others struggling
with how so convert cube rotation to light dimming in other places.\n\nTo use
this blueprint, install it from the source in the normal way. After that add your
unique name for the Script, and add an icon and change the entity_id if desired.
You should only need to run the blueprint once, as you will be calling the unique
name/entity you added above to use the code. This script has no inputs in the
Blueprint screen because all the data is added to control the action live at each
use.\n\nThis requires you call this script wth 2 data values. One is a positive
or negative number between 360 and -360 that in the original, represents the input
angle from the cube movement. The other data point is the entity of the light
or light group that you are trying to control.\n***NOTE:*** the trigger variable
below will be different for Z2M and ZHA and others. Look at my documentation for
that cube integration help if you need it.\nSample call / use of this script:\n
\ yaml\n - service: script.cube_dimmer_control\n data:\n angle: '{{
trigger.event.data.args.relative_degrees | float(0.0)}}'\n light: light.bulb1\n
\ \n"
input:
sensi:
name: Sensitivity of the cube rotational motion.
description: ' This sets how ''fast'' the changes happen compared to how far
you move the cube. Higher percentage is faster, lower is slower.
I have found that 40% is a good number, but you can adjust as desired. '
default: 40
selector:
number:
min: 1.0
max: 200.0
step: 1.0
mode: box
min_b:
name: Minimum Brighness
description: ' This sets the lowest brightness it will set before it turns off.
Some bulbs react poorly below a certain percent, you can adjust that here.
I have found that 10% is a good number, but you can adjust as desired. '
default: 10
selector:
number:
min: 5.0
max: 90.0
step: 1.0
mode: slider
fields:
angle:
name: Angle to represent new brightness
description: ' This is the new angle to be used in the calculation for Brightness'
required: true
example: '-120.7'
selector:
number:
min: -360
max: 360
step: 0.1
mode: box
light:
name: light.faretto1_studio
description: Add the light entity you want to control here
required: true
example: light.faretto1_studio
selector:
entity:
multiple: false
domain: light
variables:
sensi_var: !input sensi
sens_d: '{{ sensi_var / 100 | default( 0.4 ) }}'
min_b_var: !input min_b
sequence:
- service: light.turn_on
data:
entity_id: '{{ light }}'
brightness_pct: "{% set step_size = angle * sens_d %} {# Get brightness as a percent.
#} {% set cb = (state_attr( light, 'brightness') | float(10) / 255.0) * 100.0
%} {% set new_brightness = cb | int(10) + step_size %} {% if new_brightness
< 5 %}\n {# If it gets really low set to 0. Adjust if needed for your lights.
#}\n 0\n{% elif new_brightness <= min_b_var %}\n {# If it's not quite 0, set
to a minimum working brightness. #}\n {{ min_b_var }}\n{% elif 91 <= new_brightness
< (90 + step_size) %}\n {# If it's almost full brightness, set to 100%. #}\n
\ 100\n{% else %}\n {# Send actual calculated value. #}\n {{ new_brightness
}}\n{% endif %}"
icon: mdi:lightbulb-on-50
mode: queued
max: 10
I created the automation I sent you above but the light is not dimmed.
Got it.
You have a couple of issues with the code you posted first. That appears to be an automation, you need a script.
If you install this blueprint (itās a helper blueprint used to easily create the dimmer function sscript for you):
and then use that to generate a script it will create a dimmer script for you. Then in the cube control for the action and the side you desire, add the code that is in the description for Z2M to call the script, making sure the script names match as well. Then it should work. You can look in my config if you like for an example.
If I import your new blueprint it doesnāt keep me going because it says it exists.
I try to delete the blueprint that the existing script and reimport it all over again.
cross fingers
Ok Iāve imported the blueprint and generated the script. Now I must add to de script created the code to manage the cube using the z2m command indicated on description of blueprint? I have understood better?
I have write-up directions to help you with examples. I provide my config which is a working example. At some point you will need to adjust and fix this on your own, so you will need to learn how to do this. I am not there to see your config so I cannot advise you on HA general stuff or do it for you.
Just try it and work with it. If things get out of hand and blow up you have your offline backup to restore everything, right?
Does this still work in 2023.10? I have used this, but now suddenly seems that it doesnāt launch my script anymore when cube is shaked. I can see from zigbee2mqtt logs that shake topic appears, and the script itself working when launched manually.
EDIT: Updated the bluprint also, but no help.
EDIT: Seem that I got it working after I gave the cube a friendly name. With default it didnt work anymore.
There was an update a couple months ago for the MQTT Name fix, so updating now and making sure the name is valid is required. This is all in the instructional helper file.
There will be another update in a few days to add some features requested by a user, but those are optional to load if all is working for you.
However version 2023-08-07 will be / is a required minimum at some point.
So this touches a few blueprints, but doesnāt change any function. I suggest you use the new re-download feature of Home Assistant, however, and replace them now. Then your logs will be free of the spamming some of the older versions did.
Never use spaces in a topic
Use only ASCII characters
But WHY???
Itās very weird and ridiculous advice.
Only cause readability?
Some characters have special meaning only to humans.
None of the modern technologies will discriminate against characters.
With your blueprint, for example, I cannot use cyrillic characters.
Because then the topic is the friendly name is the entity name is the name in Z2M. I am using some quirks to get some information that would be hard to get otherwise by making sure the name matches that template.
The alternative is Customers would have to enter more inputs and make sure they are all correct.
Iām testing the blueprint, but the cube always shows side 1 in the Aqara logo, and the code wants a 0. Any ideas how to solve this? Anyone with the same problem? Other sides work as intended, but the Aqara side does not.
Are you using the most current version. I ask this because I had a similar issue on an older version on one of these cube BPās, donāt remember which.
So assuming you are on the latest, what is reporting side 1 or how are you checking what side itās on?
I just noticed that the link for the volume control needs to be adjusted, as the volume control script nowās saved here: https://github.com/SirGoodenough/HA_Blueprints/blob/1371c5fa3c50ffd80bcfb8e315480950a5fe3b72/Scripts/volume_control_4_magic_cube.yaml (and not as volume_4_magic_cube.yaml ).
Now Iāll give it a try! Thank you for making this.
I have the normal blueprint working now, but the volume control script does not do anything, after Iāve triggered it. Iām on 2023.12.4. HA running in Docker, Iāve used https://github.com/SirGoodenough/HA_Blueprints/blob/1371c5fa3c50ffd80bcfb8e315480950a5fe3b72/Scripts/volume_control_4_magic_cube.yaml, imported the blueprint, opened it, selected a icon,saved it, and executed it, but Iām just left with Service script.volume_control_4_magic_cube_and_other_things_2023_12_07 not found.
Thanks for finding the bug. It was in all 3 of my Cube BPās, BTW. Should be fixed now.
So the way the volume thing works you import the blueprint and create a script for it, answering the appropriate input questions. That creates a script that you call. So in the cube BP page go to the physical function that you want add a service, find the script that you created, it might ask more questions for the angle and device, and save it. The cube blueprint will call the script created from the other blueprint and do your thing. There are like 4 or 5 script BPās that I created for these actions.
Iām figuring out how to specify which side doing what. I wanna print these for all 6 sides. This one is my first, to control spotify. I dont want too much info. E.g; double tapping is default turning it on when itās off. (but after that, it works like mute/unmute).
This is cool.
FYI adding a label will affect things like tap and flip, as the sensor inside it tuned to the sharp spike in the motion. This is the same reason the cube does not do tap and flips as reliably on a softer surface. I would try 1 side, make sure everything still works before you paste all 6 sides.
My experience with vinyl letters was poor, as the vinyl āpaddedā some of the taps and the letters cut loose and scrambled. (That says FOOD)
iām experiencing problems with the number.cubewoonkamer_last_side Itās always āunavailableā. When i manually set the value, turn the cube, it goes back to āunavailableā. Already have deleted the MQTT device, reimported the latest version of the blueprint, but nothing helpsā¦
any idea?
nevermind, something when wrong during updating the blueprint i guess. Iām missing kind of 600 lines in my blueprint yamlā¦