Hi,
I wanted to share my solution to this problem which is a little different. And get some feedback on how to improve it.
I have a Z-wave Wall Light Switch with Dimmer (Leviton DZ6HD:Amazon.com ). This controls two scones in the wall and with automation, also controls a floor lamp that is connected to a Minoston Z-wave Plug with Dimmer (Amazon.com). Through home assistant, I use the Wall Light Switch to control the on/off of the scones and the lamp, and to keep the brightness levels in sync. I then bought 2 Philips Hues Smart Bulbs that I put into the scones. I already have a Hub and added them to the hub. I created a zone for the two bulbs.
My goal was:
1. To be able to use both home assistant and the wall switch to turn the Scones with the bulbs on and off
2. To be able to use both home assistant and the wall switch to set the brightness
Challenges:
The biggest challenge, as most know, is that using the wall switch dimmer reduces power to the bulbs and then at some point the Hue bulbs will cease to function. So I needed to limit how low a person could set the dimmer using the wall switch.
Solution:
• The Leviton switch has the ability to set the minimum dim level, and, using z-wave device configuration, I set it to 50%. This means that using either the physical dimmer or the HA entity for it, I can’t set the brightness level below 127.5 (half of 255). That being said, on the wall switch, I can still move the dimmer values up and down. To the person touching it, they can’t tell zero is close to 127.5.
• I created a Template Light (Template Light - Home Assistant) that is a combination of the Wall Switch and the Hue Bulbs. I used the on/off for the wall switch and the dimmer change using it. As you can see in my example, I translated the Wall Switch brightness values from 127.5 to 255 to reflect 0 to 255
• I created an automation so that whenever the Wall Switch brightness values are changed I update the Hues Bulb and the Floor Lamp. I set it to Restart Mode in case you press the dimmer switch too quickly (does that make sense?)
• I will probably replace the Lamp with a Hue Bulb and that will simplify my solution as I can just add the Bulb to the existing Zone, but as of now I have a separate smart plug to control the floor lamp
Issues Requesting Solutions / Feedback in General:
• Everything stays in sync as long as you don’t use the Hue App to change the brightness. If you change it, the Template Light entity shows the right value, but the Wall Switch won’t.
• The response time between touching the dimmer on the wall and see the bulbs update (brightness change) is slow
• I can’t get effects to load for the Hue Philips Zone. I believe there should be a colorloop and randomcolor?
• With the transition variable, if it isn’t used I get a transition is undefined error so I add some error handling. Is this best practice?
• Is there a better way to this or any other suggestions?
Here are the details of my solution:
Entities:
• light.living_room_foyer_bulbs → this is the Hue Philips Zone with 2 bulbs in it
• light.foyer_light → this is the Leviton Z-wave Wall Light Switch with Dimmer
• light.living_room_floor_lamp → this is the Minoston Z-wave Plug with Dimmer
• living_room_foyer_light_swtich → this is the new Template Late (I know I misspelled switch in the entity id…)
Here is what I put in configuration.yaml
- platform: template
lights:
living_room_foyer_light_swtich:
friendly_name: "Living Room Foyer"
unique_id: "lights_template_from_wall_switch_and_hue_group_01"
supports_transition_template: "{{ True }}"
turn_on:
- service: light.turn_on
entity_id:
- light.foyer_light
- light.living_room_foyer_bulbs
- light.living_room_floor_lamp
turn_off:
- service: light.turn_off
entity_id:
- light.living_room_foyer_bulbs
- light.foyer_light
- light.living_room_floor_lamp
level_template: "{{ state_attr('light.living_room_foyer_bulbs', 'brightness') | int }}"
set_level:
- service: light.turn_on
data_template:
brightness: "{{ (brightness | float / (255-0)) * (255-127.5) + 127.5 }}"
entity_id:
- light.foyer_light
value_template: "{{ states('light.foyer_light') }}"
temperature_template: "{{ state_attr('light.living_room_foyer_bulbs', 'color_temp') | int }}"
set_temperature:
service: light.turn_on
data:
color_temp: "{{ color_temp }}"
entity_id: light.living_room_foyer_bulbs
color_template: "({{ state_attr('light.living_room_foyer_bulbs', 'hs_color')[0] }}, {{ state_attr('light.living_room_foyer_bulbs', 'hs_color')[1] }})"
set_color:
- service: light.turn_on
data_template:
entity_id:
- light.living_room_foyer_bulbs
hs_color:
- "{{ hs[0] }}"
- "{{ hs[1] }}"
transition: "{{ ( transition|default('0.00') ) | float }}"
# effect_list_template: "{{ state_attr('light.living_room_foyer_bulbs', 'effect_list') }}"
Here is the automation
description: >-
When the brightness on the Foyer Light Switch changes update the Hue Bulbs &
floor lamp brightness level. Multiple the brightness setting by a multiplier
since the switch is limited on the lower bound to avoid turning off power to
the Hue Bulbs due to brightness.
trigger:
- platform: state
entity_id: light.foyer_light
attribute: brightness
condition: []
action:
- service: light.turn_on
target:
entity_id:
- light.living_room_foyer_bulbs
- light.living_room_floor_lamp
data:
brightness: >-
{{ (255-0) * (state_attr('light.foyer_light', 'brightness') | float -
127.5) / (255-127.5) + 0 }}
mode: restart
Let me know what you think!