I live in a studio apartment, and I want to keep the brightness of all of my light groups (kitchen, living room, bedroom) the same. I therefore store the brightness state in a single variable, input_number.master_brightness, and propagate changes in this variable to the brightness state of all lights that are on. (I also have each light fetch the master_brightness state when it turns on. That automation is working as expected.)
The two automations at issue:
- id: '3'
alias: Send Master Brightness to Lights
initial_state: true
trigger:
- platform: state
entity_id: input_number.master_brightness
action:
- service: light.turn_on
data_template:
entity_id: >
{%- for light in states.light -%}
{%- if not light.entity_id =="light.home" and not light.entity_id =="light.living_space" -%}
{%- if light.state == "on" -%}
{%- if not loop.first %},{%- endif %}
{{ light.entity_id }}
{%- endif -%} {%- endif -%} {%- endfor -%}
brightness_pct: '{{ states.input_number.master_brightness.state|int }}'
- id: '5'
alias: Dimmer Switch Brightness Up
description: ''
trigger:
- device_id: 51b4c8c8104141449a7e9f27bdfe0c70
domain: hue
platform: device
subtype: dim_up
type: remote_button_short_release
condition: []
action:
- data: {}
entity_id: input_number.master_brightness
service: input_number.increment
(I also have an automation similar to Dimmer Switch Brightness Up that decreases the brightness.)
Problem
The problem is that when I press the dimmer switch, it takes several seconds for master_brightness to increment, and another second for this to propagate to the lights. Taken alone, this delay would be bad but not intolerable. But for the ~5 seconds during which this script is running, additional switch presses do nothing. So if, for instance, I am at 40% brightness and want 100% brightness, I can’t just click the switch three times and wait for the automation to finish executing. I have to click, wait five seconds, click again, wait five seconds, and click again.
I’ve Tried
I have tried setting the brightness of lights directly by moving the light.turn_on code into the Dimmer automation. It did not meaningfully improve the latency and did not improve the input issue at all.
Other Details
In case it matters, I am using Hue switches and Hue lights. I’m on Home Assistant 4.09, running on a Raspberry Pi 4 64-bit.
I have a similar automation where I use a hue dimmer for various controls ( about 15 actions on the controller) I don’t mind sharing it with you.
I don’t experience any unintended delay with it
The Hue integration is local polling and polls the bridge every 5 seconds. Because of this, home assistant won’t know about dimmer switch button press events and motion sensor events for up to 5 seconds after they actually happen. There is a custom component that allows you to change the polling interval, but I can’t seem to find it at the moment unfortunately
I, (un)fortunately, use a Zigbee stick (Gocontrol Zigbee/Zwave usb stick) with my Zigbee things (Hue Dimmer included). So I cannot attest for that latency, I had understood that it was caused by the automation, not the hue bridge.
Thanks for the help, folks. I would really prefer to manage all aspects of my home automation, including dimmer switches, through HA, but I’ve decided I don’t really need to at the moment. I will just use HA, and specifically Circadian Lighting, to control color temperature and will handle brightness and on/off mostly through Hue.
But be aware that it is a big one. Due to the per room detection and multi-press function on the dimmer.
( up to 5 presses per button and conditional actions depending on entity states, for a total of
30 different actions on the dimmer )
Feel free to ask me any questions regarding the flow!
Hi @Maxi1134, what an incredible complicated (looking) piece of art! That workflow… How do you even construct something like this and debug it in case it’s not behaving as expected? Kudos!
At some point I was where you were were @dchawisher … For a while I was running Home Assistant on RPi with Conbee USB stick as well as Hue bridge, connecting both through the Hue integration. I was thinking it would give me all kinds of benefits like being able to do stuff through the Hue app that I would otherwise miss out on. Turns out it caused more issues than it solved, for one, the fact that a bulb cannot be connected to both ‘hubs’, so making groups is limited. You can only group devices that are on the same hub.
I realise this is an old post, things have changed a lot since then, but perhaps still relevant.
If you’re using Zigbee2Mqtt, create a group and add all the lights to that group.
In your automation, send a ‘set’ command to the group with the desired brightness and you’re good to go.
For dimming purposes sending a ‘set’ command with { "brightness_move": 50 } or { "brightness_move": -50 } to the group works like a charm.
This will start changing brightness up or down until it is stopped, by setting brightness_move to 0.
You would typically do that when the automation is triggered by an even like down_hold_release, up_hold_release or something, depending on what kind of events your switch sends.