feat: smoothen transition when dimming light (#9)

* feat: add transition when dimming light

* chore: add sections to simplify the blueprint

* chore: hardcode source_url

* feat: rework dimming down mechanism

* chore: add CODEOWNERS
This commit is contained in:
Damien
2024-12-20 14:34:04 +01:00
committed by GitHub
parent d7f693d393
commit f5c2b9d6e1
3 changed files with 113 additions and 91 deletions

1
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1 @@
@damru

View File

@@ -20,7 +20,8 @@ blueprint:
- Double press **on/off** (Rodret, _Optional_) **1 dot/2 dots** (Somrig)
- Hold **on/off** (Rodret) **1 dot/2 dots** (Somrig).
Actions will be executed every **Helper - Hold delay**, but maximum **Helper - Max number of loops** times.
Actions will be executed every **Hold delay**, but maximum **Max number of loops** times.
source_url: https://github.com/damru/ha-blueprints/blob/main/ikea_E2201-E2213_ZHA-Z2M_control-anything.yaml
input:
remote_device:
name: Remote
@@ -44,47 +45,54 @@ blueprint:
model: SOMRIG shortcut button (E2213)
multiple: false
on_press_action:
name: Single press action (on / 1 dot)
name: Press "on / 1 dot" action
description: Choose action(s) to run when **on** (Rodret) or **1 dot** (Somrig) button is **pressed**.
default: []
selector:
action: {}
off_press_action:
name: Single press action (off / 2 dots)
name: Press "off / 2 dots" action
description: Choose action(s) to run when **off** (Rodret) or **2 dots** (Somrig) button is **pressed**.
default: []
selector:
action: {}
on_hold_action:
name: Hold action (on / 1 dot)
name: Hold "on / 1 dot" action
description: Choose action(s) to run when **on** (Rodret) or **1 dot** (Somrig) button is **held**.
default: []
selector:
action: {}
off_hold_action:
name: Hold action (off / 2 dots)
name: Hold "off / 2 dots" action
description: Choose action(s) to run when **off** (Rodret) or **2 dots** (Somrig) button is **held**.
default: []
selector:
action: {}
on_double_press_action:
name: Double press action (on / 1 dot)
name: Double press "on / 1 dot" action
description: >
Choose action(s) to run when the **on** (Rodret) or **1 dot** (Somrig) button is **pressed twice**.
(**_NB for Rodret only_**: **Double press event (on)** must be exposed and **Helper - Double press delay** interval is used as a timeout.)
**_NB for Rodret only_**: **Double press event (on)** must be exposed and **Double press delay** interval is used as a timeout.
default: []
selector:
action: {}
off_double_press_action:
name: Double press action (off / 2 dots)
name: Double press "off / 2 dots" action
description: >
Choose action(s) to run when the **off** (Rodret) or **2 dots** (Rodret) button is **pressed twice**.
(**_NB for Rodret only_**: **Double press event (off)** must be exposed and **Helper - Double press delay** interval is used as a timeout.)
**_NB for Rodret only_**: **Double press event (off)** must be exposed and **Double press delay** interval is used as a timeout.
default: []
selector:
action: {}
helper_section :
name: Helpers
icon: mdi:cog-outline
collapsed: true
input:
helper_hold_delay:
name: Helper - Hold delay
name: Hold delay
description: Delay between the execution of the **Hold** action(s).
default: 250
selector:
@@ -95,7 +103,7 @@ blueprint:
step: 10.0
mode: slider
helper_max_loops:
name: Helper - Max number of loops
name: Max number of loops
description: Maximum number of loops when holding down a button.
default: 20
selector:
@@ -104,26 +112,31 @@ blueprint:
max: 1000.0
step: 1.0
mode: slider
rodret_options_section:
name: Rodret options
icon: mdi:remote
collapsed: true
input:
on_double_press_exposed:
name: (Rodret only) Double press event (on)
name: Expose virtual double press "on" event
description: >
**_(Rodret only)_** Choose whether or not to expose the virtual **double press** event for the **on** button.
Choose whether or not to expose the virtual **double press** event for the **on** button.
Turn this on if you are providing action(s) for the **Double press action (on / 1 dot)**.
default: false
selector:
boolean: {}
off_double_press_exposed:
name: (Rodret only) Double press event (off)
name: Expose virtual double press "off" event
description: >
**_(Rodret only)_** Choose whether or not to expose the virtual **double press** event for the **off** button.
Choose whether or not to expose the virtual **double press** event for the **off** button.
Turn this on if you are providing an action for the **Double press action (off / 2 dots)**.
default: false
selector:
boolean: {}
helper_double_press_delay:
name: (Rodret only) Helper - Double press delay
name: Double press delay
description: >
**(Rodret only)** Max delay between the first and the second button press for the
Max delay between the first and the second button press for the
**Double press events**. Provide a value only if you are using a double press action.
Increase this value if you notice that the double press action is not triggered
properly.

View File

@@ -16,13 +16,14 @@ blueprint:
Available controls:
- Press **on** (Rodret) or **1 dot** (Somrig) to turn on the light
(Optional: set the target brightness by enabling **Helper - Force Brightness** and setting a **Helper - Brightness** value)
(Optional: set the target brightness by enabling **Force Brightness** and setting a **Brightness** value)
- Press **off** (Rodret) or **2 dots** (Somrig) to turn off the light
- Hold **on** (Rodret) or **1 dot** button to increase the brightness
- Hold **off** (Rodret) or **2 dots** button to decrease the brightness down to 1%
source_url: https://github.com/damru/ha-blueprints/blob/main/ikea_E2201-E2213_ZHA-Z2M_control-light.yaml
input:
remote_device:
name: Remote
@@ -53,16 +54,21 @@ blueprint:
filter:
domain: light
multiple: false
brightness_section:
name: Brightness
icon: mdi:lightbulb-on-50
collapsed: true
input:
helper_force_brightness:
name: Helper - Force brightness
description: Force the brightness to **Helper - Brightness** value when light turns on.
name: Force brightness
description: Force the brightness to **Brightness** value when light turns on.
default: false
selector:
boolean: {}
helper_brightness:
name: Helper - Brightness
name: Brightness
description:
Target light brightness when turning on. Requires **Helper - Force brightness**
Target light brightness when turning on. Requires **Force brightness**
to be enabled.
default: 50
selector:
@@ -258,7 +264,7 @@ actions:
- variables:
helper_force_brightness: !input helper_force_brightness
helper_hold_delay: 0.1
helper_hold_dim_step: 5
helper_hold_dim_step: 4
light: !input light
- choose:
- conditions:
@@ -317,6 +323,7 @@ actions:
entity_id: !input light
data:
brightness_step_pct: "{{ helper_hold_dim_step }}"
transition: "{{ helper_hold_delay }}"
- delay: "{{ helper_hold_delay }}"
- conditions:
- condition: trigger
@@ -326,22 +333,23 @@ actions:
- hold-dots2-zha-e2213
- hold-dots2-z2m-e2213
sequence:
- variables:
brightness_pct: "{{ iif(is_state(light, 'on'), state_attr(light, 'brightness'), 0) * 100 / 255 }}"
total_iterations_to_zero: "{{ (brightness_pct / helper_hold_dim_step) | round(0, 'ceil') }}"
- repeat:
while:
- condition: template
value_template:
"{{ state_attr(light, 'brightness') | int / 255 > helper_hold_dim_step/100
}}"
count: "{{ total_iterations_to_zero - 1 }}"
sequence:
- parallel:
- action: light.turn_on
target:
entity_id: !input light
data:
brightness_step_pct: "{{ helper_hold_dim_step | int * -1 }}"
target:
entity_id: !input light
transition: "{{ helper_hold_delay }}"
- delay: "{{ helper_hold_delay }}"
- action: light.turn_on
data:
brightness_pct: 1
target:
entity_id: !input light
data:
brightness_pct: 1
transition: "{{ helper_hold_delay }}"