Possibly a daft question, but is this for a Hue light or not?
Never a daft question!
Not sure, as at the moment, I’m not sure where the dimmer will end up as I’m currently just working out the possibilities and whether or not to get more of them.
I have a mixture of hue bulbs and LightwaveRF dimmers / switches.
OK, well, if it is a Hue light then you just associate the switch with the light in the Hue app and don’t worry about anything in homeassistant for it other than funky extras (like if you press and hold bright turn on disco mode or whatever)
If it’s not, then you’ll need to monitor for the press of a button as a trigger for a script that incrementally increases/decreases the brightness, and then monitor the release of the button to trigger another automation to stop the script.
Hope this makes sense
Gotcha!
I don’t suppose that you know of any examples of the incremental brightness script?? Sounds a little past my pay grade!
No, but a quick and dirty one would be something like:
script:
increment_light:
sequence:
- service: light.turn_on
data_template:
entity_id: light.livingroom
brightness_pct: >
{% if state_attr('light.livingroom' , 'brightness_pct') < 90 %}
{{ state_attr('light.livingroom' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.livingroom
brightness_pct: >
{% if state_attr('light.livingroom' , 'brightness_pct') < 90 %}
{{ state_attr('light.livingroom' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.livingroom
brightness_pct: >
{% if state_attr('light.livingroom' , 'brightness_pct') < 90 %}
{{ state_attr('light.livingroom' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.livingroom
brightness_pct: >
{% if state_attr('light.livingroom' , 'brightness_pct') < 90 %}
{{ state_attr('light.livingroom' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.livingroom
brightness_pct: >
{% if state_attr('light.livingroom' , 'brightness_pct') < 90 %}
{{ state_attr('light.livingroom' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.livingroom
brightness_pct: >
{% if state_attr('light.livingroom' , 'brightness_pct') < 90 %}
{{ state_attr('light.livingroom' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.livingroom
brightness_pct: >
{% if state_attr('light.livingroom' , 'brightness_pct') < 90 %}
{{ state_attr('light.livingroom' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.livingroom
brightness_pct: >
{% if state_attr('light.livingroom' , 'brightness_pct') < 90 %}
{{ state_attr('light.livingroom' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.livingroom
brightness_pct: >
{% if state_attr('light.livingroom' , 'brightness_pct') < 90 %}
{{ state_attr('light.livingroom' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.livingroom
brightness_pct: >
{% if state_attr('light.livingroom' , 'brightness_pct') < 90 %}
{{ state_attr('light.livingroom' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
Which just takes the brightness it’s currently at and adds 10% every second until it goes above 90 and then the next iteration puts it to 100.
Do something similar going the other way but to 5%
Wowser! Cheers for that!
I’ll have a play.
Gave the code a go, but it doesn’t seem to be doing anything.
This is what I have:
automation:
- id: 'hue_dimmer_test'
alias: 'hue dimmer test'
trigger:
- platform: state
entity_id: sensor.hue_dimmer_1
to: '2_hold'
condition:
action:
- service: script.increment_light
script:
increment_light:
sequence:
- service: light.turn_on
data_template:
entity_id: light.kitchen_table
brightness_pct: >
{% if state_attr('light.kitchen_table' , 'brightness_pct') < 90 %}
{{ state_attr('light.kitchen_table' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.kitchen_table
brightness_pct: >
{% if state_attr('light.kitchen_table' , 'brightness_pct') < 90 %}
{{ state_attr('light.kitchen_table' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.kitchen_table
brightness_pct: >
{% if state_attr('light.kitchen_table' , 'brightness_pct') < 90 %}
{{ state_attr('light.kitchen_table' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.kitchen_table
brightness_pct: >
{% if state_attr('light.kitchen_table' , 'brightness_pct') < 90 %}
{{ state_attr('light.kitchen_table' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.kitchen_table
brightness_pct: >
{% if state_attr('light.kitchen_table' , 'brightness_pct') < 90 %}
{{ state_attr('light.kitchen_table' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.kitchen_table
brightness_pct: >
{% if state_attr('light.kitchen_table' , 'brightness_pct') < 90 %}
{{ state_attr('light.kitchen_table' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.kitchen_table
brightness_pct: >
{% if state_attr('light.kitchen_table' , 'brightness_pct') < 90 %}
{{ state_attr('light.kitchen_table' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.kitchen_table
brightness_pct: >
{% if state_attr('light.kitchen_table' , 'brightness_pct') < 90 %}
{{ state_attr('light.kitchen_table' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.kitchen_table
brightness_pct: >
{% if state_attr('light.kitchen_table' , 'brightness_pct') < 90 %}
{{ state_attr('light.kitchen_table' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
- delay: 00:00:01
- service: light.turn_on
data_template:
entity_id: light.kitchen_table
brightness_pct: >
{% if state_attr('light.kitchen_table' , 'brightness_pct') < 90 %}
{{ state_attr('light.kitchen_table' , 'brightness_pct') + 10 }}
{% else %} 100 {% endif %}
Stick that repeated template in your editor and make sure the numbers come out right, and then try casting the state_attr statements to ints.
Remove the line condition:
from automation.
Check the automation is on.
How are you adding and supporting your hue dimmer switch?
As far as I can tell there is no native support from the hue hub or light components:
Are you polling via hue API via the RESTful sensor?
Or this custom component?
Or some other method?
Trying to work out what is the current best practice for these remotes…
Thanks for the inputs…
I’m using the Hue custom component.
Seems to work well.
Just couldn’t get that code going!
Putting the recurring part into the editor only seemed to work with brightness, and not brightness_pct.
I’ve now run out of time for a while, so I’ll have to shelve this one for a while.
Thanks for your help though!!
BTW I used a brighness script with my xiaomi buttons - hold to cycle brightness up and down and release to keep.
Actually its a bit unreliable, so does not get used much.
alias: "Brightness lights"
sequence:
- service: homeassistant.turn_on
entity_id: light.hallway
data_template:
transition: 1
brightness: '{% if states.light.hallway.attributes.brightness%}{{(states.light.hallway.attributes.brightness+25)|min(255)}}{% else %}25{% endif %}'
- service: script.turn_on
entity_id: script.brightness_lights_temp
brightness_lights_temp:
sequence:
- delay: '00:00:01'
- service: script.turn_on
entity_id: script.brightness_lights
This is the trigger:
# Click and hold dimmer
- alias: "Brightness Downstairs Lights Button"
trigger:
- platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d0000eff19a
click_type: long_click_press
condition:
- condition: state
entity_id: light.hall_by_front_door
state: 'off'
- condition: state
entity_id: light.hall_by_kitchen
state: 'off'
action:
- service: homeassistant.turn_on
entity_id: script.brightness_lights
- alias: "Brightness Downstairs Lights Button Stop"
trigger:
- platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d0000eff19a
click_type: hold
condition:
action:
- service: homeassistant.turn_off
entity_id: script.brightness_lights
- service: homeassistant.turn_off
entity_id: script.brightness_lights_temp
I’ve been using the custom component and loved it, but recently I noticed some advances in the inbuilt ZHA Component and I have successfully added the Hue Dimmer Switch using HA’s native ZHA component.
It shows as a binary_sensor.xxxx
for On / Off and there is an attribute to the sensor of level
that changes when the dimmer buttons are pressed (from 0 to 255 in 10% blocks).
I am a relative newbie, and if this needs a new thread, then feel free to shut me off .
I was wondering if anyone new how to write the automation template that would allow me to use the binary sensor and the level attribute of this sensor in HA to control an entity.
Hi all, new on home assistant.
Can I use hue switch to dimmer a dumb light and how will I achieve that?
Thanks?
@rickdubra
The only way you could use a Hue dimmer to dim a “Dumb Light” at the moment is to add a smart dimmer switch, like a Aeotec Nano-Dimmer or the like. It doesn’t need to be Z-Wave, there are other options. Z-Wave is just my preferred choice for smart switches at this time.
Then you would write an automation to use the button presses on the Philips Hue Dimmer to do the functions you want. I have not got any examples at this stage as I am not using the dimmers to dim, just as a 4 button controller.
As of writing this, the ZHA Component exposes the Hue Dimmer as a binary sensor with a level attribute.
The custom component mentioned exposes the buttons as sensors and you can do virtually anything with them in automations. With the custom component, you will need a Hue Bridge and for your hue devices to be connected to Home Assistant via the Hue Bridge
Just remember that to control any “dumb” device, you’d need some kind of smart switch wired in to control it
Thanks for for clarifying, what should be the best approach without breaking the bank?
1 Can Xiaomi zigbee light switches dimm dumb lamps.
2. Xiaomi Philips Zhirui can be dimmed by any switch or just the app?
3. There is any solution on z-wave or zigbee to achieve that integration otherwise will have to go with modules.
Thanks.
Hi Brendan, did you solve the problem, how to use the level attribute of hue dimmer?
I have a dimmer and hue bulb connected by a zigbee pen to HA só i would ned to associate the two…
I haven’t had a lot of time recently to play with it. It will be just a matter of writing a template to use the attribute I am sure.
The time I have spent on HA lately has been updating configs to work with the latest version after all the changes.
I might have another look at this soon.
Also keen to see if you’ve found a way.
This is what I use, repeated double clicks cycle through a range of dimnesses.
- id: dblclick Dining
alias: dbl click dining
trigger:
platform: event
event_type: deconz_event
event_data:
id: double_switch_1
event: 2004
action:
- entity_id: light.dining_room
data_template:
brightness: >
{% if is_state('light.dining_room','off') -%}
30
{%- else -%}
{% if ( states.light.dining_room.attributes.brightness + 75) > 255 -%}
0
{%- else -%}
{{ states.light.dining_room.attributes.brightness + 75 }}
{%- endif %}
{%- endif %}
service: light.turn_on