[Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

[Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#1 Post by Neoseb38 » 10 Mar 2025, 18:26

Hello everyone,

I need help creating an ESP Easy rule to automatically manage my pool filtration. Since I’m a beginner, I’m struggling to design a rule that integrates multiple essential functions. Here’s a summary of my needs:

1. How Pool Filtration Works

Filtration is crucial to keeping the water clean and preventing algae growth.

Why?

When the water temperature exceeds 12°C, the risk of algae growth increases (especially due to UV exposure).
Below 10°C, a reduced filtration time (e.g., 1h30) is sufficient to circulate the water and prevent stagnation.
Advanced Method – Abacus Curve:
Instead of using a simple formula (e.g., temperature/2), I’d like to use the "Abacus curve" method (like in Jeedom’s pool plugin) to optimize energy consumption and ensure effective filtration.
filtration_courbe-2.png
filtration_courbe-2.png (22.4 KiB) Viewed 4965 times
Example: A minimum duration of 1h30 at 10°C, adding 0.5 hours per degree above 10°C.

2. Hardware Setup and Devices
Here’s a breakdown of my installation, based on my JSON configuration:

Temperature Sensors:

Pool: Task “Temperature” (Name: Piscine) – Displays the pool water temperature.
Outdoor: Task “Temperature” (Name: Extérieur) – Used for display on the OLED screen.

Filtration Control and Other Features:

Filtration: Task Filtration on GPIO2 (value: EtatFiltration).
Heat Pump (PAC): Task PAC on GPIO12 (value: EtatPAC).
Lighting: Task Eclairage on GPIO4 (value: EtatEclairage).

Switches:

ModeAUTO: Task ModeAUTO (value: EtatModeAUTO) to toggle between automatic and manual mode.
InterON/InterOFF: Tasks InterOn and InterOFF (values: EtatInterON and EtatInterOFF) to force filtration ON or turn it OFF.
Filtration Duration Adjustment:

Two push buttons named boutonPlus and BoutonMoins (value: State) should allow increasing or decreasing the filtration duration in percentage (e.g., from 50% to 150%).

OLED Display (Task: OLED):

Line 1: "Pool Water: [Temperature#Piscine] °C"
Line 2: "Outdoor Temp: [Temperature#Extérieur] °C"
Line 5: "Mode: ..." (updated via a rule)
Line 6: "Filtration: ..." (ON/OFF via a rule)
Line 7: "Lighting: ..." (ON/OFF via a rule)
Line 8: "PAC: ..." (ON/OFF via a rule)
3. Desired Features
Automatic Filtration:

Filtration duration is automatically calculated based on the temperature using the Abacus curve (e.g., a minimum of 1h30 for T < 10°C, with +0.5h per degree above 10°C).
This duration, considered as 100%, should be adjustable via a multiplier.
Manual Adjustment via Buttons:

I want to increase or decrease the filtration duration in percentage (from 50% to 150%) using the boutonPlus and BoutonMoins buttons.
Anti-Freeze Protection:

If the temperature drops below a critical threshold (e.g., < 3°C), the pump must activate immediately to prevent pipes from freezing, even if it’s outside the normal filtration cycle.
Power Outage Safety:

Option 1: On restart, the ESP turns off the pump for safety and recalculates the filtration cycle if the reboot happens after the expected start time (even if it results in extra filtration, which is acceptable).
Option 2: Memory Storage – To avoid losing data during a power outage, I want to save the calculated filtration duration in non-volatile memory. The idea is to store this value once per day, so the system can resume its cycle normally after a reboot without requiring manual intervention.

Here’s my current functional code, but it lacks the ability to adjust filtration times via the Plus and Minus buttons, which I don’t know how to implement:

Code: Select all

//Boot
On System#Boot do
   oledframedcmd,6,"Filtration: OFF"  // Affiche "Filtration: OFF" sur l'écran OLED
   oledframedcmd,7,"Eclairage: OFF"   // Affiche "Eclairage: OFF" sur l'écran OLED
   oledframedcmd,8,"PAC: OFF"         // Affiche "PAC: OFF" sur l'écran OLED
   logentry,"Système démarré."        // Log: Système démarré
endon

// Sécurité ANTI-GEL
On Temperature#Piscine do
   if [ModeAUTO#EtatModeAUTO]=1 And [InterOFF#EtatInterOFF]=0 And [Temperature#Piscine]<=8
     GPIO,2,1                        // Active la filtration
     timerSet,1,30                   // Timer de 30 secondes
     oledframedcmd,5,"ANTI-GEL ON"   // Affiche "ANTI-GEL ON" sur l'écran OLED
     logentry,"Anti-gel activé."     // Log: Anti-gel activé
   endif
endon

// Début journée
On Clock#Time=All,19:00 do
  if [ModeAUTO#EtatModeAUTO]=1
    if [Temperature#Piscine]>8 and [Temperature#Piscine]<=10
      timerSet,1,30                   // Timer de 30 secondes
      GPIO,2,1
      oledframedcmd,9,"Filtration AUTO"  // Affiche "Filtration AUTO" sur la ligne 9
      oledframedcmd,10,"de 9h à 11h"     // Affiche "de 9h à 11h" sur la ligne 10
      oledframedcmd,11,"Total:"          // Affiche "Total:" sur la ligne 11
      oledframedcmd,12,"30 sec"          // Affiche "30 sec" sur la ligne 12
      logentry,"Filtration: 30s"      // Log: Filtration activée pour 30 secondes
    elseif [Temperature#Piscine]<=15
      timerSet,1,60                   // Timer de 1 minute
      GPIO,2,1
      oledframedcmd,9,"Filtration AUTO"  // Affiche "Filtration AUTO" sur la ligne 9
      oledframedcmd,10,"de 9h à 11h"     // Affiche "de 9h à 11h" sur la ligne 10
      oledframedcmd,11,"Total:"          // Affiche "Total:" sur la ligne 11
      oledframedcmd,12,"1 min"           // Affiche "1 min" sur la ligne 12
      logentry,"Filtration: 1min"     // Log: Filtration activée pour 1 minute
    elseif [Temperature#Piscine]<=20
      timerSet,1,90                   // Timer de 1 minute 30
      GPIO,2,1
      oledframedcmd,9,"Filtration AUTO"  // Affiche "Filtration AUTO" sur la ligne 9
      oledframedcmd,10,"de 9h à 11h"     // Affiche "de 9h à 11h" sur la ligne 10
      oledframedcmd,11,"Total:"          // Affiche "Total:" sur la ligne 11
      oledframedcmd,12,"1 min 30"        // Affiche "1 min 30" sur la ligne 12
      logentry,"Filtration: 1min30"   // Log: Filtration activée pour 1 minute 30
    elseif [Temperature#Piscine]<=25
      timerSet,1,120                  // Timer de 2 minutes
      GPIO,2,1
      oledframedcmd,9,"Filtration AUTO"  // Affiche "Filtration AUTO" sur la ligne 9
      oledframedcmd,10,"de 9h à 11h"     // Affiche "de 9h à 11h" sur la ligne 10
      oledframedcmd,11,"Total:"          // Affiche "Total:" sur la ligne 11
      oledframedcmd,12,"2 min"           // Affiche "2 min" sur la ligne 12
      logentry,"Filtration: 2h"       // Log: Filtration activée pour 2 heures
    elseif [Temperature#Piscine]<=28
      timerSet,1,150                  // Timer de 2 minutes 30
      GPIO,2,1
      oledframedcmd,9,"Filtration AUTO"  // Affiche "Filtration AUTO" sur la ligne 9
      oledframedcmd,10,"de 9h à 11h"     // Affiche "de 9h à 11h" sur la ligne 10
      oledframedcmd,11,"Total:"          // Affiche "Total:" sur la ligne 11
      oledframedcmd,12,"2 min 30"        // Affiche "2 min 30" sur la ligne 12
      logentry,"Filtration: 2min30"   // Log: Filtration activée pour 2 minutes 30
    elseif [Temperature#Piscine]>28
      timerSet,1,180                  // Timer de 3 minutes
      GPIO,2,1
      oledframedcmd,9,"Filtration AUTO"  // Affiche "Filtration AUTO" sur la ligne 9
      oledframedcmd,10,"de 9h à 11h"     // Affiche "de 9h à 11h" sur la ligne 10
      oledframedcmd,11,"Total:"          // Affiche "Total:" sur la ligne 11
      oledframedcmd,12,"3 min"           // Affiche "3 min" sur la ligne 12
      logentry,"Filtration: 3min"     // Log: Filtration activée pour 3 minutes
    endif
  endif
endon

// Fin du timer
On Rules#Timer=1 do
  GPIO,2,0                            // Désactive la filtration
  oledframedcmd,5,"Mode: AUTO"        // Affiche "Mode: AUTO" sur la ligne 5
  oledframedcmd,9," "                 // Efface la ligne 9
  oledframedcmd,10," "                // Efface la ligne 10
  oledframedcmd,11," "                // Efface la ligne 11
  oledframedcmd,12," "                // Efface la ligne 12
  logentry,"Filtration désactivée. Affichage nettoyé."  // Log: Filtration désactivée et affichage nettoyé
endon

// Sécurité - Fin de journée
On Clock#Time=All,19:58 do
  if [ModeAUTO#EtatModeAUTO]=1
    if [Temperature#Piscine]>8
      GPIO,2,0                        // Désactive la filtration
      logentry,"Fin de journée."      // Log: Filtration désactivée en fin de journée
    endif
  endif
endon

Code: Select all

// Affichage Filtration sur l'ecran
On Filtration#EtatFiltration do
   if [Filtration#EtatFiltration]=1
      oledframedcmd,6,"Filtration: ON"
   else
      oledframedcmd,6,"Filtration: OFF"
   endif
endon

// Affichage Eclairage sur l'ecran
On Eclairage#EtatEclairage do
   if [Eclairage#EtatEclairage]=1
      oledframedcmd,7,"Eclairage: ON"
   else
      oledframedcmd,7,"Eclairage: OFF"
   endif
endon

//Affichage PAC sur l'ecran
On PAC#EtatPAC do
   if [PAC#EtatPAC]=1
      oledframedcmd,8,"PAC: ON"
   else
      oledframedcmd,8,"PAC: OFF"
   endif
endon

Code: Select all

// Mode Auto/Manuel
On ModeAuto#EtatModeAUTO do
   // Ne change rien si en mode Forcé ou Arrêt
   if ([InterON#EtatInterON]=0 and [InterOFF#EtatInterOFF]=0)
      if [ModeAuto#EtatModeAUTO]=1
         oledframedcmd,5,"Mode : Auto"
      else
         oledframedcmd,5,"Mode : Manuel"
      endif
   endif
endon

// Mode Forcé (InterON)
On InterON#EtatInterON do
   if [InterON#EtatInterON]=1
      oledframedcmd,5,"Mode : Forcé"
      gpio,2,1  // Active la filtration
   endif
   if [InterON#EtatInterON]=0 and [InterOFF#EtatInterOFF]=0
      // Retour au mode précédent (Auto ou Manuel), mais ne désactive pas la filtration
      if [ModeAuto#EtatModeAUTO]=1
         oledframedcmd,5,"Mode : Auto"
      else
         oledframedcmd,5,"Mode : Manuel"
      endif
   endif
endon

// Mode Arrêt (InterOFF)
On InterOFF#EtatInterOFF do
   if [InterOFF#EtatInterOFF]=1
      oledframedcmd,5,"Mode : Arrêt"
      gpio,2,0  // Désactive la filtration
   endif
   if [InterON#EtatInterON]=0 and [InterOFF#EtatInterOFF]=0
      // Retour au mode précédent (Auto ou Manuel)
      if [ModeAuto#EtatModeAUTO]=1
         oledframedcmd,5,"Mode : Auto"
      else
         oledframedcmd,5,"Mode : Manuel"
      endif
      // Désactive la filtration uniquement en mode Arrêt
      gpio,2,0  // Désactive la filtration
   endif
endon
Any help or suggestions would be greatly appreciated. Thank you in advance!

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#2 Post by Neoseb38 » 10 Mar 2025, 18:29

In another post that was slightly drifting off-topic, TD-er provided me with a draft rule that I tried to update (Names and Values), as well as shorten the timers for testing. I also added screen displays to better see the plus and minus buttons, etc.

However, I couldn’t get the code to work, so I’m continuing my research.
I’m reposting the code here:

Code: Select all

// Initialisation au démarrage : Éteindre la pompe, charger les variables sauvegardées, démarrer les minuteries
On System#Boot do
  gpio,2,0           // Éteindre la pompe au démarrage (sécurité)
  
  if [adjust#GetLevel] < 0.5 OR [adjust#GetLevel] > 1.5
    config,task,adjust,SetLevel,1  // Multiplicateur par défaut (100%)
  endif
  looptimerset,1,60   // Vérifier toutes les minutes pour la filtration
endon


// Calcul des temps de filtration
On Clock#Time=9:00 do
  asyncevent,calculateFiltration
endon

On Clock#Time=0:00 do
   let,1,0 // Effacer les temps calculés
endon

// Vérifier toutes les minutes si la pompe doit rester allumée
On Rules#Timer=1 do
  // Vérifier si l'heure est déjà passée 9h (9 * 3600 = 32400 sec)
  if %unixday_sec% > 32400 and [int#1] = 0
    event,calculateFiltration
  endif
  
  if [Temperature#Piscine]<3  // Si la température < 3°C
    gpio,2,1         // Allumer la pompe (priorité anti-gel)
  else
    if %unixday_sec% > [int#2] and %unixday_sec% < [int#3]
      gpio,2,1           // Garder la pompe allumée
    else
      gpio,2,0           // Éteindre la pompe
    endif
  endif
endon


on calculateFiltration do
  // Calculer la durée de filtration (stockée dans var#1)
  Let,1,5400          // Durée minimale de 5400 sec si T < 10°C
  if [[Temperature#Piscine]] > 10
    Let,1,5400 + ([[Temperature#Piscine]]-10)*1800  // Ajouter 0.5h par degré au-dessus de 10°C
  endif
  
  // Appliquer l'ajustement
  let,1,[adjust#GetLevel] * [int#1]  
  
  // Calculer maintenant l'heure de début et de fin pour le pivot
  // Utiliser la variable %unixday_sec% pour obtenir le nombre de secondes de "aujourd'hui"
  // 14:00 est 3600 * 14 soit 50400 secondes dans la journée actuelle
  let,2,50400 - ([var#1]/2)  // heure de début
  let,3,50400 + ([var#1]/2)  // heure de fin
endon


// Augmenter le multiplicateur de 5% avec le bouton plus
On BoutonPlus#State=1 do
  if [adjust#GetLevel] < 1.45
    Let,10,[adjust#GetLevel]+0.05  // Ajouter 5%
    if [Var#10]>1.5       // Limite maximale : 150%
      Let,10,1.5
    endif
    config,task,adjust,SetLevel,[Var#10] // Sauvegarder le nouveau multiplicateur
  endif
endon

// Diminuer le multiplicateur de 5% avec le bouton moins
On BoutonMoins#State=1 do
  if [adjust#GetLevel] > 0.55
    Let,10,[adjust#GetLevel]-0.05  // Soustraire 5%
    if [Var#10]<0.5       // Limite minimale : 50%
      Let,10,0.5
    endif
    config,task,adjust,SetLevel,[Var#10] // Sauvegarder le nouveau multiplicateur
  endif
endon
I removed the OLED messages that weren’t displaying anything and put the code back. I only tried the dummy device.
Capture d’écran 2025-03-10 à 18.28.03.png
Capture d’écran 2025-03-10 à 18.28.03.png (572.4 KiB) Viewed 4963 times
Maybe my Dummy device, I don't know.
Last edited by Neoseb38 on 11 Mar 2025, 06:42, edited 1 time in total.

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#3 Post by TD-er » 10 Mar 2025, 20:23

I don't see a task using the "Level" plugin, only one called "Level" but using the Dummy plugin.

To set a value in a Dummy task, you need the command "taskvalueset"
However those values are not stored in flash and thus lost after a power cycle.

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#4 Post by Neoseb38 » 11 Mar 2025, 06:41

But yesssss, it's not like you haven't repeated it to me...
Capture d’écran 2025-03-11 à 06.40.58.png
Capture d’écran 2025-03-11 à 06.40.58.png (31.07 KiB) Viewed 4893 times
Like this?
But what do I need to fill in for the GPIO and Device Settings (Input Task...)?

Could you also explain to me roughly how your code works? I don't really understand everything. (I'm currently learning about let and var functions.)

And is what I'm trying to do actually feasible on ESP Easy?

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#5 Post by TD-er » 11 Mar 2025, 09:51

Sure it is doable, however it is a little more complex due to the different constraints and the need to do calculations in rules.
So might be a bit of a steep learning curve to do as first ESPEasy project, especially if you never did any programming before.

About the "Regulator" task (named "adjust")
It looks like you changed the output name to GetLevel
This is not what you should do, as this Regulator plugin allows for specific commands to get the actual setting.
The output (which was originally named "Output") is only the state of any coupled GPIO pin. Thus either "1" or "0".
The level (which you can set using "config,task,<taskname>,SetLevel,<value>" and get using [<taskname>#GetLevel]) is some parameter you can use to set a threshold.

Just an example to help you understand and hopefully give you some ideas how to simplify/improve your project :)
Purely hypothetical, but let's assume you have a pool, a pump and a thermometer. (like I said a hypothetical scenario :) )
You need to make sure the pool pump will run when the temperature drops below 3°C and you also don't want the pump to continuously turn on/off when the temperature switches between 2.9 and 3.0°C.
So what you need is some hysteresis to let the pump turn on when < 3°C and only turn off when the temperature > 4°C for example.

Now take a look at the documentation of the "Level" plugin: https://espeasy.readthedocs.io/en/lates ... #p021-page

It can operate a GPIO pin (e.g. to turn on/off a pump) and needs some task as input.
So what we can do here, is select the task with the temperature sensor as "Input Task".
If your task has multiple values (for example the Bosch BME280 has temperature, humidity and air pressure) you must verify the "Input Value" is set to the correct task value.

Then the "Setpoint" should be set to your trigger level, which is 3.0°C.
The "Hysteresis" (good explanation about what a hysteresis is in the "Level" plugin documentation I linked above) should be set to something like 1.00 °C (you need to find a compromise between least energy consumption and least wear of the pump)

The control of the output is "0" when the temperature is below the set setpoint and "1" when above.
However you need this inverted, so you should check the checkbox "Invert input" (a bit of a confusing name, as "Invert output" would make more sense)


You can also send this to your controller so you can also keep track of when the pump was turned on/off due to low temperature.


This Level plugin is the only one that can actually get/set a value which will be stored in the settings.
So that's why I suggested it for your adjustment setting.
However as you can see, you can also use it to simplify your rules a bit more as it can keep track of your anti-freeze requirement.

In the documentation of the Level plugin, there is also a few other commands listed: https://espeasy.readthedocs.io/en/lates ... -available

Like this one:
levelcontrol,Remote,[0|1]

This is actually an override, which does make the rules a lot simpler (I forgot about this feature)
What this does is that you can override the set "anti freeze" feature as just discussed by turning on the pump.

So the setup can be as simple as this:
- Configure your Level task and set it to directly operate the pump so it will control the pump directly based on the temperature.
- Calculate the pivot-point duration/start time/end time
- Call "<taskname>.levelcontrol,Remote,1" at the calculated start time
- Call "<taskname>.levelcontrol,Remote,0" at the calculated end time


Just ignore the rest for now.

So what you need are two "Level" tasks, named:
- "Pump"
- "Adjust"

The first one will be configured as described above.
The second one is just used to store the "adjust" factor (0.5x ... 1.5x)

At boot of ESPEasy:

Code: Select all

On System#Boot do
  gpio,2,0           // Éteindre la pompe au démarrage (sécurité)
  
  if [adjust#GetLevel] < 0.5 OR [adjust#GetLevel] > 1.5
    // Make sure the "adjust" task is set to a correct value between 0.5 and 1.5
    // If not, then set it to 1.0 (100%)
    config,task,adjust,SetLevel,1  // Multiplicateur par défaut (100%)
  endif
  
  // Set a looptimer which will trigger an event every minute (60 sec)
  // This event will be dealt with in the block: On Rules#Timer=1 do
  looptimerset,1,60   // Vérifier toutes les minutes pour la filtration
endon
The looptimer is just to make it easier to understand and more fail safe when the ESP rebooted.
However there are more elegant solutions, which may not be as simple to understand when just getting to know ESPEasy.


Now I will be calculating 3 values, which will be stored in variables #1, #2, #3
- Variable #1: Total duration to run the filtration
- Variable #2: Start time expressed in seconds of the current day
- Variable #3: End time expressed in seconds of the current day

First 2 rules blocks acting on a specific time, 9:00 to calculate the filtration duration and at midnight to clear the calculated duration.

Code: Select all

// Calcul des temps de filtration
On Clock#Time=9:00 do
  // Call the event to actually calculate the filtration duration
  asyncevent,calculateFiltration
endon

On Clock#Time=0:00 do
  // Clear the calculated duration, so we can check whether it was calculated for the current day
   let,1,0 // Effacer les temps calculés
endon
Now the actual calculation:

Code: Select all

on calculateFiltration do
  // Calculer la durée de filtration (stockée dans var#1)
  Let,1,5400          // Durée minimale de 5400 sec si T < 10°C
  if [Temperature#Piscine] > 10
    Let,1,5400 + ([Temperature#Piscine]-10)*1800  // Ajouter 0.5h par degré au-dessus de 10°C
  endif
  
  // Appliquer l'ajustement
  let,1,[adjust#GetLevel] * [int#1]  
  
  // Calculer maintenant l'heure de début et de fin pour le pivot
  // Utiliser la variable %unixday_sec% pour obtenir le nombre de secondes de "aujourd'hui"
  // 14:00 est 3600 * 14 soit 50400 secondes dans la journée actuelle
  let,2,50400 - ([var#1]/2)  // heure de début
  let,3,50400 + ([var#1]/2)  // heure de fin
endon
N.B. I removed the double [[...]] you had in the rules
You have task #10 called "Temperature" and the task value "Piscine"
However I strongly suggest to swap those as you could otherwise end up with multiple tasks with the same name when you later want to add another temperature sensor.
When you change those (thus task called "Piscine" and taskvalue "Temperature") make sure you also change those in the rules.
Thus [Temperature#Piscine] => [Piscine#Temperature]

The "let" command does store the result of the calculation in the given variable#.
And both [var#1] and [int#1] refer to the same variable, however the [int#1] notation is rounding the value to an integer number, where [var#1] can also contain decimals.


Now the block running every minute as we started the looptimer at boot of ESPEasy:

Code: Select all

// Vérifier toutes les minutes si la pompe doit rester allumée
On Rules#Timer=1 do
  // Vérifier si l'heure est déjà passée 9h (9 * 3600 = 32400 sec)
  if %unixday_sec% > 32400 and [int#1] = 0
    // Either ESP just booted ([int#1] = 0) or the calculated duration was reset at midnight
    // Calculate the filtration duration
    event,calculateFiltration
  endif
  
  if %unixday_sec% > [int#2] and %unixday_sec% < [int#3]
    Pump.levelcontrol,Remote,1  // Garder la pompe allumée
  else
    Pump.levelcontrol,Remote,0  // Éteindre la pompe
  endif
endon
As you can see, the pump control logic now has become much simpler as we directly address the pomp to manual override starting the pump.
When we set this to 0, we just hand over the control back to the "Level" task called "pump".
Meaning if the temperature is below our set minimum temperature, the pump will continue to run.
Or when the temperature is above the setpoint, the pump will turn off.

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#6 Post by TD-er » 11 Mar 2025, 10:05

When you understand this and have it working, we can look into setting the adjust value using buttons and implementing the 'Abacus curve'.
You probably have some formula for this, so we can have a look on how to extend the calculation to implement this.

There are probably more optimizations we can later implement, as the calculations are now done at 9am, however I think the pool will be warmer after 14, so we could dynamically extend/shorten the filtration duration based on the amount of energy put into the pool water during the day.
Just a matter of performing some integration over time of the temperature difference between pool water and outside temperature.
But that might be a bit too much to start with, however keep in mind this is all possible using rules and the recently added 'statistics' feature in ESPEasy :)

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#7 Post by Neoseb38 » 11 Mar 2025, 17:26

Wow, thanks again for all this valuable information.

If I understand correctly, the regulator plugin will allow you to compensate for possible power outages, to do without a rule for wintering and also to be able to increase or decrease the filtration times?
To do this, I need to create two "Regulator - Level Control" devices.

The first one that will be used for wintering and thus do without a dedicated rule.
The second one that will be used for adjustments using the plus and minus buttons.

Is that right?

If this is the case, I am in the process of creating it.
On the other hand (using a translator because I am French and trying to understand the codes etc. excuse my clumsiness) I did not understand everything for certain points.

Tell me where I am wrong:

I created two regulator - level control:
One that I named Hivernage (Wintering) with its settings.
Capture d’écran 2025-03-11 à 17.22.41.png
Capture d’écran 2025-03-11 à 17.22.41.png (205.32 KiB) Viewed 4826 times
Capture d’écran 2025-03-11 à 17.22.54.png
Capture d’écran 2025-03-11 à 17.22.54.png (190.12 KiB) Viewed 4826 times
It gets complicated for the second one: :D
I named it AjustFiltration and I activated the remote function. All the other settings, I did not touch them.
Capture d’écran 2025-03-11 à 17.30.47.png
Capture d’écran 2025-03-11 à 17.30.47.png (205.83 KiB) Viewed 4823 times
Capture d’écran 2025-03-11 à 17.24.25.png
Capture d’écran 2025-03-11 à 17.24.25.png (229.99 KiB) Viewed 4826 times
Capture d’écran 2025-03-11 à 17.24.35.png
Capture d’écran 2025-03-11 à 17.24.35.png (56.01 KiB) Viewed 4826 times
You tell me that I changed the output name to GetLevel and that it is not what I should have done, so I put everything back to default.
Finally, I saw that we could put a tank for the oled screen.
This is what I am missing to be able to send the information back to the screen because it is not easy to test without sending information back.

Finally, indeed, it will be necessary to review the calculation method based on the curve because I was MORE than wrong on the calculation (which by the way, I do not know)... Sorry.
Attachments
Capture d’écran 2025-03-11 à 17.24.10.png
Capture d’écran 2025-03-11 à 17.24.10.png (204.83 KiB) Viewed 4826 times

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#8 Post by Neoseb38 » 11 Mar 2025, 17:40

I renamed the task called "Temperature" and the task value "Pool" as you told me.

Here is the rule:

Code: Select all

On System#Boot do
  gpio,2,0           // Éteindre la pompe au démarrage (sécurité)
  
  if [AjustFiltration#Output] < 0.5 OR [AjustFiltration#Output] > 1.5
    // Make sure the "adjust" task is set to a correct value between 0.5 and 1.5
    // If not, then set it to 1.0 (100%)
    config,task,adjust,SetLevel,1  // Multiplicateur par défaut (100%)
  endif
  
  // Set a looptimer which will trigger an event every minute (60 sec)
  // This event will be dealt with in the block: On Rules#Timer=1 do
  looptimerset,1,60   // Vérifier toutes les minutes pour la filtration
Endon

// Calcul des temps de filtration
On Clock#Time=9:00 do
  // Call the event to actually calculate the filtration duration
  asyncevent,calculateFiltration
endon

On Clock#Time=0:00 do
  // Clear the calculated duration, so we can check whether it was calculated for the current day
   let,1,0 // Effacer les temps calculés
Endon

On calculateFiltration do
  // Calculer la durée de filtration (stockée dans var#1)
  Let,1,5400          // Durée minimale de 5400 sec si T < 10°C
  if [Piscine#Temperature] > 10
    Let,1,5400 + ([Piscine#Temperature]-10)*1800  // Ajouter 0.5h par degré au-dessus de 10°C
  endif
  
  // Appliquer l'ajustement
  let,1,[AjustFiltration#Output] * [int#1]  
  
  // Calculer maintenant l'heure de début et de fin pour le pivot
  // Utiliser la variable %unixday_sec% pour obtenir le nombre de secondes de "aujourd'hui"
  // 14:00 est 3600 * 14 soit 50400 secondes dans la journée actuelle
  let,2,50400 - ([var#1]/2)  // heure de début
  let,3,50400 + ([var#1]/2)  // heure de fin
endon

// Vérifier toutes les minutes si la pompe doit rester allumée
On Rules#Timer=1 do
  // Vérifier si l'heure est déjà passée 9h (9 * 3600 = 32400 sec)
  if %unixday_sec% > 32400 and [int#1] = 0
    // Either ESP just booted ([int#1] = 0) or the calculated duration was reset at midnight
    // Calculate the filtration duration
    event,calculateFiltration
  endif
  
  if %unixday_sec% > [int#2] and %unixday_sec% < [int#3]
    Pump.levelcontrol,Remote,1  // Garder la pompe allumée
  else
    Pump.levelcontrol,Remote,0  // Éteindre la pompe
  endif
endon

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#9 Post by TD-er » 11 Mar 2025, 17:56

Nope, you got it wrong... (edit: this is a reply to your earlier reply, not about renaming the temperature sensor)

First of all, why try to change the names before getting it to work?
Now you're introducing lots and lots of uncertainties as there can be some extra typing errors and it makes it harder to compare with the example.

Let's first completely ignore the adjustment factor as it apparently makes it way more confusing.

The adjustment "Level" task was only to keep the adjustment factor stored in the settings.
However you're now trying to also let this one control the GPIO pin which is absolutely not the intention.
There should be only 1 task controlling the GPIO to the pump and that's the first "Level" task.

So please forget the second Level task for now and only focus on the main "Level" task.

If you want to call it "Hivernage", that's fine.
Based on the screenshots, you need to set the "Setpoint" to 3.00 (degree C)
It looks like you also need to enable the "extended functionality" here to be able to use the "remote" command. (this should be added in the documentation)


The second "Level" task probably has a typing error in the task name, as you called it "AjustFiltration", where I'm missing a "d".
N.B. if you change these names, then all related names in the rules also need to change, so that's why I don't understand why you want to change so many things at once as it will be really hard to find the errors.
Just as a general tip when working with these kind of things: Try only to change 1 thing at a time and try to start making small parts work first.

This one does NOT control any GPIO, so the GPIO field should be left empty.
Also it does NOT need an input task. It ONLY needs to store the "Setpoint". Nothing else!


I also see a third screenshot of a task using a "Level" plugin, which is absolutely not needed right now.
So can you tell me what tasks are now present?
I don't know what I am looking at.

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#10 Post by TD-er » 11 Mar 2025, 18:03

Neoseb38 wrote: 11 Mar 2025, 17:40 I renamed the task called "Temperature" and the task value "Pool" as you told me.

Here is the rule:
[...]

Code: Select all

On System#Boot do
  gpio,2,0           // Éteindre la pompe au démarrage (sécurité)
  
  if [AjustFiltration#GetLevel] < 0.5 OR [AjustFiltration#GetLevel] > 1.5
    // Make sure the "AjustFiltration" task is set to a correct value between 0.5 and 1.5
    // If not, then set it to 1.0 (100%)
    config,task,AjustFiltration,SetLevel,1  // Multiplicateur par défaut (100%)
  endif
  
  // Set a looptimer which will trigger an event every minute (60 sec)
  // This event will be dealt with in the block: On Rules#Timer=1 do
  looptimerset,1,60   // Vérifier toutes les minutes pour la filtration
Endon

// Calcul des temps de filtration
On Clock#Time=9:00 do
  // Call the event to actually calculate the filtration duration
  asyncevent,calculateFiltration
endon

On Clock#Time=0:00 do
  // Clear the calculated duration, so we can check whether it was calculated for the current day
   let,1,0 // Effacer les temps calculés
Endon

On calculateFiltration do
  // Calculer la durée de filtration (stockée dans var#1)
  Let,1,5400          // Durée minimale de 5400 sec si T < 10°C
  if [Piscine#Temperature] > 10
    Let,1,5400 + ([Piscine#Temperature]-10)*1800  // Ajouter 0.5h par degré au-dessus de 10°C
  endif
  
  // Appliquer l'ajustement
  let,1,[AjustFiltration#GetLevel] * [int#1]  
  
  // Calculer maintenant l'heure de début et de fin pour le pivot
  // Utiliser la variable %unixday_sec% pour obtenir le nombre de secondes de "aujourd'hui"
  // 14:00 est 3600 * 14 soit 50400 secondes dans la journée actuelle
  let,2,50400 - ([var#1]/2)  // heure de début
  let,3,50400 + ([var#1]/2)  // heure de fin
endon

// Vérifier toutes les minutes si la pompe doit rester allumée
On Rules#Timer=1 do
  // Vérifier si l'heure est déjà passée 9h (9 * 3600 = 32400 sec)
  if %unixday_sec% > 32400 and [int#1] = 0
    // Either ESP just booted ([int#1] = 0) or the calculated duration was reset at midnight
    // Calculate the filtration duration
    event,calculateFiltration
  endif
  
  if %unixday_sec% > [int#2] and %unixday_sec% < [int#3]
    Hivernage.levelcontrol,Remote,1  // Garder la pompe allumée
  else
    Hivernage.levelcontrol,Remote,0  // Éteindre la pompe
  endif
endon
I did try to fix as many errors due to renaming as I could find.
But like I said, when renaming things all at once, before you even got things working is absolutely a bad idea as you have no idea what else has to change.
For example "pump" had to be changed to "Hivernage" and you also renamed the "GetLevel" to "Output" which was not correct.
I think I changed a few other things too, but forgot which those were.

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re : [Aide nécessaire] Règle facile ESP pour la gestion automatique de la filtration de la piscine

#11 Post by Neoseb38 » 11 Mar 2025, 18:38

I'm really sorry.
I tried to replace the names that I changed in the code and I didn't see everything...
I thought I was doing the right thing because it would be so much easier for me to find my way around and understand (with all this new information)

As for the second level task, I misunderstood (probably with the translator) your instructions:
So the setup can be as simple as this:
- Configure your Level task and set it to directly operate the pump so it will control the pump directly based on the temperature.
- Calculate the pivot-point duration/start time/end time
I also thought that this function would also control my plus and minus buttons to adjust the adjustment... ( :roll: )
I renamed it AjustFiltration because in French we say "Ajustage" (sorry again)
I removed the gpio and input task fields that I set to none.

I left the remote function.
Should I leave the setpoint at 0?

As for wintering, I add the "extended functionality" here to be able to use the "remote" command.
I didn't think I was doing anything wrong by setting the set temperature to 0°C, it's just that I preferred to set the right temperature right away (and I would even go down to -2 from experience) because over the years, I realized that running the pool as soon as it's 0 outside when the water is not even at 4°C was not very economical.

What I don't understand is how to test all this?
Is it possible to put a display on the screen to be able to see for example if my plus and minus buttons work etc...

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#12 Post by Neoseb38 » 11 Mar 2025, 18:54

Wintering works since it's 22.2 at home and if I put 23 in Setpoint, the relay turns on. At 22, nothing changes (Hysteresis) and 21 it turns off.

I think that given the time, it must also work because I can no longer activate my relay. (I reset the wintering to 0.
When I activate the forced mode of my switch (we'll have to correct that :D ), the relay turns on and off instantly.
Same with the command: gpio,2,1

if [Piscine#Temperature] > 10
Let,1,5400 + ([Piscine#Temperature]-10)*1800 // Ajouter 0.5h par degré au-dessus de 10°C
endif
temperature of 22.2 = 7.6h
pivot at 2 p.m.
It is 7 p.m., the relay must be off.

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#13 Post by TD-er » 11 Mar 2025, 20:36

You can also see the calculated variables #1, #2 and #3 on the system variables page at the top (only when they have been set)
And by holding the temperature sensor in your hands or press it to a cold beer, you can easily test how it toggles the relais when changing temperature.

This way you can easily see how it is working and also get a feeling of what to change to get a different result.
Well... as long as you don't finish those cold beers immediately during testing :)

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#14 Post by Neoseb38 » 11 Mar 2025, 21:20

You can also see the calculated variables #1, #2 and #3 on the system variables page at the top (only when they have been set)
Nothing for the moment, I'll see tomorrow after 9am?

To do this properly, I'll have to temporarily replace the pivot time calculation with minutes.
Indeed, waiting several hours to test won't be very practical :lol:

Then, I'll have to find a way to get as close as possible to the curve.

I found this:
Here is the calculation formula for the curve:
Capture d’écran 2025-03-12 à 06.26.15.png
Capture d’écran 2025-03-12 à 06.26.15.png (29.04 KiB) Viewed 4674 times
I find HERE:
https://domo.rem81.com/index.php/2022/0 ... pdaemon-2/

In any case, I'm very happy with this code and can't wait to confirm the tests for the future.
Thanks again for everything.

I know we're not there yet, but will it be possible to make all this work only when the auto mode is enabled? (interrupter)
Because for the moment, the code overrides my forced on and off filtration interrupter.

PS: Beers might indeed be a real problem :lol: :lol:

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#15 Post by Neoseb38 » 12 Mar 2025, 09:51

The formula works and fits well with the blue 100% curve.
However, you have to keep all the numbers after the decimal points, otherwise the result in hours will be very different.
Do you think this formula is feasible for espeasy? :shock:

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#16 Post by TD-er » 12 Mar 2025, 10:01

Sure, the floating point variables in ESPEasy are of type 'double'.
Meaning you have roughly 16 decimals to work with (compared to the 6 - 7 decimals of a 'float' type)

Just using variable #10 here as that one isn't used.

Code: Select all

let,10,[Piscine#Temperature]^3*0.00335
let,10,[var#10] - ([Piscine#Temperature]^2 * 0.14953)
let,10,[var#10] + ([Piscine#Temperature] * 2.43489)
let,10,[var#10] -10.1072859
And then your calculated value can be used in the rules (or on displays, or anywhere you need it) by referring to [var#10]

N.B. I used [var#...] here instead of [int#...] as we need to keep the decimals.

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#17 Post by Neoseb38 » 12 Mar 2025, 10:16

This is excellent news and a great step forward for my project 👏

I don't yet master the variables very well but I remember what you said for the differences between the Int and Var functions

I'm currently at work and I'll see all this tonight. At the moment, 9 a.m. having passed, my relay will have to be cut off around 5:30 p.m. given the temperature at home. (7 hours of filtration for pivot at 2 p.m.)

I will add his last lines of code to replace this one, is that right?

Let,1,5400 + ([Piscine#Temperature]-10)*1800 // Ajouter 0.5h par degré au-dessus de 10°C

Edit… I forgot that I had to put the result in second.

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#18 Post by TD-er » 12 Mar 2025, 10:58

I don't know what unit the formula is for.
If it is hours, then you simply need to multiply it with 3600 at the end.

And if it is intended to replace the original #1 variable, then you can just keep the time in hours in #10 and the duration in seconds in #1 like this:

Code: Select all

let,10,[Piscine#Temperature]^3*0.00335
let,10,[var#10] - ([Piscine#Temperature]^2 * 0.14953)
let,10,[var#10] + ([Piscine#Temperature] * 2.43489)
let,10,[var#10] -10.1072859

let,1,[var#10]*3600

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#19 Post by Neoseb38 » 12 Mar 2025, 11:08

Yes, I did 2 tests with temperatures 15 and 25 degrees and I find in result 3.5 and 9 which perfectly corresponds to the blue abacus curve (100%) of the beginning.
So it's a lot of hours and yes, you have to replace the initial calculation >10 because it's totally necessary (my fault)

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#20 Post by Neoseb38 » 12 Mar 2025, 12:11

To simplify my tests, if I multiply let,1,[var#10]*60 to have timers in minutes, it would be easier, right?

Let’s say I want to test between 6:00 PM and 7:00 PM. I would also need to reset, for example, at 5:50 PM (instead of midnight) and calculate the filtration time around 6:00 PM. Then, I set a pivot time at 6:30 PM.

Is this the right way to proceed?
Because working with full hours is complicated, especially with my job.

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#21 Post by TD-er » 12 Mar 2025, 12:28

Sure, you can simply change the multiplier to shorten the duration for testing.
And the 'pivot offset' (the "middle" of the pump duration) is also easy to find in your code.

If you're smart, you define those two (the factor and the offset) in the "On System#boot do" block and set them to an unused variable.

Just using some unused variable index, like 100 and 101:

Code: Select all

let,100,14*3600 // Pivot time of 14:00
let,101,60         // Use minutes instead of seconds
And then you replace 50400 in the rules with [int#100]
And
let,1,[var#10]*3600
with
let,1,[var#10]*[int#101]

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#22 Post by Neoseb38 » 12 Mar 2025, 14:52

Thank you again,
I assure you that I'm doing my best... my job is carpenter at the base 😂
I just do the temporary addition of your two lines (system boot) and the other two modifications and then I will only have to change the 14th of the pivot time for the desired time?
Will it be necessary to do a reboot to validate this?

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#23 Post by TD-er » 12 Mar 2025, 14:59

When you change the variables, you can do a reboot, or you can also give the following command in the command line field on the Tools page:

Code: Select all

event,System#Boot
And don't feel sorry, I don't have diplomas myself.
I'm also just doing what I think should make sense and every now and then it is very valuable to have someone new using the software without any tech background, so we can focus again at the "Easy" part of ESPEasy to make sure we don't loose our focus on that (important) part of the project.

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#24 Post by Neoseb38 » 12 Mar 2025, 16:25

I just got home (I haven't changed the rules yet).
The variables have appeared, but the filtration relay is off.
Capture d’écran 2025-03-12 à 16.22.18.png
Capture d’écran 2025-03-12 à 16.22.18.png (57.78 KiB) Viewed 4536 times
I'll try the new rule in a few minutes.

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#25 Post by TD-er » 12 Mar 2025, 16:38

Can you show your complete rules?
These values are strange, as it suggests the total duration is 1 sec.
Can you create a 'backup' of the settings file (tools page -> backup)
This will download a '.tar' file and your browser will ask you whether you like to keep this file as it is not a typical file type to download.
You need to approve this or else the file will not be downloaded.

Can you then send this file to me (do not publicly attach it here as it also contains your WiFi password)
You can send it via a direct message.

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#26 Post by Neoseb38 » 12 Mar 2025, 16:52

Damn, I modified the rule to implement what we were talking about earlier.

The rule I had earlier is the one you corrected by replacing the new tasks and values.

Did I misconfigure my Regulator - Level Control (AdjustFiltration) (again)?

Here's my new rule that doesn't work (I probably made a mistake).

Code: Select all

On System#Boot do
  gpio,2,0           // Éteindre la pompe au démarrage (sécurité)
  let,100,16.43*3600 // Pivot time of 16:43
  let,101,60         // Use minutes instead of seconds
  
  if [AjustFiltration#GetLevel] < 0.5 OR [AjustFiltration#GetLevel] > 1.5
    // Make sure the "AjustFiltration" task is set to a correct value between 0.5 and 1.5
    // If not, then set it to 1.0 (100%)
    config,task,AjustFiltration,SetLevel,1  // Multiplicateur par défaut (100%)
  endif
  
  // Set a looptimer which will trigger an event every minute (60 sec)
  // This event will be dealt with in the block: On Rules#Timer=1 do
  looptimerset,1,60   // Vérifier toutes les minutes pour la filtration
Endon

// Calcul des temps de filtration
On Clock#Time=9:00 do
  // Call the event to actually calculate the filtration duration
  asyncevent,calculateFiltration
endon

On Clock#Time=0:00 do
  // Clear the calculated duration, so we can check whether it was calculated for the current day
   let,1,0 // Effacer les temps calculés
Endon

On calculateFiltration do
  // Calculer la durée de filtration (stockée dans var#1)
  Let,1,5400          // Durée minimale de 5400 sec si T < 10°C
  if [Piscine#Temperature] > 10
    let,10,[Piscine#Temperature]^3*0.00335
    let,10,[var#10] - ([Piscine#Temperature]^2 * 0.14953)
    let,10,[var#10] + ([Piscine#Temperature] * 2.43489)
    let,10,[var#10] -10.72859

    Let,1,[var#10]*[int#101]   // Remplacement provisoire de ( Let,1,[var#10]*3600 ) pour les test en minutes
  
  // Appliquer l'ajustement
  let,1,[AjustFiltration#GetLevel] * [int#1]  
  
  // Calculer maintenant l'heure de début et de fin pour le pivot
  // Utiliser la variable %unixday_sec% pour obtenir le nombre de secondes de "aujourd'hui"
  // 14:00 est 3600 * 14 soit 50400 secondes dans la journée actuelle (remplacé provisoirement par [int#100])
  let,2,[int#100] - ([var#1]/2)  // heure de début
  let,3,[int#100] + ([var#1]/2)  // heure de fin
endon

// Vérifier toutes les minutes si la pompe doit rester allumée
On Rules#Timer=1 do
  // Vérifier si l'heure est déjà passée 9h (9 * 3600 = 32400 sec)
  if %unixday_sec% > 32400 and [int#1] = 0
    // Either ESP just booted ([int#1] = 0) or the calculated duration was reset at midnight
    // Calculate the filtration duration
    event,calculateFiltration
  endif
  
  if %unixday_sec% > [int#2] and %unixday_sec% < [int#3]
    Hivernage.levelcontrol,Remote,1  // Garder la pompe allumée
  else
    Hivernage.levelcontrol,Remote,0  // Éteindre la pompe
  endif
endon

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#27 Post by TD-er » 12 Mar 2025, 17:11

First thing I found :)

Code: Select all

  let,100,16.43*3600 // Pivot time of 16:43
That's not how you calculate a time to seconds :)

This is probably more like it:

Code: Select all

  let,100,16*3600 + 43*60 // Pivot time of 16:43

I'll have another look at the rest.

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#28 Post by Neoseb38 » 12 Mar 2025, 17:17

just in case:


Capture d’écran 2025-03-12 à 17.16.35.png
Capture d’écran 2025-03-12 à 17.16.35.png (182 KiB) Viewed 4511 times
Capture d’écran 2025-03-12 à 17.16.46.png
Capture d’écran 2025-03-12 à 17.16.46.png (195.89 KiB) Viewed 4511 times
Capture d’écran 2025-03-12 à 17.16.56.png
Capture d’écran 2025-03-12 à 17.16.56.png (150.87 KiB) Viewed 4511 times

PS: I can't send anything in PM.

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#29 Post by TD-er » 12 Mar 2025, 17:20

Missed an "endif" after checking the temperature > 10

Code: Select all

On System#Boot do
  gpio,2,0           // Éteindre la pompe au démarrage (sécurité)
  let,100,16*3600 + 43*60 // Pivot time of 16:43
  let,101,60         // Use minutes instead of seconds
  
  if [AjustFiltration#GetLevel] < 0.5 OR [AjustFiltration#GetLevel] > 1.5
    // Make sure the "AjustFiltration" task is set to a correct value between 0.5 and 1.5
    // If not, then set it to 1.0 (100%)
    config,task,AjustFiltration,SetLevel,1  // Multiplicateur par défaut (100%)
  endif
  
  // Set a looptimer which will trigger an event every minute (60 sec)
  // This event will be dealt with in the block: On Rules#Timer=1 do
  looptimerset,1,60   // Vérifier toutes les minutes pour la filtration
Endon

// Calcul des temps de filtration
On Clock#Time=9:00 do
  // Call the event to actually calculate the filtration duration
  asyncevent,calculateFiltration
endon

On Clock#Time=0:00 do
  // Clear the calculated duration, so we can check whether it was calculated for the current day
   let,1,0 // Effacer les temps calculés
Endon

On calculateFiltration do
  // Calculer la durée de filtration (stockée dans var#1)
  Let,1,5400          // Durée minimale de 5400 sec si T < 10°C
  if [Piscine#Temperature] > 10
    let,10,[Piscine#Temperature]^3*0.00335
    let,10,[var#10] - ([Piscine#Temperature]^2 * 0.14953)
    let,10,[var#10] + ([Piscine#Temperature] * 2.43489)
    let,10,[var#10] -10.72859

    Let,1,[var#10]*[int#101]   // Remplacement provisoire de ( Let,1,[var#10]*3600 ) pour les test en minutes
  endif
  
  // Appliquer l'ajustement
//  let,1,[AjustFiltration#GetLevel] * [int#1]
  
  // Calculer maintenant l'heure de début et de fin pour le pivot
  // Utiliser la variable %unixday_sec% pour obtenir le nombre de secondes de "aujourd'hui"
  // 14:00 est 3600 * 14 soit 50400 secondes dans la journée actuelle (remplacé provisoirement par [int#100])
  let,2,[int#100] - ([var#1]/2)  // heure de début
  let,3,[int#100] + ([var#1]/2)  // heure de fin
endon

// Vérifier toutes les minutes si la pompe doit rester allumée
On Rules#Timer=1 do
  // Vérifier si l'heure est déjà passée 9h (9 * 3600 = 32400 sec)
  if %unixday_sec% > 32400 and [int#1] = 0
    // Either ESP just booted ([int#1] = 0) or the calculated duration was reset at midnight
    // Calculate the filtration duration
    event,calculateFiltration
  endif
  
  if %unixday_sec% > [int#2] and %unixday_sec% < [int#3]
    Hivernage.levelcontrol,Remote,1  // Garder la pompe allumée
  else
    Hivernage.levelcontrol,Remote,0  // Éteindre la pompe
  endif
endon
I put this line in comments:
// let,1,[AjustFiltration#GetLevel] * [int#1]
Just to make sure this isn't causing an issue as we're now ignoring the adjustment factor.

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#30 Post by TD-er » 12 Mar 2025, 17:21

Ah it is good I put that adjustment factor in a comment, as you have set it to 0, not 1.
So for now we just ignore it. Something for later when the rest is working.

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#31 Post by Neoseb38 » 12 Mar 2025, 17:25

Ah it is good I put that adjustment factor in a comment, as you have set it to 0, not 1.
So for now we just ignore it. Something for later when the rest is working.
Are you talking about that?
Capture d’écran 2025-03-12 à 17.24.48.png
Capture d’écran 2025-03-12 à 17.24.48.png (43.91 KiB) Viewed 4499 times

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#32 Post by Neoseb38 » 12 Mar 2025, 17:39

Even with the corrected rule, nothing works.
I've changed the hour (and minutes :D ), but my relay remains off. In fact, it's impossible to turn it on (automatic mode or via command).

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#33 Post by TD-er » 12 Mar 2025, 17:47

Later this evening I will have a look at the settings you sent me via mail.

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#34 Post by Neoseb38 » 12 Mar 2025, 18:11

OK

Nothing to do with it, but:
Is it normal that I have to wait at least 3 to 4 seconds to navigate to the ESP Easy web page (device to rules, etc.)?
I'm connected to Ethernet (on Wi-Fi, I don't know why; it no longer wants to save the rules, whereas before it was connected to Ethernet, and you resolved this issue with an update).
ESP32 ETH01
Every now and then, he becomes super fast lol
I'm a little worried about him being in my pool shed lol
I'm 1 meter from my router.

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#35 Post by TD-er » 12 Mar 2025, 19:49

Without more information it is hard to tell if this is 'normal' behavior.

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#36 Post by Neoseb38 » 15 Mar 2025, 09:18

Hi, did you have time to take a look at my total filtration problem of 1 second?
Yes, no, no worries, take your time. Thank you again for your help.

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#37 Post by Neoseb38 » 26 Mar 2025, 18:45

I managed to make a little progress.

I realized that the Variable V10 was wrong and did not correspond to the calculation.

I searched on my side but I didn't understand.

I ended up asking the question to different AI (not hoping for much) and only GROK to find, and the first time.

Here are his words:

- The calculation of %v10% is not complete beyond the first step.

- The calculations of %v2% and %v3% are not applied, leaving these variables at their initial value.

After advising me to add logos, he confirmed this and then remade me a code that after checking the logos will be operational.

Here is the code:

Code: Select all

On System#Boot do
  gpio,2,0           // Éteindre la pompe au démarrage (sécurité)
  let,100,17*3600 + 30*60 // Heure pivot de 17h30 (63 000 secondes, personnalisable)
  let,101,60         // Utiliser des minutes au lieu de secondes pour les tests
  
  if [AjustFiltration#GetLevel] < 0.5 OR [AjustFiltration#GetLevel] > 1.5
    // S'assurer que la tâche "AjustFiltration" est réglée sur une valeur correcte entre 0.5 et 1.5
    // Sinon, la définir à 1.0 (100%)
    config,task,AjustFiltration,SetLevel,1  // Multiplicateur par défaut (100%)
  endif
  
  // Définir une boucle qui déclenche un événement toutes les minutes (60 sec)
  looptimerset,1,60   // Vérifier toutes les minutes pour la filtration
Endon

// Calcul des temps de filtration
On Clock#Time=9:00 do
  // Lancer l'événement pour calculer la durée de filtration
  asyncevent,calculateFiltration
Endon

On Clock#Time=0:00 do
  // Effacer la durée calculée pour vérifier si elle a été calculée pour le jour actuel
  let,1,0 // Effacer les temps calculés
Endon

On calculateFiltration do
  // Calculer la durée de filtration (stockée dans var#1)
  Let,1,5400          // Durée minimale de 5400 sec si T < 10°C
  if [Piscine#Temperature] > 10
    // Étape 1 : T^3 * 0.00335
    let,10,[Piscine#Temperature]^3 // Calculer T au cube
    let,10,[var#10]*0.00335        // Multiplier par 0.00335
    logentry,"v10 après étape 1=%v10%"
    // Étape 2 : - (T^2 * 0.14953)
    let,11,[Piscine#Temperature]^2 // Calculer T au carré
    let,11,[var#11]*0.14953        // Multiplier par 0.14953
    let,10,[var#10]-[var#11]       // Soustraire le résultat à var#10
    logentry,"v10 après étape 2=%v10%"
    // Étape 3 : + (T * 2.43489)
    let,11,[Piscine#Temperature]*2.43489 // Multiplier T par 2.43489
    let,10,[var#10]+[var#11]             // Ajouter le résultat à var#10
    logentry,"v10 après étape 3=%v10%"
    // Étape 4 : - 10.72859
    let,10,[var#10]-10.72859       // Soustraire 10.72859
    logentry,"v10 après étape 4=%v10%"
    // Calcul final de la durée avec facteur personnalisable
    Let,1,[var#10]*[int#101]   // [int#101] = 60 pour tests en minutes, 3600 pour heures
    logentry,"Durée calculée : v1=%v1%"
  endif
  
  // Calculer maintenant l'heure de début et de fin pour le pivot personnalisable
  let,11,[var#1]/2   // Calculer la demi-durée
  logentry,"Demi-durée : v11=%v11%"
  let,2,[int#100]-[var#11]  // Heure de début autour du pivot [int#100]
  let,3,[int#100]+[var#11]  // Heure de fin autour du pivot [int#100]
  logentry,"Heures calculées : v2=%v2%, v3=%v3%"
Endon

// Vérifier toutes les minutes si la pompe doit rester allumée
On Rules#Timer=1 do
  // Relancer la boucle toutes les 60 secondes
  looptimerset,1,60
  // Vérifier si l'heure est déjà passée 9h (9 * 3600 = 32400 sec)
  if %unixday_sec% > 32400 and [int#1] = 0
    // Soit l'ESP vient de démarrer ([int#1] = 0), soit la durée a été réinitialisée à minuit
    event,calculateFiltration
  endif
  
  if %unixday_sec% > [int#2] and %unixday_sec% < [int#3]
    Hivernage.levelcontrol,Remote,1  // Garder la pompe allumée
  else
    Hivernage.levelcontrol,Remote,0  // Éteindre la pompe
  endif
  logentry,"État pompe : %unixday_sec% entre v2=%v2% et v3=%v3%"
Endon
This is much better for the Abacus curve formula but I realized that the variable %v100% was also wrong.

Having exceeded the free time of grok :D I found that the error did not take into account the minutes for an example of 5:30 pm:
let,100,17*3600 + 30*60
By leaving it like this, all the variables seem to be ok.
let,100,17*3600
Capture d’écran 2025-03-26 à 18.50.17.png
Capture d’écran 2025-03-26 à 18.50.17.png (104.85 KiB) Viewed 3131 times
However, my gpio2 remains off despite everything.

Even when entering the order
gpio,2,1
The relay is activated and then deactivated instantly.

Ditto through my switch for forced walking.

The only way to activate it is to modify the set point so as to set a temperature higher than the temperature recorded in"Regulator - Level Control # Hivernage.

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#38 Post by Neoseb38 » 27 Mar 2025, 18:32

I succeeded and I will have struggled a lot.

The problem came from the temperature threshold of the level plugin that was set to 0.

So every time I tried to activate my gpio2 also controlled by this plugin, it did not work since the latter turned it off every time since temperature above 0.

So the rule couldn't work.

So I removed the gpio2 from the plugin level (Hivernage) and no more worries.

Then, and that's where I struggled, I had another problem with the rule.

I first replaced the commands:

Code: Select all

   if %unixday_sec% > [int#2] and %unixday_sec% < [int#3]
    Hivernage.levelcontrol,Remote,1  // Garder la pompe allumée
  else
    Hivernage.levelcontrol,Remote,0  // Éteindre la pompe
  endif
by

Code: Select all

   if %unixday_sec% > [int#2] and %unixday_sec% < [int#3]
    gpio,2,1  // Garder la pompe allumée
  else
    gpio,2,0  // Éteindre la pompe
  endif
However, it did not work.

The problem came from the command %unixday_sec%.

I ended up with a lag of 1 hour between the time of the esp32 and the time found.

Living in France, I thought about hourly takeoff. However, I have settled everything in espeasy and the NTP.
Capture d’écran 2025-03-27 à 18.27.04.png
Capture d’écran 2025-03-27 à 18.27.04.png (169.82 KiB) Viewed 2967 times
In short, after having fought well, I started on the %syssec_d% values that they do not change.

And there, it works:

Code: Select all

On System#Boot do
  gpio,2,0
  let,100,18*3600
  let,100,[int#100]+10*60  // 18h10
  let,101,60
  logentry,"Démarrage : v100=%v100%, syssec_d=%syssec_d%, unixday_sec=%unixday_sec%"
  event,calculateFiltration
  looptimerset,1,60
Endon

On Clock#Time=9:00 do
  asyncevent,calculateFiltration
Endon

On Clock#Time=0:00 do
  let,1,0
Endon

On calculateFiltration do
  Let,1,5400
  if [Piscine#Temperature] > 10
    let,10,[Piscine#Temperature]^3
    let,10,[var#10]*0.00335
    let,11,[Piscine#Temperature]^2
    let,11,[var#11]*0.14953
    let,10,[var#10]-[var#11]
    let,11,[Piscine#Temperature]*2.43489
    let,10,[var#10]+[var#11]
    let,10,[var#10]-10.72859
    Let,1,[var#10]*[int#101]
    logentry,"Durée calculée : v1=%v1%"
  endif
  let,11,[var#1]/2
  let,2,[int#100]-[var#11]
  let,3,[int#100]+[var#11]
  logentry,"Heures calculées : v2=%v2%, v3=%v3%"
Endon

On Rules#Timer=1 do
  looptimerset,1,60
  if %syssec_d% > 32400 and [int#1] = 0
    event,calculateFiltration
  endif
  logentry,"Verification : syssec_d=%syssec_d%, v2=%v2%, v3=%v3%"
  if %syssec_d% > [int#2] and %syssec_d% < [int#3]
    gpio,2,1
    logentry,"Pompe allumée : %syssec_d% entre v2=%v2% et v3=%v3%"
  else
    gpio,2,0
    logentry,"Pompe éteinte : %syssec_d% hors v2=%v2% et v3=%v3%"
  endif
Endon
I suspect that I should not have removed the gpio from the level plugin and that I no longer have wintering at the moment but at least it will have allowed me to learn a little.

Now, I will try to add some displays for my screen, the fact that the rule should only work when the Auto mode is activated (switch), put the wintering back and especially be able to increase or decrease the filtration times using my two pushers. :lol:

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#39 Post by TD-er » 27 Mar 2025, 19:56

Glad you managed to find out stuff yourself.
Sorry I have been extremely busy the past 2 weeks, which leaves not much time for ESPEasy :(
I wish there was a way to have 48h per day...

User avatar
Ath
Normal user
Posts: 4332
Joined: 10 Jun 2018, 12:06
Location: NL

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#40 Post by Ath » 27 Mar 2025, 20:16

Neoseb38 wrote: 27 Mar 2025, 18:32

Code: Select all

On Clock#Time=9:00 do
  asyncevent,calculateFiltration
Endon

On Clock#Time=0:00 do
  let,1,0
Endon
AFAICS, you might not get exactly what you intend in these rules, they are supposed to be more like this:

Code: Select all

On Clock#Time=All,9:00 do
  asyncevent,calculateFiltration
Endon

On Clock#Time=All,0:00 do
  let,1,0
Endon
(I inserted 'All' before the trigger-time, as the day is part of the event.)
/Ton (PayPal.me)

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#41 Post by Neoseb38 » 28 Mar 2025, 06:24

Ath wrote: 27 Mar 2025, 20:16 (I inserted 'All' before the trigger-time, as the day is part of the event.)
Thank you very much for your correction.

I Appreciate :D
Glad you managed to find out stuff yourself.
Sorry I have been extremely busy the past 2 weeks, which leaves not much time for ESPEasy :(
I wish there was a way to have 48h per day...
No worries, you've already helped me so much :D

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#42 Post by Neoseb38 » 29 Mar 2025, 12:47

Hello everyone.

I think I have made very good progress.

Code: Select all

On System#Boot do
  gpio,2,0          // État initial éteint
  let,100,10*3600    // 9h00 en secondes (pivot initial)
  let,100,[int#100]+30*60  // Ajoute 5 minutes
  let,101,60        // Constante pour le calcul
  let,102,100       // Pourcentage de filtration par défaut (100%)
  logentry,"Démarrage : v100=%v100%, syssec_d=%syssec_d%, unixday_sec=%unixday_sec%"
  let,200,0         // Pas encore de température réelle
  
  // Forcer un calcul initial immédiat
  event,calculateFiltration
  
  // Démarrer la boucle immédiatement, mais avec un intervalle court au début
  looptimerset,1,5  // Vérification toutes les 5 secondes au démarrage
Endon

On Clock#Time=All,9:00 do
  asyncevent,calculateFiltration
Endon

On Clock#Time=All,0:00 do
  let,1,0
Endon

On Piscine#Temperature do
  if [int#200] = 0   // Si on n'a pas encore fait de calcul avec température réelle
    let,200,1        // Marquer que nous avons maintenant une température réelle
    asyncevent,calculateFiltration
  endif
Endon

On calculateFiltration do
  Let,1,5400        // Valeur par défaut (90 minutes en secondes)
  if [Piscine#Temperature] > 10
    let,10,[Piscine#Temperature]^3
    let,10,[var#10]*0.00335
    let,11,[Piscine#Temperature]^2
    let,11,[var#11]*0.14953
    let,10,[var#10]-[var#11]
    let,11,[Piscine#Temperature]*2.43489
    let,10,[var#10]+[var#11]
    let,10,[var#10]-10.72859
    Let,1,[var#10]*[int#101]
    logentry,"Durée calculée : v1=%v1%"
  endif
  
  // Appliquer le pourcentage de filtration personnalisé
  let,1,[var#1]*[int#102]/100
  
  let,11,[var#1]/2
  let,2,[int#100]-[var#11]  // Heure de début
  let,3,[int#100]+[var#11]  // Heure de fin
  logentry,"Heures calculées : v2=%v2%, v3=%v3%"
  
  // Mise à jour de l'affichage OLED
  let,20,[var#10]
  let,21,[var#1]/60
  let,22,([var#1]/60)*10+0.5
  let,22,[int#22]
  let,22,[int#22]/10
  oledframedcmd,6,"Ajustement: %v102%% "
  oledframedcmd,7,"Durée: %v22% heures"
  oledframedcmd,8,"Pivot: 14h00"
Endon

On BoutonPlus#State do
  if [BoutonPlus#State] = 1
    if [int#102] < 200
      let,102,[int#102]+5
      logentry,"Augmentation filtration à %v102%%%"
      event,calculateFiltration
    endif
  endif
Endon

On BoutonMoins#State do
  if [BoutonMoins#State] = 1
    if [int#102] > 50
      let,102,[int#102]-5
      logentry,"Diminution filtration à %v102%%%"
      event,calculateFiltration
    endif
  endif
Endon

On Rules#Timer=1 do
  looptimerset,1,5  // Vérification toutes les 5 secondes
  if %syssec_d% > 32400 and [int#1] = 0
    event,calculateFiltration
  endif
  logentry,"Verification : syssec_d=%syssec_d%, v2=%v2%, v3=%v3%"
  if [ModeAuto#EtatModeAUTO] = 1
    if [InterON#EtatInterON] = 0 and [InterOFF#EtatInterOFF] = 0
      if %syssec_d% > [int#2] and %syssec_d% < [int#3]
        gpio,2,1
        logentry,"Pompe allumée : %syssec_d% entre v2=%v2% et v3=%v3%"
      else
        gpio,2,0
        logentry,"Pompe éteinte : %syssec_d% hors v2=%v2% et v3=%v3%"
      endif
    endif
  endif
Endon

Code: Select all

// Affichage Filtration sur l'ecran
On Filtration#EtatFiltration do
   if [Filtration#EtatFiltration]=1
      oledframedcmd,10,"Filtration: ON"
   else
      oledframedcmd,10,"Filtration: OFF"
   endif
endon

// Affichage Eclairage sur l'ecran
On Eclairage#EtatEclairage do
   if [Eclairage#EtatEclairage]=1
      oledframedcmd,11,"Eclairage: ON"
   else
      oledframedcmd,11,"Eclairage: OFF"
   endif
endon

//Affichage PAC sur l'ecran
On PAC#EtatPAC do
   if [PAC#EtatPAC]=1
      oledframedcmd,12,"PAC: ON"
   else
      oledframedcmd,12,"PAC: OFF"
   endif
endon

Code: Select all

// Mode Auto/Manuel
On ModeAuto#EtatModeAUTO do
   // Ne change rien si en mode Forcé ou Arrêt
   if ([InterON#EtatInterON]=0 and [InterOFF#EtatInterOFF]=0)
      if [ModeAuto#EtatModeAUTO]=1
         oledframedcmd,5,"Mode : Auto"
      else
         oledframedcmd,5,"Mode : Manuel"
      endif
   endif
endon

// Mode Forcé (InterON)
On InterON#EtatInterON do
   if [InterON#EtatInterON]=1
      oledframedcmd,5,"Mode : Forcé"
      gpio,2,1  // Active la filtration
   endif
   if [InterON#EtatInterON]=0 and [InterOFF#EtatInterOFF]=0
      // Retour au mode précédent (Auto ou Manuel), mais ne désactive pas la filtration
      if [ModeAuto#EtatModeAUTO]=1
         oledframedcmd,5,"Mode : Auto"
      else
         oledframedcmd,5,"Mode : Manuel"
      endif
   endif
endon

// Mode Arrêt (InterOFF)
On InterOFF#EtatInterOFF do
   if [InterOFF#EtatInterOFF]=1
      oledframedcmd,5,"Mode : Arrêt"
      gpio,2,0  // Désactive la filtration
   endif
   if [InterON#EtatInterON]=0 and [InterOFF#EtatInterOFF]=0
      // Retour au mode précédent (Auto ou Manuel)
      if [ModeAuto#EtatModeAUTO]=1
         oledframedcmd,5,"Mode : Auto"
      else
         oledframedcmd,5,"Mode : Manuel"
      endif
      // Désactive la filtration uniquement en mode Arrêt
      gpio,2,0  // Désactive la filtration
   endif
endon
Here are my 3 rules that work very well at the moment.

To facilitate my tests in minutes around the adjustable pivot time, I have always kept these lines:
let,100,10*3600 // 9h00 en secondes (pivot initial)
let,100,[int#100]+30*60 // Ajoute 5 minutes
let,101,60 // Constante pour le calcul

As a beginner, I struggled and you can imagine that I asked for help from the AI even if it was laborious.

Please excuse me once again.

So for the moment, here's where I am and what works:

- Ignition of the filtration (gpio2) automatically according to the formula (which returns to the blue curve of the Abaqus curve attached above in this post) and rotates around the pivot time.

- filtration recovery after power cut simulation (I had a problem or the time and the temperature was not loaded quickly enough at startup or something like that)

- Forced on and off switch that now also work in automatic mode (before it only worked in manual mode because in auto mode, if the pump had to be turned off for example, if I turned on the gpio2 via the switch, the program turned it off)

- Possibility to increase or decrease filtration times using two push buttons (+ or - 5%)

- Display on OLED screen of the adjustment percentage, filtration time (even if I would have preferred the HH:MM format) pivot hour etc....

Now I will miss 2 things.

1/

The wintering function to turn on the pump in case of frost (via a second temperature sensor measuring outside air and not water)

Only in auto mode, if the filtration turns on outside the filtration hours, the gpio is automatically turned off by the program. Only the switch can.

The level plugin will have arranged for me but it creates a conflict since if I set a temperature threshold of 0°C for example to turn on the gpio2, as soon as the temperature passes above the Valere of hysteresis, the filtration is off and makes my rule obsolete.

2 /

I would have liked to be able to remotely control the gpio2 of my pump in automatic mode as well (for example with my Homekit application (iPhone) connected to jeedom) but I can't because also if the filtration is supposed to be turned off (outside of filtration hours), the program will prevent me from turning it on. Problematic when children want to go swimming at times other than filtration times. Forced to switch to manual mode etc...

There too, only the switch can do it.

Will the creation of a switch-type Dummy device and configure it as the switches be able to overcome its 2 problems?

Hoping that some will have managed to read until the :D

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#43 Post by Neoseb38 » 12 Apr 2025, 10:16

Hello everyone,

My project is coming to an end, and I am very happy.

I finally finished the design of the 3d box and just like the pcb, it was a great first.
I also left room for an evolution towards PH reading and therefore the module that goes with it.
IMG_5871.jpeg
IMG_5871.jpeg (2.65 MiB) Viewed 1401 times
IMG_5870.jpeg
IMG_5870.jpeg (2.09 MiB) Viewed 1401 times
IMG_5869.jpeg
IMG_5869.jpeg (2.46 MiB) Viewed 1401 times
At the moment everything works perfectly well.

I still lack a little thing to put in the rules but for that I will have to be able to activate my gpio2 via a switch-type dummy device but I can't do it.

I can do it via the command line but not through a rule.

In short...

I have a question:

This project must manage my pool but also that of my father-in-law.

Only how do I proceed to make a copy of my esp32?

I make a backup of my espeasy, I go back herehttps://td-er.nl/ESPEasy/latest/ for a new installation and then I restore or is there faster?

Once the new installation is complete, do I have to go to this ip address 192.168.4.1? (Sorry but I had struggled and I don't remember anymore)

There was a password to enter I think?

If I do all this from home, once at my father-in-law's with new wifi, how do I do it please?

For future updates, I have to install the versions without the factory, is that right?

PS: the screen in the photos is not broken, I just didn't remove the protective film :D and I have not yet received my momentary inter 3 positions for the increase / decrease in filtration time.

User avatar
Ath
Normal user
Posts: 4332
Joined: 10 Jun 2018, 12:06
Location: NL

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#44 Post by Ath » 12 Apr 2025, 11:41

Neoseb38 wrote: 12 Apr 2025, 10:16 I have a question:

This project must manage my pool but also that of my father-in-law.

Only how do I proceed to make a copy of my esp32?

I make a backup of my espeasy, I go back herehttps://td-er.nl/ESPEasy/latest/ for a new installation and then I restore or is there faster?

Once the new installation is complete, do I have to go to this ip address 192.168.4.1? (Sorry but I had struggled and I don't remember anymore)

There was a password to enter I think?

If I do all this from home, once at my father-in-law's with new wifi, how do I do it please?
The Tools page has a Backup files button that will create a .tar file with all files on the file system of the ESP, including all configuration. Be sure to have your browser save that file, as .tar is a really old, but simple, archive that's deemed 'old' by most browsers and they are reluctant to save it.
This backup file can be restored on another, similar, ESPEasy unit using the Load button on the Tools page. (The .tar file should be uploaded without being renamed!)
The reboot that's suggested after the Load is completed is mandatory!

When restoring on a new unit, the unit number and device name should be changed, and when using a fixed IP-address that must also be changed.
Neoseb38 wrote: 12 Apr 2025, 10:16 For future updates, I have to install the versions without the factory, is that right?
Updates can be installed on the Tools page, using the Update Firmware button. The .factory.bin file is uploaded only once, for the initial setup, when using an external tool, via the ESPEasy UI you select the (somewhat smaller) .bin file.

The initial connection to WiFi is indeed via the AP provided from the ESP, but can also be done from https://td-er.nl/ESPEasy/latest/.
When using f.e. an Android tablet to connect to that AP it will usually be redirected to the WiFi setup automatically, the AP default password is configesp. That password is often saved by the browser for a simple reconnect (when setting up a new device from the same browser ;))
/Ton (PayPal.me)

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#45 Post by Neoseb38 » 13 Apr 2025, 08:43

Thank you very much for your very detailed message.
When restoring on a new unit, the unit number and device name should be changed, and when using a fixed IP-address that must also be changed.
The two esp32 will never be turned on at the same time. And since one of them will no longer be at my place once configured, is it really necessary to change the number, IP etc...?

How will I have to proceed once at my father-in-law's to make it work on his wifi?

TD-er
Core team member
Posts: 9897
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#46 Post by TD-er » 13 Apr 2025, 12:06

You could add the credentials for his WiFi to the 'fallback' or '2nd' WiFi SSID/key.

Or you can connect that ESP to USB on your PC and visit the web flasher link Ton posted.
This also allows you to open a console to the ESP and make scanning for WiFi a lot easier than connecting to it using your phone.

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#47 Post by Neoseb38 » 13 Apr 2025, 15:34

I spent the whole morning trying to install espeasy on my esp32 ETH01 but I didn't succeed.

I had already struggled the first time but now I can't.

However, I connected well like this:

Image

IO0 on hinge at startup.

Tests with reset (EN on GND), in short hundreds of tests but in vain.

Capture d’écran 2025-04-13 à 15.32.57.png
Capture d’écran 2025-04-13 à 15.32.57.png (67.31 KiB) Viewed 1075 times
Capture d’écran 2025-04-13 à 15.32.38.png
Capture d’écran 2025-04-13 à 15.32.38.png (42.84 KiB) Viewed 1075 times
Capture d’écran 2025-04-13 à 15.32.25.png
Capture d’écran 2025-04-13 à 15.32.25.png (155.59 KiB) Viewed 1075 times

User avatar
Ath
Normal user
Posts: 4332
Joined: 10 Jun 2018, 12:06
Location: NL

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#48 Post by Ath » 13 Apr 2025, 17:04

Most likely the serial adapter doesn't deliver enough power to start up the ESP. Better use a separate 5V power supply to the 5V pin of the ESP. The GND must be shared with the GND coming from the serial adapter, and 3V3 from the serial adapter must be disconnected from the ESP board.
/Ton (PayPal.me)

Neoseb38
Normal user
Posts: 122
Joined: 02 Dec 2024, 18:48

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#49 Post by Neoseb38 » 13 Apr 2025, 17:27

Thank you, I'll try this way.
Can you tell me the exact manipulation to do with the gpio0 and the EN please?
I start with the gpio0 connect to GND then once turned on, I unplug?
For the EN terminal and the nest, do I just have to make a pulse?

DSL but I mix the brushes :D

User avatar
Ath
Normal user
Posts: 4332
Joined: 10 Jun 2018, 12:06
Location: NL

Re: [Help Needed] ESP Easy Rule for Automatic Pool Filtration Management

#50 Post by Ath » 13 Apr 2025, 17:42

This sounds right. Keep GPIO-0 connected to ground, then power-up or reset (EN to GND) the unit. Then it's in Flash-mode, and GPIO-0 can be disconnected. After flashing the unit will most likely be software-reset, so the flasher is expecting to be able to connect to the ESP, but that requires GPIO-0 to be floating, and not to GND, so best to disconnect that pin once it's in Flash-mode.
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests