Hi, all!
I’m quite new to Home Assistant and I’ve just registered the account. I hope to be around.
At the moment I’m just experimenting with a simple setup in home assistant to dimm a light in my living room. The setup is HA → USB Zigbee → Zigbee dimmer → Lightbulb
I’ve added the required instances and it works as expected: I can switch ON/OFF the light and control the brightness. The only problem I have is the limits for min/max brightness are around 20-70% (anything below 20% doesn’t produce any light in the bulb, and anything above 70% won’t increase the brightness).
I’d like to make those limits more user friendly by adding a “virtual” entity to control the actual entity. So, I created the following template (I think that’s the proper name, apologies if it’s not):
- platform: template
lights:
hallway_pendant:
unique_id: foo
value_template: >-
{% if is_state('light.zigbee_dimmer_1', 'on') %}
on
{% elif is_state('light.zigbee_dimmer_1', 'off') %}
off
{% else %}
unknown
{% endif %}
turn_on:
service: light.turn_on
data:
entity_id: light.zigbee_dimmer_1
turn_off:
service: light.turn_off
data:
entity_id: light.zigbee_dimmer_1
level_template: "{{ state_attr('light.zigbee_dimmer_1', 'brightness') | float / 0.65 }}"
set_level:
service: light.turn_on
data_template:
brightness: "{{ state_attr('light.zigbee_dimmer_1', 'brightness') | float * 0.65 }}"
(don’t worry if the 0.65 factor doesn’t make any sense with my above definition of 20-70 limits, I just wanted to make a quick test)
Then, I create a card in lovelace to view/control both instances. Somehow, the virtual entity is reading all the data from the physical entity (ON/OFF state and brightness levels), and I can switch ON/OFF the physical light from the virtual instance but I can’t change the brightness level from the virtual entity. It simply ignores the value I dial.
Do you know what I’m doing wrong?