Can I take you up on this offer? I am also attempting to temporarily disable a trigger as a part of an automation/blueprint.
I have an automation that controls a light switch. This light switch has an LED bar on the side and the “brightness” of the LED bar corresponds with how much of the light bar is illuminated. For example, if the brightness of the light is set to 100%, the light bar is fully lit. If the brightness of the light bar is set to 50%, the light bar is only lit halfway up. If the brightness of the light bar is set to 1%, only the very bottom of the strip is illuminated.
I have written a script to keep the value of this light bar in sync with the brightness of the overhead lights that the switch controls. If the overhead lights get set to 75%, the LED bar will automatically adjust to match the lights.
This is great, except when dimming the lights. The switch sends an “held down” event and a “released” event. When held down, the LED bar starts to change its own brightness based on a configuration for how long it should take (I have chosen four seconds). So if I hold down, the LED bar will take 4 seconds to get from wherever it is to 1%.
Polling the LED bar and setting the Overhead lights to match it’s value was a very unsmooth experience and had unpredictable behavior. So instead of polling the LED bar I figured out that I can instead tell the overhead lights to transition to 1% at the same rate as the LED bar and interrupt the transition when the “released” event is triggered by reading the LED bar value and setting the overhead lights to it. It is a very smooth transition. But the sync script needs to be disabled during this time because the syncing direction is temporarily going the other direction (LED bar to lights instead of lights to LED bar). I would like to combine the sync automation and the switch automation into one, reducing overhead for each switch I have so that instead of disabling and enabling a separate automation I could just disable and enable a trigger internal to the automation itself. Below is the current actions for “held down”, “released”, and “sync”
Held Down
downHeld:
- alias: Disable auto-sync
action: automation.turn_off
metadata: {}
data:
stop_actions: true
target:
entity_id:
- automation.dining_room_light_sync
- action: adaptive_lighting.set_manual_control
metadata: {}
data:
manual_control: true
entity_id: switch.adaptive_lighting_living_and_dining_room
lights:
- light.dining_room
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
enabled: true
- action: light.turn_on
metadata: {}
data:
transition: >-
{{
states('select.dining_room_dimmer_switch_dimming_speed')|trim('s')|trim('m')|float
}}
brightness_pct: 1
target:
entity_id: light.dining_room
alias: Start dimming of lights
Released
downReleased:
- action: light.turn_on
metadata: {}
data:
brightness: >-
{{state_attr('light.dining_room_dimmer_switch_light_1',
'brightness')}}
target:
entity_id: light.dining_room
alias: Stop dimming at current value
- alias: Re-enable auto-sync
action: automation.turn_on
target:
entity_id:
- automation.dining_room_light_sync
data: {}
Sync
alias: Dining Room Light Sync
description: ""
trigger:
- platform: state
entity_id:
- light.dining_room
attribute: brightness
id: brightness
condition: []
action:
- action: light.turn_on
metadata: {}
data:
brightness: "{{ state_attr('light.dining_room', 'brightness') }}"
target:
entity_id: light.dining_room_dimmer_switch_light_1
mode: single