Compare commits
2
Commits
746a048251
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
490d60adc0 | ||
|
|
9e3c770178 |
@@ -44,7 +44,7 @@ blueprint:
|
|||||||
|
|
||||||
rotation_deadzone:
|
rotation_deadzone:
|
||||||
name: Rotation Deadzone (Anti-knock)
|
name: Rotation Deadzone (Anti-knock)
|
||||||
description: The minimum rotation angle (in degrees) required to trigger a dimming action. Increase this if you accidentally dim the lights when clicking the knob.
|
description: The rotation angle below which the blueprint briefly waits to determine whether the event was actually a single click.
|
||||||
default: 20
|
default: 20
|
||||||
selector:
|
selector:
|
||||||
number:
|
number:
|
||||||
@@ -126,11 +126,8 @@ action:
|
|||||||
payload: "{{ trigger.payload_json if trigger.payload_json is defined else {} }}"
|
payload: "{{ trigger.payload_json if trigger.payload_json is defined else {} }}"
|
||||||
raw_action_type: "{{ payload.action | default('') }}"
|
raw_action_type: "{{ payload.action | default('') }}"
|
||||||
|
|
||||||
# Time since the previous MQTT event triggered this automation.
|
# Time since the previous real MQTT action event.
|
||||||
# Genuine stop_rotating events immediately follow rotation events.
|
# Null/missing action packets are filtered at the trigger above.
|
||||||
# The H2 bug emits a stray stop_rotating after the device has been idle.
|
|
||||||
# Null/missing action packets are filtered at the MQTT trigger above,
|
|
||||||
# so only genuine action events affect this timer.
|
|
||||||
idle_seconds: >
|
idle_seconds: >
|
||||||
{{ as_timestamp(now()) -
|
{{ as_timestamp(now()) -
|
||||||
as_timestamp(
|
as_timestamp(
|
||||||
@@ -210,10 +207,56 @@ action:
|
|||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ action_type == 'rotation' }}"
|
value_template: "{{ action_type == 'rotation' }}"
|
||||||
sequence:
|
sequence:
|
||||||
# Filter out accidental micro-rotations (knocks) below the deadzone
|
- choose:
|
||||||
|
# Small rotations may actually be a misreported single click.
|
||||||
|
# Wait briefly for the stop_rotating packet that accompanies
|
||||||
|
# the H2's erroneous rotation -> stop_rotating click sequence.
|
||||||
|
- conditions:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ (raw_angle | abs) >= (deadzone | float(0)) }}"
|
value_template: "{{ (raw_angle | abs) < (deadzone | float(0)) }}"
|
||||||
# Only fire the turn_on service if there was a registrable angle change
|
sequence:
|
||||||
|
- wait_for_trigger:
|
||||||
|
- platform: mqtt
|
||||||
|
topic: !input mqtt_topic
|
||||||
|
payload: "stop_rotating"
|
||||||
|
value_template: "{{ value_json.action | default('') }}"
|
||||||
|
timeout:
|
||||||
|
milliseconds: 300
|
||||||
|
continue_on_timeout: true
|
||||||
|
|
||||||
|
- choose:
|
||||||
|
# stop_rotating arrived within the click window:
|
||||||
|
# treat the small rotation as a single press.
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ wait.completed }}"
|
||||||
|
sequence:
|
||||||
|
- choose:
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ enable_toggle }}"
|
||||||
|
sequence:
|
||||||
|
- service: light.toggle
|
||||||
|
target: !input target_light
|
||||||
|
|
||||||
|
- choose:
|
||||||
|
- conditions: []
|
||||||
|
sequence: !input single_press_action
|
||||||
|
|
||||||
|
# No stop_rotating within the click window:
|
||||||
|
# this was a genuine small rotation, so apply it.
|
||||||
|
default:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ scaled_step != 0 }}"
|
||||||
|
- service: light.turn_on
|
||||||
|
target: !input target_light
|
||||||
|
data:
|
||||||
|
brightness_step_pct: "{{ scaled_step }}"
|
||||||
|
transition: !input dim_transition
|
||||||
|
|
||||||
|
# Rotation exceeds the deadzone, so it is unambiguously a
|
||||||
|
# genuine rotation and can be processed immediately.
|
||||||
|
default:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ scaled_step != 0 }}"
|
value_template: "{{ scaled_step != 0 }}"
|
||||||
- service: light.turn_on
|
- service: light.turn_on
|
||||||
|
|||||||
Reference in new issue
Block a user