I’m relatively new to HA and ESPhome (I’ve been tinkering and playing with code snippets for about a year and a half), but I’ve been writing code for embedded and non-embedded systems for the best part of 20 years and covering around 10 different languages. Which means that I’m well aware that having the paradigms (or way-of-thinking) of a given system in your head when planning and coding will generally make the process smoother. Or to put it differently, trying to impose a different paradigm over the top of someone else’s will generally lead to messy code, or disaster. With that in mind…
I have an ESP8266 attached to two I2C GPIO extenders, which let it monitor the state of all the light switches in the house, and let it control a series of relays which turn on and off the corresponding circuits. At the minute this is all coded in an increasingly large and unwieldy YAML file. But yesterday my other half asked if the toilet light could be set on a timer as the kids keep leaving it on. But since we leave it overnight for them, the timer only needs to operate during the daytime. I have it working but the resulting code is getting messier. (Nested if statements + a script). It occurs to me that it would be great to have this option for all the circuits, and that in general, being able to reassign circuits or adjust time-outs from an interface, rather than in the code would be useful… and neater. I like hacking, but there’s no way my wife is going to learn YAML, and were we ever to sell the house it’d be great if we could sell to non-programmers!
My thinking is to create a bunch of Number and Binary (Is this even possible) objects which would be used to configure these settings. Another nesting of ifs would let me check for the configuration when reacting to a switch. All ideally in a similar manner to that of a Shelly 1 light switch controller, ie. exposed locally (via a web-interface) and hidden from HA to avoid clutter.
I know that parts of this are possible. I can imagine that saving the configuration between reboots might require some re-encoding of the data to avoid filling the small amount of available Flash. I also know that I could do this directly in C, but I honestly don’t want to invest the time and the maintenance responsibility and I like the out-of-the-box HA compatibility of ESPHome. So… is there some paradigm in HA world that I’ve missed which would fit this use-case or am I now way outside the box, looking in, and needing to bodge a solution using the (not quite the right) tools?
Thanks,
Jon