Multiple input numbers entities with a min-max in common

I need to create about 15 input number entities that will act as set point to our eating system (I need to send those values via MQTT.
Is it possible to use a unique set of min-max-step values?
How can I send to MQTT those value as soon as they change?
Thanks!

min, max, and step options are specific to each Input Number you create.

If you want to create fifteen Input Number entities with the same values for min, max, and step then I suggest you configure them in YAML, as opposed to the UI, because you can easily duplicate (via copy-paste) one Input Numberā€™s configuration fifteen times.

You can publish an Input Numberā€™s value, to an MQTT topic, using an automation with a State Trigger. It will publish the value the moment it changes.

alias: example
trigger:
  - platform: state
    entity_id:
      - input_number.one
      - input_number.two
      - input_number.etc
    to:
condition: []
action:
  - service: mqtt.publish
    data:
      topic: your/topic/goes/here
      payload: "{{ trigger.to_state.state }}"

Yes, I was gonna do that in config files, I prefer that way, I feel to have more control.
Your code throw me the error Integration error: action - Integration ā€˜actionā€™ not found
It could be an indentation error, but Iā€™m just starting with this and I really canā€™t see the problem.

What if I want those values to also change based on a MQTT values?

Thanks a lot!

Do you have the MQTT integration installed and configured to connect to your MQTT broker?

I do and Iā€™m already using it.

Then Iā€™m not sure why the automation produced this error:

Integration error: action - Integration ā€˜actionā€™ not found

I entered the automationā€™s code on my system and it saved it without producing an error.

Post your automationā€™s code.

Here it is:


# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

#automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
#input_number: !include_dir_merge_list input_numbers  
input_number:
  setpoint_amministrazione:
    name: "Setpoint amministrazione"
    initial: 24
    min: 24
    max: 28
    step: 0.5


alias: example
trigger:
  - platform: state
    entity_id:
      - setpoint_amministrazione
    to:
condition: []
action:
  - service: mqtt.publish
    data:
      topic: office/setpoints/amministrazione
      payload: "{{ trigger.to_state.state }}"

mqtt:
#    light: !include_dir_merge_list lights/  #!include lights.yaml
#    cover: !include cover.yaml
    switch: !include switch.yaml
#    button: !include buttons.yaml
    sensor: !include_dir_merge_list sensors

OK, now the mistake is visible. You canā€™t simply drop an automation into configuration.yaml like that.

You should uncomment this line:

#automation: !include automations.yaml

For organization purposes, itā€™s best to store automations in a separate file.

I suggest you remove your automation, restart Home Assistant, then use the visual Automation Editor to create the automation.

When youā€™re in the Automation Editor, creating a new automation, switch the Editor into YAML mode, delete whatever you see displayed, then copy-paste the example into the Editor. click the Save button and it should save it without any errors.

Mmmā€¦I will do, but why?

With all due respect, itā€™s becoming apparent to me that you are a beginner because you are making fundamental errors while attempting to compose a basic automation. Thatā€™s why I recommend you use the Automation Editor. In visual mode, it guides you to avoid making basic errors. For example, this is an invalid entity_id

  - platform: state
    entity_id:
      - setpoint_amministrazione

I have not seen the code for automation.set_temp_slider but I know for a fact that thereā€™s no such service call as setpoint_amministrazione.set_value. The correct name is input_number.set_value. Once again, the Automation Editor, in visual mode, would have helped you avoid making that mistake.

Iā€™m definitely a beginner, sorry for not have pointed that out in the beginning.
About the second error, Iā€™ve just realized that was an old one (Iā€™ve removed it from my post i guess just as you were posting your reply, sorry).

I got the error: I didnā€™t realize that your code was an automation.
Iā€™ve put it under the automation and doesnā€™t throw any error now.
Thanks!

automation:
    alias: example
    trigger:
      - platform: state
        entity_id:
          - setpoint_amministrazione
        to:
    condition: []
    action:
      - service: mqtt.publish
        data:
          topic: office/setpoints/amministrazione
          payload: "{{ trigger.to_state.state }}"

No problem. Just follow my instructions posted here. You want your system to store automations in a separate file (automations.yaml). When you create automations with the Automation Editor, they will be automatically stored in that file.

  • Use the Automation Editor in visual mode to help avoid making basic errors whe creating modifying automations.

  • Use the Automation Editor in YAML mode for copy-pasting examples from the forum or when you become more familiar with the correct syntax for entities, service calls, Home Assistantā€™s scripting, etc.

The latest example you posted still has the wrong entity_id (it should be input_number.setpoint_amministrazione). You are also still saving the automation in configuration.yaml which isnā€™t the best long-term strategy for organization.

1 Like

Thanks a lot, it works!!!

I use to put everything in the configuration.yaml file at first and then, when everything works, I move the code in the different files (as I just did!).
This because sometimes I use wrong indentation orā€¦I donā€™t know what else and the code works in configuration.yaml but not in the single files, so first I solve the code errors (if there are) and then I move the code.
I guess that I can start writing the code directly in separate files!

Nowā€¦if you still have a bit of patience: how can I change that value from MQTT?

Thatā€™s a time-consuming way to compose error-free automations.

If you compose your automations in the Automation Editor, it will help you avoid making errors. Any errors you do make will be reported the moment you attempt to save the file. After you have saved it, you can switch the Editor to YAML mode and see the error-free YAML that was produced (a faster, better way for you to learn correct YAML syntax).

I know, but I had problems everywhere, not only in the automation! Buuuut I think that I will use the automation editor (I didnā€™t know it existed before you told me :see_no_evil:), it surely help!

Is it possible to use a variable for min and max of all the setpoints?

I donā€™t see anything in Input Numberā€™s documentation indicating thatā€™s possible.

If the YAML configuration of your 15 Input Numbers contains a lot of duplication, you can use the YAML feature called ā€˜Anchors and Aliasesā€™ to minimize duplication. Hereā€™s an example of its use for reducing the configuration of multiple light entities:

1 Like