Input helper number not a float?

Good one!

… but that didn’t help either.

This is the erroneous line, correct? Maybe addressing an input-helper is not supported.

Try

volume_level: {{ states('input_number.google_home_volume') }}

Yes, that is the line that gives me trouble. You’re suggestion is very creative. Tried it, but still a no go.

I’m puzzled by this, should be so easy.

The error message seems to be complaining about this line

data:
      value: "{{ state_attr('media_player.google_home_study', 'volume_level') | float }}"

As you stated the key is a float, but by putting double quotes around the template you turned it into a string I believe. Remove the double quotes and try that FWIW. Also, some key:value pairs will only accept a float, not a template, so not sure this will fix it. You could also try service_data: then your template.

HA stores all values as strings, you then have to convert them
Recently HA has been trying to ‘interpret’ dimensions from the values stored and convert them back but there are sometimes issues
You should always test in the template editor.

The question I have here from the above is how did you set up the input number and what it’s step value is compared to the values displayed in the template edit (you say you always test to) ie does it show 3.00 or just 3.0.?

data_template was deprecated in favor of data several versions ago.
data now serves the same function as data_template did.

No, in fact the double-quotes are required otherwise, without them, the entire line will be reported as an error.


The error message is complaining about volume_level expecting a float value but it failed to receive one. That’s obvious from here:

  - service: media_player.volume_set
    data:
      volume_level: input_number.google_home_volume. <---- This
    entity_id: media_player.google_home_study

m0wlheld had the right idea, just overlooked to wrap the template in double-quotes.

  - service: media_player.volume_set
    data:
      volume_level: "{{ states('input_number.google_home_volume') }}"
    entity_id: media_player.google_home_study
1 Like

Thanx for all the input and help. Much appreciated. Got it working with all the input you guys gave me.

Final working code :

var_test:
  alias: var test
  sequence:
  - service: input_number.set_value
    data:
      entity_id: input_number.google_home_volume
      value: "{{ state_attr( 'media_player.google_home_study', 'volume_level' ) | default(0) | float }}"
  - service: media_player.volume_set
    data:
      volume_level: 0.3
    entity_id: media_player.google_home_study
  - delay: 00:00:02
  - service: media_player.volume_set
    data:
      entity_id: media_player.google_home_study
      volume_level: "{{ states( 'input_number.google_home_volume' ) }}"
  mode: single

Thanx for your elaborate reply. Very much appreciated!

1 Like

You’re welcome!

You should know that marking your own post as the Solution is reserved for the situation where you actually solved it yourself.

It’s the custom of this community to mark the first post that offers, or leads to, a solution to the problem. Many people offered assistance and at least one of their responses provided a solution. That’s the post that should be marked with the Solution tag.

3 Likes

Oke, didn’t know that. I’ll keep that in mind.

So move the solution !

Oke, now that is a bit blunt.

I’m trying to find my way in this forum. If there is common decency on how to tag a solution I’ll oblige. But for now, I don’t even know what : ‘So move the solution !’ even means…

Taras already explained.
Each topic can have only one solution.
You can tick any post in the thread as the solution.
You did none of the work but ticked your own post as the solution.
Think about that.
If everyone ticked their own posts as solutions then why are the rest of us here ?
Besides it’s just polite to acknowledge someone’s efforts
Find the post that helped you most and tick that.
ie Move the ‘solution’

I really think you are too much after that solution tick. Let them do what they like, who cares. It’s not a lie that that post leads to the final solution for someone who doesn’t want to read the entire thread.

No, I didn’t even know I was in the running, Taras gave the full explanation and gave the most guidance. I have no problem with him or anyone else for that matter taking the win.

Let me actually read the thread again.

Back in a moment.

Edit: No, I definitely do not deserve the solution, but outline for me why you think, anyone but Taras, does ?

For me it’s not about winning, it’s about somebody coming to this thread and finding the solution as fast as possible. If you summarize in a post the solution and mark it, it’s ok to me. It’s not a matter of who deserves it or who doesn’t, it’s about putting things as simple as possible for other people who haven’t necessarily followed the whole thread or aren’t willing to.

it’s just as good if you mark Taras’ or yours

1 Like

That’s fair. So do you think if I deleted my post, the one that explains the cause of the problem and suggests how to correct it, new readers will understand all of that from the author’s post (the one that simply duplicates my suggestion)?

2 Likes

Your statement is logical and I generally agree but people just searching for a quick fix will ‘just’ take the quick fix and learn nothing as a consequence.

The reason our major support people answer the way they do is to positively encourage people to think and learn.
If the solution links to that same post then more will learn and the OP’s consequent implementation is usually just below.
This is the best of both worlds.

I don’t want to fall into insulting someone but, with all respect, it looks so childish. I’ve seen it several times in various threads before saying a word… battling for the solution mark. I’ll say nothing more about his, last words… Do as you please.

Perhaps you have misunderstood the purpose of marking a post with the Solution tag. It helps other users by identifying which topics have arrived at a satisfactory conclusion. The Solution post identifies the root cause and presents a means to resolve it.

It’s a handy aid when searching for answers to questions and is a suggested practice in the community guidelines document called: How to help us help you (see #21).

Many users overlook to perform this final step and I remind them to do so. On some occasions, they have marked my post and I have asked them to remove it and mark another person’s post because it was either first or better (or both).

To be clear, I only ask users to follow the community’s customs and never pressure them; ultimately, it’s their decision.

What is a regrettable practice is when the topic’s author copies someone else’s suggestion and then marks their own post as the Solution. They add nothing and only demonstrate their ability to duplicate a post. If I see someone repeat this behavior, I’m less motivated to provide them with assistance (because they can’t follow a simple community practice).

1 Like