My GE 14294 Dimmers have the annoying property of saving the brightness level when dimmed. I came up with the following automation which “worked” leveraging the double-tap (I made the group association to enable double click). Double-tap up worked to set the light to full brightness as desired, double-tap off doesn’t work… but while annoying I can live with that unless someone has a fix.
So I’m looking for help with two things:
How to make this also turn off the light all the way with a double click off?
How to modify this so to be a single automation that can be applied to every dimmer switch, individually? Meaning, I don’t want to control both office_ceiling and bedroom_ceiling (e.g. two different switches, I actually have about 10) at the same time… I just want to avoid having to make 10 duplicate automations, 1 for every switch. I tried making entity_id into a list, that broke it. It would need to listen to multiple events (for different entities), determine which one actually triggered it (via a filter?) and then run the action for only the triggering entity.
Have you tried just calling the light.toggle service with brightness 255 when the event fires?
I just tried this quickly here, and just tested it with my Z-Wave dimmers. Starting with the lights dimmed about 50%, the first service call turns off the lights and the next service call turns them back on at 100% brightness.
This way you don’t need to be very clever with the service template. Give it a try in developer tools / services with the light.toggle service and see.
Related, I have an automation like this:
- alias: dimmers to full brightness
initial_state: true
trigger:
platform: state
# if you enable the to: condition, then you'll miss changes in brightness made
# when lamp is already on. this only happens when changing brightness in hass
#to: 'on'
entity_id:
- light.lr_center_level
- light.lr_front_level
- light.lr_back_level
- light.kitchen_inside_level
- light.kitchen_center_level
- light.kitchen_outside_level
- light.parlor_level
- light.upstairs_office_level
- light.upstairs_hall_level
- light.blue_bedroom_level
- light.master_bedroom_level
- light.upstairs_steps_level
- light.attic_level
condition:
condition: template
value_template: '{{ (trigger.to_state is not none) and (trigger.to_state.state == "on") and
(trigger.to_state.attributes is not none) and ((trigger.to_state.attributes["brightness"] | int) < 255) }}'
action:
- service: light.turn_on
data_template:
entity_id: "{{ trigger.entity_id }}"
brightness: 255
that I use in the case I have non-dimmable LED lamps on a Z-Wave dimmer. If someone tried to turn on the light, but holds the toggle causing it to dim-up, this will set the brightness to 100%.
There’s a few problems with the way you wrote the automation:
You’re mixing zwave and light domain entities improperly.
You’re not using data_template properly.
You can’t call light.turn_off with the brightness option. Rather (believe it or not) you should call light.turn_on with brightness: 0. (Don’t feel too bad. I’ve seen a lot of people make this mistake.)
@lmamakos - I’ve tried to use light.toggle but I can’t seem to make it work, at least, not with a double-click. The light toggle seems to only work for a initiating the dimming, even when I set it for full brightness.
@pnbruckner - Your code worked great except for the condition which throws an error in home-assistant.log: [homeassistant.helpers.condition] Error during template condition: UndefinedError: 'zwave' is undefined
I’ve tried a bunch of different variations, and can’t make it work. I thought maybe: state_attr('group.all_lights_only','entity_id')
…would work based on this example, but no.
However, the below automation which is nice and compact seems to work fine with no condition at all. I guess that could work for now as I want the same behavior for all my dimmers. But I’m still curious if there’s a way to limit the triggering switches, ideally via a group. Did the code work for you?
Additionally, the double-click down/off dims like a single-click, with the normal slow transition. I was wanting/expecting immediate off like the double click on is immediate. I thought perhaps it was particular to my switches according to something else you said in another thread. But I tried both the Python and native scripts and neither worked. The normal scripts through errors even when replicated exactly.
For those following along… the following works for all switches for which I’ve enabled double-click via group association… normal dimming with a single click, double-click on goes to full bright, double-click off also dims slowly to off:
- id: double_tap_all_dimmers
alias: Double Tap All Dimmers
trigger:
- event_type: zwave.node_event
platform: event
action:
- data_template:
brightness: '{{ 0 if trigger.event.data.basic_level == 0 else 255 }}'
entity_id: |
{{ (states.light
| selectattr('attributes.node_id','eq',trigger.event.data.node_id)
| list
)[0].entity_id }}
service: light.turn_on
Sorry, that was a typo. I couldn’t test it in its entirety. I forgot to quote the entity_id’s in the condition. I’ll go back and fix my previous post.
The only reason I suggested the condition was because I didn’t know if you’d want to do this with all your dimmers. If so, then like you discovered, you can simply delete the condition.
When turning on to a particular level, it is quick. When turning on, but with no level specified (which makes it turn on to the level it was on last), it is slow. Also, turning off is slow. That’s just the default behavior of the dimmer. The only way, that I know of, to turn it off quickly is to change the rate config parameters in the dimmer (which you can do using the zwave.set_config_parameter service.)
And I tested changing the off value to 1 instead of 0, and you’re right it does work much quicker which is very annoying.
Am I missing something as simple as the right quotes here too? This would be pretty slick if it could be made to work (and I wanted to use double-click for a different purpose with a couple of the switches):
condition:
- condition: template
value_template: "{{ trigger.event.data.entity_id in state_attr('group.all_zwave_dimmers','entity_id') }}"
Sheesh, it’s like you’re looking over my shoulder pointing out all my obvious mistakes. Thank you, I think I’ll stop mucking with this one for a bit and call it solved. It’s all in one automation and nice and compact which makes me happy. Thank you @pnbruckner for all the help! For anyone else struggling here’s the final config:
automations.yaml
- id: double_tap_all_dimmers
alias: Dimmer Double Tap
description: Enable double-tap to set light to full brightness via triggering on zwave.node_event and checking the trigger.event.data.basic_level (255=on/0=off). Note pre-requisite z-wave node group association of switch to controller to enable double-tap. Additionally set the Z-Wave and Local Dim Rate/Step (I used 2 and 1 vs. the default of 3 and 1 for Local and 1 and 1 for Z-Wave) to speed things up.
trigger:
- event_type: zwave.node_event
platform: event
condition:
- condition: template
value_template: >
{{ trigger.event.data.entity_id in state_attr('group.all_zwave_dimmers',
'entity_id') }}
action:
- data_template:
brightness: '{{ 0 if trigger.event.data.basic_level == 0 else 255 }}'
entity_id: |
{{ (states.light
| selectattr('attributes.node_id','eq',trigger.event.data.node_id)
| list
)[0].entity_id }}
service: light.turn_on
But now I’m getting this error in my logs
2021-06-27 12:57:48 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: ‘dict object’ has no attribute ‘event’ when rendering '{{ (states.light
| selectattr(‘attributes.node_id’,‘eq’,trigger.event.data.node_id)
| list
)[0].entity_id }}
’
2021-06-27 12:57:48 ERROR (MainThread) [homeassistant.components.automation.refresh_dimmer_value] Refresh Dimmer Value: Error executing script. Error for call_service at pos 2: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘event’
2021-06-27 12:57:48 ERROR (MainThread) [homeassistant.components.automation.refresh_dimmer_value] Error while executing automation automation.refresh_dimmer_value: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘event’.