Last active
April 10, 2025 16:44
-
-
Save D3SOX/163d347d5eb495abe20d1925c5391ded to your computer and use it in GitHub Desktop.
Dim a light with an Aqara Cube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Aqara Cube Light Dimmer | |
description: Adjust light brightness using Aqara Cube rotation | |
domain: automation | |
input: | |
cube_angle_sensor: | |
name: Aqara Cube Angle Sensor | |
description: The sensor that provides the rotation angle | |
selector: | |
entity: | |
domain: sensor | |
light_entity: | |
name: Light to control | |
description: The light entity that will be dimmed | |
selector: | |
entity: | |
domain: light | |
brightness_multiplier: | |
name: Brightness Change Speed | |
description: How fast the brightness changes with rotation (higher = faster changes) | |
default: 2 | |
selector: | |
number: | |
min: 0.5 | |
max: 10 | |
step: 0.5 | |
mode: slider | |
trigger: | |
- platform: state | |
entity_id: !input cube_angle_sensor | |
condition: | |
- condition: template | |
value_template: "{{ trigger.to_state.state != 'unknown' and trigger.to_state.state|float|abs > 5 }}" | |
variables: | |
light_entity: !input light_entity | |
brightness_multiplier: !input brightness_multiplier | |
action: | |
- service: light.turn_on | |
target: | |
entity_id: !input light_entity | |
data: | |
brightness: >- | |
{% set current = state_attr(light_entity, 'brightness') | int(100) %} | |
{% set angle = trigger.to_state.state | float %} | |
{% if angle > 0 %} | |
{% set new_brightness = current + (angle|abs * brightness_multiplier)|int %} | |
{{ [new_brightness, 255]|min }} | |
{% else %} | |
{% set new_brightness = current - (angle|abs * brightness_multiplier)|int %} | |
{{ [new_brightness, 1]|max }} | |
{% endif %} | |
mode: restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment