Thanks for pointing me to this. But I fear that it does not help as the fans are kind of special: They have a common anode and a “cathode” for each of the directions. I just had a quick look at the documents to which you referred to. Perhaps it would be doable. But I fear it will become a total mess because I will have then for each fan and each condition to check if “internal” or “external” control is chosen.

Now my question: I would like to replace the electronics box by a new one based on an ESP32 and ESPhome. Reading the two switches using ADC gpios is no problem. My idea was to use global variables and if “independent/manual” mode is chosen (using a switch), to evaluate these global variables in a state machine, preferably using the lambda framework. But here I’m struggling.

Hi, I’m relatively new to ESPhome but I have already successfully created some instances carrying out rather simple jobs.

Ha 317vs ha317

Ha 317bearings

No problem, neither mine… I’m too tired to read your yaml right now, but maybe template number (min1, max 3) could be useful for your setup.

I would be looking at bringing as much of it into ESPHome as possible, including as much of the Home Assistant automations as makes sense.

I need to explain the background a bit more before I can ask my questions. More than a decade ago I built a control for the ventilation of my basement. It is basically in two parts: an electronics box with an Atmega328 running a simple state machine which receives its instructions via a couple of cables from a raspi on which a python program runs the real “control software” (which also a state machine - but it’s much easier to make changes to a python program than to reflash the Atmega). I want to replace the python program by an automation in HA, but that’s not the question here. The electronics box comprises the possibility to switch into an “independent”/“manual” mode where the very basic settings can be set using two switches having three states each. One controls three levels of “power”, the second allows to choose the fan directions (constantly a->b, constantly b->a or switching every few minutes between a->b and b->a). All in all, there are about 10 gpios to set depending on the state.

Image

Ha 317skf

I’m sorry, but I don’t have a schematic. Essentially, it’s just two switches of this kind (“Stufenwahl” and “Richtungswahl”) and an ordinary switch to switch between external and internal control (“modeswitch” in the yaml) and about 10 outputs.

I have to take some time and think about both ways of doing it. Just because the state machine has worked well so far does not mean it’s the only good solution.

The switches are three way switches with the following positions: 1 - short to ground 2 - in the middle of a voltage divider i.e. Vcc /2 3 - short to Vcc (Vcc = 3.3V) With an ADC I can determine all three positions as I get three clearly distinguishable readings (0V / 1.65V / 3.3V). I don’t know how to do it easily in another way and this worked with my old circuit. It was not too difficult to get this into the yaml.

So far, I programmed my entities by reading the documentation, looking for examples, coding, getting errors, (jumping back to start) until it worked as I desired.

Image

Ha 317adapter sleeve

It sounds like you want to control a fan that has three speed levels, some direction/oscillation settings, and maybe a few custom modes/routines.

Image