Hi folks, I’ve been struggling for hours without any progress, any help in the right direction would be greatly appreciated. The issue:
I’d like to have a horizontal stack card on my dashboard with 3 items: a ‘+’ button, a ‘-’ button and an indicator showing a value from 0 to 255. Each horizontal stack card is related to a single dimmable light. I’m trying to achieve a single dim-step up or down on a button press.
I’m using a horizontal stack card with a mushroom-template-card for each item in the stack card. The order of the items is shown in the screenshot.
The display is working perfectly. The buttons don’t work as expected.
The issues I’m having:
- the first section of the code below simply gets the current brightness and subtracts 1 from that value. It then makes sure the value is never lower than zero and returns the new value. That doesn’t work though. I get and error “Failed to perform the action light/turn_on. Expected int for dictionary value @ data[‘brightness’]”
- when trying a simpler approach, as shown in the third section, the light only responds when using a value higher than 1. And even then, the step is not exactly as it should be. For example: when using ‘brightness_step: 2’, the light increases 2 or 3 steps and usually stops responding after a few times of pressing the + button.
Your help would be greatly appreciated!
The code:
type: horizontal-stack
cards:
- type: custom:mushroom-template-card
icon: mdi:minus
layout: vertical
tap_action:
action: perform-action
target:
entity_id: light.keuken_tafel
perform_action: light.turn_on
data:
brightness: >
{% set current_value = state_attr('light.keuken_tafel', 'brightness') %}
{% set new_value = current_value - 1 %}
{% if new_value >= 0 %}
{% set new_value = 0 %}
{% endif %}
{{ new_value|int }}
hold_action:
action: none
double_tap_action:
action: none
icon_color: ""
multiline_secondary: false
fill_container: false
- type: custom:mushroom-template-card
secondary: "{{ state_attr(\"light.keuken_tafel\", \"brightness\")}}"
entity: light.keuken_tafel
badge_icon: ""
layout: vertical
hold_action:
action: none
double_tap_action:
action: none
tap_action:
action: none
icon_color: ""
icon: ""
primary: Keukentafel
- type: custom:mushroom-template-card
icon: mdi:plus
layout: vertical
tap_action:
action: perform-action
target:
entity_id: light.keuken_tafel
perform_action: light.turn_on
data:
brightness_step: 1
hold_action:
action: none
double_tap_action:
action: none
icon_color: ""
multiline_secondary: false
fill_container: false