When I change any of those numbers, I need the value for the matching input_number to change to the previous value. i.e.
{% if 'input_number.number_1' == 'input_number.number_2' %}
'input_number.number_2' = "the old value from input_number.number_1"
{% elif 'input_number.number1' == 'input_number.number_3' %}
'input_number.number_3' = "the old value from input_number.number_1"
etc...
Not sure where or how this is done - Iād searched for some other examples, but came up empty. If thereās a better way to do this aside from input_number, Iām open to suggestions.
Thereās a potential for this system to perform an endless loop.
If you create a system where it detects a change to the value of any input_number, hereās what can happen:
It detects a change in the value of number_1.
It determines that the value of number_4 matches number_1.
It sets the value of number_4 to the previous value of number_1.
By changing the value of number_4, it immediately causes the process to repeat:
It detects a change in the value of number_4.
It determines that the value of number_13 matches number_4.
It sets the value of number_13 to the previous value of number_4.
By changing the value of number_13, it immediately causes the process to repeat:
It detects a change in the value of number_13.
It determines that the value of number_8 matches number_13.
It sets the value of number_8 to the previous value of number_13.
It will keep repeating until it cannot find a matching value in any of the 16 input_numbers.
Is that how you actually want it to work? (because thatās how it will work if you trigger on a change to any input_number)
You will have to explain what you are attempting to accomplish.
You created 16 input_numbers where each one is configured to support a number from 1 to 16. Thatās 16 x 16 = 256 possible combinations. EDIT far more than 256
How is all of that supposed to be used to āset the order for relays to executeā?
How many relays are there?
What is the desired pattern of enabling/disabling the relays?
I imagine a clumsy way to prevent chaining would be to use a boolean helper that would conditionally prevent a second change.
Detect a change in number_1 and set boolean to true
Determine number_2 matches
Change number_2 to previous number_1 and set boolean to false
This doesnāt seem like a reasonable solution, at least without considering alternates first.
Iāve got a 16 channel multiplexed relay designed for irrigation. Iāve configured 4 different potential daily schedules for each of the 16 zones along with the ability to disable/enable any of those zones for any particular schedule.
The basic logic for enabling days, zones, determining run times, and triggering the relays is nearly all complete, but I discovered a circular reference in determining the on/off times when the sequence is the same on two or more zones (obvious when looking at it after the fact). Aside from the circular reference, two relays at once wouldnāt work on the multiplexer nor would there be enough water pressure even if it did.
Front end is a work in progress, but getting there.
edit:
I should also mention, that Iāv seen Irrigation Unlimited in the HACS apps, but didnāt get the wife approval based on the lack of flexibility to make changes to the schedules etc from the front end.
How does that correlate with 16 input_numbers having one of 16 potential values each?
BTW, I was wrong about 16 x 16 = 256 combinations. Itās 1616 combinations. What is the need for this wealth of combinations?
EDIT
It dawned on me that it will be easy to suppress a ārepeating effectā without employing the input_boolean you suggested. The automation simply needs to use the default mode: single and that will ignore attempts to execute it again while itās already executing.
Fairly basic:
16 irrigation zones - each with itās own valve controlled by a relay.
The order in which each valve is opened during the schedule and the flexibility to change that order based on desire/need/whatever else.
The input_number only determines the sequence (order) that the particular zone is run during the schedule. The input_boolean is what is being turned on/off at a particular time (determined by the schedule/sequence).
Defined sequences are what I currently have. Just looking for the flexibility to change those sequences. I wasnāt sure if someone would have been able to suggest something other than the 1616 if statements that Iām aware that would have to be created. Itās unfortunately worse than that anyhow, since there are four different schedules.
I donāt see why you need a data structure capable of representing 1616 combinations to achieve that. It seems all the more needlessly complicated when you take in the fact you only intend to turn on one relay at a time.
Maybe I am failing to appreciate some aspect of your plan that makes 1616 combinations mandatory. Rather than waste your time trying to convince me of its necessity, Iāll step aside and allow someone else to help you (who needs no convincing). Good luck!