🧯 Miscellaneous Blueprint Scripts - Volume - Dimming - Reset - Long Short Press Simulation - Color Change

These are several Script Blueprints written to help other Automations or Blueprints complete repetitive ot tricky tasks.

:bookmark_tabs: Changelog

  • 2023-12-07: Stop log spamming leak. #32
    • (Documentation change 2-7-2024 to add License notice. Changes only to Descriptions.)
  • 2023-11-14: Add Transition to Dimmer as per FR #24
  • 2023-08-07: First release as it’s own Blueprint Exchange thread :tada:

:crystal_ball: About this blueprint

Type of blueprint: SCRIPT

What if I am having problems getting it going?

You can contact me for help, see the links below.

Why do I need this?

There are several Script Blueprints in here. The Descriptions provided should help you decide if you need them in your life or not.
Several of these are designed to accept a number from 0 to 360 like the angle number that comes out of a Aqara Xiaomi Magic Cube’s angle value and do something with it. There are others as well that do other things.

:moyai:License 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.

:arrows_clockwise: Device Reset

This script was invented to be used with my Device Tracker-Monitor-Notifier Blueprint. I released it as a standalone Script Blueprint because I saw an opportunity to add another tool to my toolbox, and possibly to others
toolboxes.

There are other places in my HA config where I need to reset something and now I can use this thing.

It asks for the entity or list of entities that you want to reset and how long you want them to be off for the reset.

When a Script using this Blueprint is called, it will use Homeassistant turn off to shut them off, wait the delay, then turn them back on. Simple Simple, but if you are doing it over and over in an automation, this cleans up the code quite a bit.

:calling: Software to Download :floppy_disk:

HA link to download blueprint: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Direct link to download Blueprint: https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/device_reset.yaml

HA_Blueprints/Scripts/device_reset.yaml at master · SirGoodenough/HA_Blueprints · GitHub.

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

:loud_sound: Volume Control 4 Magic Cube

This script was invented to be used with my Magic Cube Blueprints. I released it as a standalone Script Blueprint because because of requests to extend the function of my BP’s with how to convert cube rotation to volume in other places. Research found me this Post from Petro which had a very elegant solution to the problem, It was very easy decision to adopt it here.

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 and provide action data. This script has one !input in the Blueprint screen to set the sensitivity of the rotation to volume changes. 30 seemed about right, but adjust as
needed.

Because all the data is added to control the action live at each use this is the only !input. This requires you call this generated script wth 2 data values when you want it to run. 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 media_player that you are trying to control.

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 for ZHA:

- service: script.cube_dimmer_control_bp
    data:
    angle: '{{ trigger.event.data.args.relative_degrees | default(0.1) | float(0.2) }}'
    mp: media_player.farg

Sample call / use of this script for Z2M:

- service: script.cube_dimmer_control_bp
    data:
    angle: '{{ trigger.payload_json.action_angle | default(0.1) | float(0.2) }}'
    mp: media_player.farg

:calling: Software to Download :floppy_disk:

HA link to download blueprint: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Direct link to download Blueprint: https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/volume_control_4_magic_cube.yaml

HA_Blueprints/Scripts/volume_control_4_magic_cube.yaml at master · SirGoodenough/HA_Blueprints · GitHub.

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

:rainbow: Color Control 4 Magic Cube

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.

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 1 input to select the relationship between the rotation amount and the speed of the color change.

This requires you call this script wth 3 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 second data point is the entity of the light or light group that you are trying to control. The third is to tell the BP id you are controlling the red, the blue, or the green part of the color.

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:

- service: script.cube_color_control
    data:
    angle: '{{ trigger.event.data.args.relative_degrees | default(0.1) | float(0.2) }}'
    light: light.grp_studio
    t_color: red

Sample call / use of this script with Z2M:

- service: script.cube_color_control
    data:
    '{{ trigger.payload_json.action_angle | default(0.1) | float(0.2) }}'
    light: light.kitchensink
    t_color: red

:calling: Software to Download :floppy_disk:

