Last active
August 13, 2025 16:23
-
-
Save jsenecal/02e6686f49c5d8021913bf4fe38f2ceb to your computer and use it in GitHub Desktop.
ERS Rotary Dial - Simple RGBCCW Light Control
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: ERS Rotary Dial - Simple RGBCCW Light Control | |
| description: > | |
| Simple control for ERS rotary dial with event entity. | |
| Single tap: toggle (but when off, only turn on), Double tap: RGB/white mode, | |
| Rotate: brightness, Press+rotate: hue/color | |
| domain: automation | |
| input: | |
| light: | |
| name: Light Entity | |
| description: The light entity to control | |
| selector: | |
| entity: | |
| filter: | |
| - domain: light | |
| multiple: false | |
| dial: | |
| name: Rotary Dial Event Entity | |
| description: Select the rotary dial event entity | |
| selector: | |
| entity: | |
| filter: | |
| - domain: event | |
| multiple: false | |
| mode_tracker: | |
| name: RGB/White Mode Tracker | |
| description: Input boolean to track RGB (on) vs white (off) mode | |
| selector: | |
| entity: | |
| filter: | |
| - domain: input_boolean | |
| multiple: false | |
| step_size_sensor: | |
| name: Rotation Step Size Sensor | |
| description: Sensor that reports rotation step size/rate | |
| selector: | |
| entity: | |
| filter: | |
| - domain: sensor | |
| multiple: false | |
| brightness_multiplier: | |
| name: Brightness Change Multiplier | |
| description: Multiplier for brightness changes (step_size * multiplier) | |
| default: 3 | |
| selector: | |
| number: | |
| min: 0.1 | |
| max: 5 | |
| step: 0.1 | |
| color_multiplier: | |
| name: Color Change Multiplier | |
| description: Multiplier for hue/color changes (step_size * multiplier) | |
| default: 0.5 | |
| selector: | |
| number: | |
| min: 0.1 | |
| max: 5 | |
| step: 0.1 | |
| transition_time: | |
| name: Transition Time | |
| description: Transition time for light changes in seconds | |
| default: 0.3 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 5 | |
| step: 0.1 | |
| rgb_saturation: | |
| name: RGB Saturation | |
| description: Saturation level for RGB mode (0-100, higher = more vivid colors) | |
| default: 100 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 100 | |
| step: 1 | |
| mode: queued | |
| max: 10 | |
| max_exceeded: silent | |
| trigger: | |
| - platform: state | |
| entity_id: !input dial | |
| action: | |
| - variables: | |
| light: !input light | |
| mode_tracker: !input mode_tracker | |
| step_size_sensor: !input step_size_sensor | |
| brightness_multiplier: !input brightness_multiplier | |
| color_multiplier: !input color_multiplier | |
| transition_time: !input transition_time | |
| rgb_saturation: !input rgb_saturation | |
| event_type: "{{ trigger.to_state.attributes.event_type if trigger.to_state and trigger.to_state.attributes else '' }}" | |
| direction: "{{ trigger.to_state.attributes.direction if trigger.to_state and trigger.to_state.attributes else '' }}" | |
| step_size: "{{ states(step_size_sensor) }}" | |
| step_size_final: "{{ 20 if states(step_size_sensor) in ['unknown', 'unavailable', 'none'] or (states(step_size_sensor) | int(0)) == 0 else (states(step_size_sensor) | int(0)) }}" | |
| is_rgb_mode: "{{ is_state(mode_tracker, 'on') }}" | |
| current_brightness: "{{ state_attr(light, 'brightness') | int(255) }}" | |
| current_kelvin: "{{ state_attr(light, 'color_temp_kelvin') | int(3000) }}" | |
| - condition: template | |
| value_template: "{{ event_type != '' }}" | |
| - choose: | |
| # Single tap: toggle light (but when off, only turn on) | |
| - alias: "Toggle Light" | |
| conditions: | |
| - condition: template | |
| value_template: "{{ event_type == 'toggle' }}" | |
| sequence: | |
| - choose: | |
| # Light is off: just turn on | |
| - alias: "Turn On When Off" | |
| conditions: | |
| - condition: template | |
| value_template: "{{ is_state(light, 'off') }}" | |
| sequence: | |
| - service: light.turn_on | |
| data: | |
| transition: "{{ transition_time }}" | |
| target: | |
| entity_id: !input light | |
| # Light is on: toggle off | |
| - alias: "Turn Off When On" | |
| conditions: | |
| - condition: template | |
| value_template: "{{ is_state(light, 'on') }}" | |
| sequence: | |
| - service: light.turn_off | |
| data: | |
| transition: "{{ transition_time }}" | |
| target: | |
| entity_id: !input light | |
| # Double tap: switch between RGB and white modes | |
| - alias: "Switch Color Mode" | |
| conditions: | |
| - condition: template | |
| value_template: "{{ event_type == 'double' }}" | |
| sequence: | |
| - service: input_boolean.toggle | |
| target: | |
| entity_id: !input mode_tracker | |
| - choose: | |
| # Switching to RGB mode | |
| - alias: "Switch to RGB Mode" | |
| conditions: | |
| - condition: template | |
| value_template: "{{ not is_rgb_mode }}" | |
| sequence: | |
| - service: light.turn_on | |
| data: | |
| hs_color: > | |
| {% set hs = state_attr(light, 'hs_color') %} | |
| {% if hs is not none and hs|length >= 2 %} | |
| [{{ hs[0] }}, {{ rgb_saturation }}] | |
| {% else %} | |
| [0, {{ rgb_saturation }}] | |
| {% endif %} | |
| transition: "{{ transition_time }}" | |
| target: | |
| entity_id: !input light | |
| # Switching to white mode | |
| - alias: "Switch to White Mode" | |
| conditions: | |
| - condition: template | |
| value_template: "{{ is_rgb_mode }}" | |
| sequence: | |
| - service: light.turn_on | |
| data: | |
| kelvin: "{{ current_kelvin }}" | |
| transition: "{{ transition_time }}" | |
| target: | |
| entity_id: !input light | |
| # Rotate: adjust brightness (only when light is on) | |
| - alias: "Adjust Brightness" | |
| conditions: | |
| - condition: template | |
| value_template: "{{ event_type in ['rotate', 'rotation', 'brightness_step', 'step'] }}" | |
| - condition: template | |
| value_template: "{{ is_state(light, 'on') }}" | |
| sequence: | |
| - variables: | |
| brightness_step: "{{ (step_size_final * brightness_multiplier) | int }}" | |
| new_brightness: > | |
| {% set step = brightness_step if direction == 'up' else -brightness_step %} | |
| {% set new_val = current_brightness + step %} | |
| {% if new_val > 255 %}255{% elif new_val < 1 %}1{% else %}{{ new_val }}{% endif %} | |
| - service: light.turn_on | |
| data: | |
| brightness: "{{ new_brightness }}" | |
| transition: "{{ transition_time }}" | |
| target: | |
| entity_id: !input light | |
| # Press + rotate: adjust hue/color (only when light is on) | |
| - alias: "Adjust Color/Hue" | |
| conditions: | |
| - condition: template | |
| value_template: "{{ event_type in ['color_temperature_step_up', 'color_temperature_step_down', 'press_rotate', 'hold_rotate'] }}" | |
| - condition: template | |
| value_template: "{{ is_state(light, 'on') }}" | |
| sequence: | |
| - choose: | |
| # RGB mode: adjust hue | |
| - alias: "Adjust Hue in RGB Mode" | |
| conditions: | |
| - condition: template | |
| value_template: "{{ is_rgb_mode }}" | |
| sequence: | |
| - service: light.turn_on | |
| data: | |
| hs_color: > | |
| {% set direction_multiplier = 1 if event_type == 'color_temperature_step_up' else -1 %} | |
| {% set hue_step = (step_size_final * color_multiplier) | int %} | |
| {% set current_hs = state_attr(light, 'hs_color') %} | |
| {% if current_hs is not none and current_hs|length >= 2 %} | |
| {% set current_hue = current_hs[0] | int(0) %} | |
| {% else %} | |
| {% set current_hue = 0 %} | |
| {% endif %} | |
| {% set step = hue_step * direction_multiplier %} | |
| {% set new_hue = current_hue + step %} | |
| {% if new_hue > 360 %} | |
| {% set new_hue = new_hue - 360 %} | |
| {% elif new_hue < 0 %} | |
| {% set new_hue = new_hue + 360 %} | |
| {% endif %} | |
| [{{ new_hue }}, {{ rgb_saturation }}] | |
| transition: "{{ transition_time }}" | |
| target: | |
| entity_id: !input light | |
| # White mode: adjust color temperature | |
| - alias: "Adjust Color Temperature in White Mode" | |
| conditions: | |
| - condition: template | |
| value_template: "{{ not is_rgb_mode }}" | |
| sequence: | |
| - variables: | |
| direction_multiplier: "{{ 1 if event_type == 'color_temperature_step_up' else -1 }}" | |
| kelvin_step: "{{ (step_size_final * color_multiplier * 10) | int }}" | |
| new_kelvin: > | |
| {% set step = kelvin_step * direction_multiplier %} | |
| {% set new_val = current_kelvin + step %} | |
| {% if new_val > 6500 %}6500{% elif new_val < 2000 %}2000{% else %}{{ new_val }}{% endif %} | |
| - service: light.turn_on | |
| data: | |
| kelvin: "{{ new_kelvin }}" | |
| transition: "{{ transition_time }}" | |
| target: | |
| entity_id: !input light |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment