Updating a list of input_number entities

I have 6 input_number entities as input_number.temp_1 through to temp_6 set up as sliders to adjust 6 individual temperature points during the day.

I would like a button set up to increment ( and in time decrement) the temperature of all of the sliders by a small value instead of adjusting each one.

So far I have the button set up to adjust the first one

ramp_up:
  friendly_name: 'Ramp up'
  icon_template: mdi:thermometer-plus
  value_template: "{{ false }}" 
  turn_on:
    service: input_number.set_value
    data_template:
      entity_id: input_number.temp_1
      value: "{{ (states('input_number.temp_1') | float ) + 0.1 }}"
  turn_off: []

But I’m trying to find out how to increase all the input_number entities in one go by a small value. I thought of putting the input_number entities into a group and iterate through them but cant find anything in the community forum that is close to what I want to do.

From what I can gather, I need to create a ‘for loop’ with a variable to iterate and update through the input_number list.

Im not even sure if this can be done in a data_template or would I need to create a python script and call that from the button?

What you need is Counted Repeat to call the same service (input_number.set_value) six times. Your template will employ the repeat.index variable to identify which one of the six input_numbers it uses in each one of the six iterations.

It will look something like this:

turn_on:
- repeat:
    count: 6
    sequence:
    - service: input_number.set_value
      data:
        entity_id: "input_number.temp_{{repeat.index}}"
        value: "{{ (states('input_number.temp_' ~ repeat.index) | float ) + 0.1 }}"

Thats awesome and thank you for the links, I wasn’t aware of the count/repeat method so will read up on them.
I just felt after a day of searching the forum, it may not be possible and that it would be done in a python script, hence asking.

1 Like