Setting input min and max number using another input number

Wrong.

As I explained in my previous post:

Ahh, okeiii thankyou very muchh

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.

okeiii donee

While I wouldn’t recommend doing so for most users… If you absolutely need dynamic max, min, or step variables you can use a Template Number entity instead of an Input Number helper.

Maybe can you give me the example what should I do? Because I’m beginner in using home assistant, thankyouu

To avoid the dreaded XY problem, it might be more beneficial for you if you explain what you are trying to accomplish in a broader sense rather than asking about a specific method. There may be more appropriate integrations or other tools than number-type entities.

Describe the end goal.

I need to make 2 input number :

  1. Max_watt_house
  2. Max_watt_use

I want to give limit for the input Max_watt_use which is 90% of the Max_watt_house

In example if the user input 1000 for Max_watt_house. Then when the user want to input Max_watt_use there is limit, so the user only can input 0-900 for the Max_watt_use

I don’t know what you did, but it didn’t put a Solution tag anywhere.

However, it no longer matters because, as long as you don’t mind changing at least one of the two Input Numbers to a Template Number, you’ll get the ability to adjust its min/max values.

I leave you in the capable hands of Didgeridrew.

Step 1: Set up an Input Number to use as a place to store the state of your Template number. For purposes of the rest of this example I will use input_number.max_watt_save. When you set up your helper, set the min and max to the widest acceptable limits that you would ever use. Remember, this is just a storage helper.

Step 2: Set up your Template number in your configuration.yaml or templates.yaml file.

template:
  - number:
      - name: Max Watt Use
        state: "{{ states('input_number.max_watt_save') }}"
        set_value:
          - service: input_number.set_value
            data:
              value: "{{ value }}"
            target:
              entity_id: input_number.max_watt_save
        step: 1
        min: 0
        max: "{{ states('input_number.input_watt_house') | int * 0.9 }}"
        availability: "{{ states('input_number.input_watt_house') | is_number }}"

Can you please check my code, maybe there is something wrong? Because it doesn’t work. I code this in configuration.yaml which is in studio code server

because when input_max_watt_penggunaan > input_watt_rumah does not appear red against input_max_watt_penggunaan

image

I don’t understand what you mean by the above statement.

Things to check…

Did you restart/reload HA so your number entity gets instantiated?
The entity you will want to use in the frontend will be number.max_watt_use, not input_number.input_max_watt_penggunaan. You have set input_max_watt_penggunaan
to be your storage helper…

Haiiii, sorry for late reply… Thankyouu, it works, it’s my fault, i use the wrong helper in my overview, thankyou once againn

Hai, sorry, i want to ask again. i don’t why sometime when i change input_watt_rumah the slider max watt use change to input number like this

Try setting the mode of the number entity to the kind you want using Manual Customization.

sorry, i can’t get display mode setting

I don’t understand what you are talking about… Manual customization is something you do in your configuration.yaml file.

  1. Open your configuration.yaml file
  2. Find the homeassistant: configuration key. If you don’t have one, add it.
  3. Under the homeassistant: key add your customization. It should look something like:
homeassistant:
  customize:
    number.max_watt_use:
      mode: slider

Ohh okeii, it works. Thankyou very much

1 Like

Hello there,

i want to do almost the same as michael382:
“set input min and max number using another input number”
(or may be an teplate: sensor in the future)

Background:
I have a Wallbox and want to set the current state of charge (soc) of my car (manually cause my car has no wireless interface)

input_number.auto_links_soc_start

and I want to enter the soc up to which it should be loaded.

input_number.auto_links_soc_soll

It makes only sense if the second one is always above the first one.
So the min (and initial?) Value of the one custom:numberbox-card has to be an other input_number

As state-storage-helper i created

input_number.auto_links_soc_soll_min

I added this in configuration.yaml (i have not template.yaml !?)

template:
  - number:
      - name: min_soc
        state: "{{ states('input_number.auto_links_soc_soll_min') }}"
        set_value:
          - service: input_number.set_value
            data:
              value: "{{ value }}"
            target:
              entity_id: input_number.auto_links_soc_soll_min
        step: 1
        min: "{{ states('input_number.auto_links_soc_start') | int }}"
        max: 100
        availability: "{{ states('input_number.auto_links_soc_start') | is_number }}"

and this in a Lovelace Card:

  - type: custom:numberbox-card
    border: true
    entity: input_number.auto_links_soc_soll
    min: min_soc
    max: 100
    step: 1
    name: Ladung Soll %

In Studio-Code-Server I get in the configuration.yaml after “step: 1” and “max: 100” the error-message “Incorrect type. Expected “string”.”

May be i am to new to HASS to understand, but i would need a “Step 3” in you example, how to put the things in configuration.yaml, Lovelace and the Helpers to work together.
I guessed to enter “min_soc” as the value for “min:” in the numberbox card - but since it doesn’t work, maybe I guessed badly…
And why do i get errors in configuration.yaml?

Can you please help again?

“How to make things work together” is very broad question… that’s basically the question being asked by the totality of every thread on this forum :slight_smile:




It looks like you should be using min_entity instead of min:

  - type: custom:numberbox-card
    border: true
    entity: input_number.auto_links_soc_soll
    min_entity: number.min_soc
    max: 100
    step: 1
    name: Ladung Soll %

The rest of your post jumps around a lot and I can’t tell exactly where else you need help. Please clarify if you have any further questions.