My float isn't a float

show_name: true
show_icon: false
type: button
tap_action:
  action: perform-action
  perform_action: input_number.set_value
  target:
    entity_id: input_number.originalvolume
  data:
    value: action: input_number.set_value
target:
  entity_id: input_number.originalvolume
data:
  value: "{{ state_attr('media_player.denon_avc_x3800h','volume_level') | float(0) }}"
entity: input_number.originalvolume
name: Set Original Volume
hold_action:
  action: none

When I press the button, I get an error about it expecting a float. But it’s being defined as a float, so I’m not sure what the issue is. I have a near-identical action as part of an automation, and it works fine:

action: input_number.set_value
target:
  entity_id: input_number.originalvolume
data:
  value: "{{ state_attr('media_player.denon_avc_x3800h','volume_level') | float(0) }}"

Currently the value passed from the tap_action is another action, which is definitely not a float. value: action: input_number.set_value is not valid. Also you can’t use jinja tamplates in most cards so that’s likely to fail as well.

What card are you using?

I don’t know what that means.

Button.

Everything inside the curly brackets {{ }} is a jinja template, definitely can not be used in the button card.

I recommend that you use the UI rather than yaml code to create cards until you better understand how how yaml and templates work.

1 Like

So how can I achieve what I’m trying to achieve here?

Set up a script that performs your templated action, then call that script in the button card’s action.

Something seems strange with your indentation. I don’t know what card this is, but what is this row: value: action: input_number.set_value

Maybe you mean something like this? (I am not sure what the other set of action and target in your code were meant for.)

show_name: true
show_icon: false
type: button
tap_action:
  action: perform-action
  perform_action: input_number.set_value
  target:
    entity_id: input_number.originalvolume
  data:
    value: "{{ state_attr('media_player.denon_avc_x3800h','volume_level') | float(0) }}"
entity: input_number.originalvolume
name: Set Original Volume
hold_action:
  action: none

That’s still invalid, since Button cards don’t support templates.

Are you sure?

I agree with that. In my suggestion above, I made everything using the GUI (just had to go yaml to paste in the entities I do not have).

Yes.

You can put whatever you want in the “Value” field and the card may look fine, but the action will fail because templates are not supported:

2 Likes

Positive, as Didgeridrew pointed out

I see. Sorry, didn’t test the whole way through.

That got the job done.