long_short_toggle_4_magic_cube_and_other_things - 2023-12-07 by SirGoodenough
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 actions in other places.
To 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.
This requires you call this script with a couple of 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 device(s) that you are trying o control. Only 1 of the short_entity or long_entity is required 4 this Blueprint to work.
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.
Sample call / use of this script with ZHA:
yaml - service: script.cube_long_short_toggle data: angle: '{{ trigger.event.data.args.relative_degrees | default(0.1) | float(0.2) }}' short_entity: light.kitchen_down_lights long_entity: light.kitchensink
Sample call / use of this script with Z2M:
yaml - service: script.cube_long_short_toggle data: angle: '{{ trigger.payload_json.action_angle | default(0.1) | float(0.2) }}' short_entity: light.kitchen_down_lights long_entity: light.kitchensink
🗿Notice👮🏿♂️:
-
Copies of the original Blueprint that were converted via the 'Take Control' feature or other means are officially not supported by me.
-
I may or may not be able to support you when you have a problem after you make changes to my code, as some of the code is no longer mine.
-
I & my license also require attribution as a link back to the original should you use this code in your own creation.
-
Here is a link to my license & the original github post expected to be followed & referenced as attribution should you use this code elsewhere.
Import to Home Assistant
Click to import this blueprint directly into your Home Assistant instance.
Configuration
Requires 0 inputs to configure
Source Code
View on GitHubDetails
Explore More
Related Blueprints
More button actions automations you might like