HA link to download blueprint: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Direct link to download Blueprint: https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/color_control_4_magic_cube.yaml

HA_Blueprints/Scripts/color_control_4_magic_cube.yaml at master · SirGoodenough/HA_Blueprints · GitHub.

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

:last_quarter_moon: Dimmer Control 4 Magic Cube

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.

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 2 inputs in the Blueprint screen to set the sensitivity of the rotation action and the minimum brightness level for your lights. If the rotation is too sensitive the lights will change from dim to bright
in too short of a rotation so make it less sensitive. If the lights flicker at low brightness, raise the minimum brightness level to stop it.

The data is sent to the generated script to control the action live at each use. You only need to execute this blueprint generator script if you wish to change in input values or create another dimmer script.

There is a third optional field available, transition. This is the transition value for the lights. It can be picked as a field, as an input, or ignored. Ignored it doesn’t change the current value in the light. If you call the script with a data field that has priority and that will be the value set. If there is no data field called, and there is an input value, that will be used.

This 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.

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 for ZHA:

- service: script.cube_dimmer_control_bp
    data:
    angle: '{{ trigger.event.data.args.relative_degrees | default(0.1) | float(0.2) }}'
    light: light.grp_studio
    transition: 4

Sample call / use of this script for Z2M:

- service: script.cube_dimmer_control_bp
    data:
    angle: '{{ trigger.payload_json.action_angle | default(0.1) | float(0.2) }}'
    light: light.grp_kitch

:calling: Software to Download :floppy_disk:

HA link to download blueprint: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Direct link to download Blueprint: https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/dimmer_control_4_magic_cube.yaml

HA_Blueprints/Scripts/dimmer_control_4_magic_cube.yaml at master · SirGoodenough/HA_Blueprints · GitHub.

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

:flags: Long Short Toggle 4 Magic Cube

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 to 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:

- 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:

- 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

:calling: Software to Download :floppy_disk:

HA link to download blueprint: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Direct link to download Blueprint: https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/long_short_toggle_4_magic_cube.yaml

HA_Blueprints/Scripts/long_short_toggle_4_magic_cube.yaml at master · SirGoodenough/HA_Blueprints · GitHub.

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

:envelope_with_arrow: Version Updates

Updates will be published on my GIT repository with the rest of my Home Assistant Blueprint collection.

:envelope_with_arrow: There is not an official version control system for Blueprints. However I have found something that comes pretty close. It is not perfect, but for MOST Blueprints, it does just fine. I encourage you to check this script out and use it to easily check if I have updated this blueprint. :link:koter84 Blueprint Update Script

:globe_with_meridians: All My Blueprints

Link to ALL my Blueprints

https://github.com/SirGoodenough/HA_Blueprints/blob/master/README.md

:man_juggling:t5: Contact Links or see my other work

What are we Fixing Today Homepage / Website: https://www.WhatAreWeFixing.Today/

Channel Link URL: (WhatAreWeFixingToday) https://bit.ly/WhatAreWeFixingTodaysYT

Discord Guild: (Sir_Goodenough#9683) WhatAreWeFixingToday?

:cheese: If you want to support me

Buy me Coffee: https://www.buymeacoffee.com/SirGoodenough

PayPal one-off donation link: PayPal.Me

#WhatAreWeFixingToday

#SirGoodEnough

If you were having a problem with the volume control kicking up errors, I found a minor bug. A condition where the volume was not known to HA showed up to me that didn’t show in testing. Reload the volume control BP to fix the issue. Not worth bumping the rev numbers.

The change was I added the cast to float with the default here so if there is no volume to grab, it has a place to start (40% volume).

      volume_level: >-
        {% set v = state_attr(mp, 'volume_level') | float(0.4) %}
        {{ v + 0.0000625 * delta }}

:bookmark_tabs: Changelog

  • 2023-11-14: Add Transition to Dimmer as per FR #24

New Versions. 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.

:bookmark_tabs: Changelog

  • 2023-12-07: Stop log spamming leak. #32