Set/Force Input number state to "null"

I am trying to clear an input_number data field in a dashboard so I don’t have to delete the previous value to enter a new one.

The only way I was able to do it is to set back the state to “null”.
It does work perfectly in the dev tools “set state” (was previously set to “777”):

But unfortunately, a script or automation won’t accept anything else than a float.
(below returns "expected float for dictionary value @ data[‘value’] " )

service: input_number.set_value
target:
  entity_id: input_number.winamp_playlist_play
data:
  value: "null"

Since I have confirmation that the system can do it, is there a way to emulate the devtools, “force” a “null” value as a state, or revert the input_number to it’s “initial” value (which is also “null”).

Thank you!

That’s not indicative of success. That tool will allow you to write almost anything to an entity’s state value.

The arbitor of valid/invalid values are the entity’s service calls. As you have discovered empirically, you can’t set an Input Number’s state to null.

Thanks,
was hoping there was some “brute force” command to emulate what the dev tool permits.
Will keep on deleting those zeros I guess…

Or use an input_text to keep a number ))).

Great idea :point_up_2:. Should work indeed. Will test and report back.

What is your application’s requirement? Does the value you need to store have to be modifiable via the UI?

If not, then a Trigger-based Template Sensor may be the better choice.

Input_text did work :+1: Thanks for the pointer.

@123 The data has to be to modifiable via the Dashboard.
The data field is a jukebox style field for guests to select songs from a playlist.
The input_text works for this purpose.

Thanks to both of you.

How were you originally planning to have your guests use the Input Number helper? Were they supposed to enter a number?

So now they enter the number in an Input Text helper?

Yes, screenshot below, bottom right.

With input_number the best I could do is leave a “0” as default;
now I just add float(0) to previous templates and send a " " to clear the field.

Wall tablet Winamp/Wacup frontend with limited control for guests.

That would have been my first choice as well. The 0 serves as a visual cue, for the user, of what’s expected in that field. Given a list of numbered choices, 0 is an intuitive ‘non choice’. In addition, an Input Number automatically constrains the user’s input to a numeric value.

Now that you have switched to an Input Text, be sure to use its pattern option to restrict input to integers and an empty string (otherwise, by default, Input Text allows for any characters).

Thanks for the tips;
The “0” didn’t really feel intuitive.
Though it would accept “0123” as an input for 123, you didn’t know if you had to delete it or why it was there… Will test with guests and see how it goes.
l kept the previous code in case I change my mind :smile:
Cheers.