Hi. I am doing some test yaml-ing and planning for an Olimex ESP32-POE-ISO that is going to serve as a controller unit for my DIY-music rack, ie audio sources, preamp, active xover, amps etc.
The main objectives are that I shall not have to switch on and off every gear separately and also in specific orders to avoid potential loud audible thumps if for example the preamp is turned off while amps are still on etc. So convenience and safety.
I have learned how to perform some Actions, for example to sequence on a series of output pins (they are on two daisy chained 74HC565 to get enough of them), and off in reverse order with on_click short and long and it works fine.
Now I am on to further modelling and creating conditions in the yaml, like for example checking if amps pins are off before allowing shutting down preamp pin.
And my first question are:
If I do an “on_click - switch.turn_on: pin x”, do I need to check if that pin already is on and do some if/else stuff, or will it just ignore the turn_on if it is already turned on?
No - that’s fine. The main reason you may use a template switch is that you could hide all the gpio switches from HA (internal: true), that would then allow you to control from Home Assistant as well as from the ESPHome device.
I managed to do a condition test. I need to get some logic into what shall happen in given situations pressing buttons for inputs like digital or vinyl and outputs like speakers or headphones. Shall it switch or turn off etc. The indentation rules are crazy to get a grip on. Any hints on how to think?