Min-Max input validation in UI

Hi HA community,

I have automations that use max_temp and min_temp values for work.
Each value is an different input_number configurable via UI.
My problem is that all works fine if min_temp < max_temp but if by error the values aren’t correct (min_temp > max_temp) the automations doesn’t work as expected.
I wonder if it is possible to validate the user input in some way?
For example, when changing the value of min_temp with the slider automatically set max_temp to a higher value if min_temp reaches max_temp. And doing the reverse when setting max_temp.

The other option is to change automations to check the values and take into account the error condition, but i think is much better to do input validation first. Keeps automations cleaner and if there are many automations, avoid to do many code changes.

I think it would be useful to have a helper of range type. With a min-max slider selector or something similar.

Thank you very much!

It sounds like you are creating a thermostat. Is that correct?

Some kind of

In that case you are probably better of using a gerneric thermostat and have HA control the automations.

Thanks for the reply.
It is possible that I could use the generic_termostate for my current purposes.
But I am doing the automations to learn how to develop in HA and in the future I would like to use this kind of min-max range for other variables than temperature (water level, awning opening angle, etc.).
So anyway I would like to know if it is possible to do what I was asking.
Thanks!

Fair enough!

alias: New Automation
description: ''
mode: single
trigger:
  - platform: template
    value_template: '{{ states(''input_number.max'') <= states(''input_number.min'') }}'
    id: change_max
  - platform: template
    value_template: '{{ states(''input_number.min'') >= states(''input_number.max'') }}'
    id: change_min
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: change_max
        sequence:
          - service: input_number.set_value
            data:
              value: '{{ states(''input_number.min'') | int }}'
            target:
              entity_id: input_number.max
    default: []
  - choose:
      - conditions:
          - condition: trigger
            id: change_min
        sequence:
          - service: input_number.set_value
            data:
              value: '{{ states(''input_number.max'') | int }}'
            target:
              entity_id: input_number.min
    default: []