modes : forcé, normal +et-, arrêt

This commit is contained in:
Laurent Claude 2024-08-26 08:36:55 +02:00
parent 8b71e2bb63
commit d40590e1cd

View File

@ -1,6 +1,6 @@
substitutions: substitutions:
name: thr320d_filtre_bb04f0 name: thr320d_filtre_bb04f0
friendly_name: "filtration" friendly_name: Filtration"
project_name: "Filtration piscine" project_name: "Filtration piscine"
project_version: "1.0" project_version: "1.0"
light_restore_mode: RESTORE_DEFAULT_OFF light_restore_mode: RESTORE_DEFAULT_OFF
@ -29,11 +29,19 @@ logger:
web_server: web_server:
port: 80 port: 80
version: 3
log: off
ota: off
local: true
auth:
username: !secret web_server_user_piscine
password: !secret web_server_pass_piscine
wifi: wifi:
ssid: !secret wifi_ssid ssid: !secret wifi_ssid
password: !secret wifi_password password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails # Enable fallback hotspot (captive portal) in case wifi connection fails
ap: ap:
ssid: !secret ap_ssid_pool ssid: !secret ap_ssid_pool
@ -58,10 +66,9 @@ display:
lambda: |- lambda: |-
it.printf(0, "%.1f", id(${name}_temp).state); it.printf(0, "%.1f", id(${name}_temp).state);
it.display_celsius(true); it.display_celsius(true);
/*it.printf(1, "%.1f", id(${name}_temp).state/10); if (id(sntp_time).now().is_valid()) {
/*it.display_kwh(true); it.printf(1, "%1.f", id(duree).state);
/*it.printf(1, "%.1f", id(${name}_humi).state); }
it.display_humidity(true);*/
binary_sensor: binary_sensor:
# single main button that also puts device into flash mode when held on boot # single main button that also puts device into flash mode when held on boot
@ -70,21 +77,20 @@ binary_sensor:
number: GPIO0 number: GPIO0
mode: INPUT_PULLUP mode: INPUT_PULLUP
inverted: True inverted: True
name: "${friendly_name} Button" name: "Boutton"
internal: True
on_click: on_click:
- max_length: 350ms # short press to toggle the relay - min_length: 500ms # long press
max_length: 2s
then: then:
switch.toggle: mainRelayVirt - switch.toggle: mainRelayVirt
- min_length: 360ms # long press to do... - min_length: 5s # very long press to reset
max_length: 3s max_length: 10s
then:
switch.toggle: dryContRelay
- min_length: 10s # very long press to reset
max_length: 20s
then: then:
- switch.turn_on: ${name}_restart - switch.turn_on: ${name}_restart
- platform: status on_double_click:
name: "${friendly_name} Status" then:
switch.toggle: dryContRelay
switch: switch:
# virtual switch to represent the main relay # virtual switch to represent the main relay
@ -94,14 +100,14 @@ switch:
name: "Pompe" name: "Pompe"
turn_on_action: turn_on_action:
- switch.turn_on: mainRelayOn - switch.turn_on: mainRelayOn
- switch.turn_on: ${name}_onoff_led - switch.turn_on: ${name}_pompe_led
turn_off_action: turn_off_action:
- switch.turn_on: mainRelayOff - switch.turn_on: mainRelayOff
- switch.turn_off: ${name}_onoff_led - switch.turn_off: ${name}_pompe_led
assumed_state: True assumed_state: True
optimistic: True optimistic: True
#restore_state: True icon: mdi:pump
#restore_mode: ALWAYS_ON web_server_sorting_weight: 10
# internal momentary switch for main relay ON # internal momentary switch for main relay ON
- platform: gpio - platform: gpio
@ -128,24 +134,27 @@ switch:
# dry contact relay switch # dry contact relay switch
- platform: gpio - platform: gpio
id: dryContRelay id: dryContRelay
name: "Extension" name: "Sortie auxiliaire"
icon: mdi:cards-diamond
web_server_sorting_weight: 15
pin: pin:
number: GPIO4 number: GPIO4
on_turn_on: on_turn_on:
- switch.turn_on: ${name}_ext_led - switch.turn_on: ${name}_aux_led
on_turn_off: on_turn_off:
- switch.turn_off: ${name}_ext_led - switch.turn_off: ${name}_aux_led
restore_mode: ALWAYS_OFF
# Leftmost (red) LED that's used to indicate the relay being on/off # Leftmost (red) LED that's used to indicate the relay being on/off
- platform: gpio - platform: gpio
id: ${name}_onoff_led id: ${name}_pompe_led
pin: pin:
number: GPIO16 number: GPIO16
inverted: true inverted: true
# Rightmost (green) LED; use as dry contact indicator # Rightmost (green) LED; use as dry contact indicator
- platform: gpio - platform: gpio
id: ${name}_ext_led id: ${name}_aux_led
pin: pin:
number: GPIO13 number: GPIO13
inverted: true inverted: true
@ -156,21 +165,13 @@ switch:
- platform: gpio - platform: gpio
pin: GPIO27 pin: GPIO27
id: ${name}_sensor_power id: ${name}_sensor_power
restore_mode: ALWAYS_ON restore_mode: ALWAYS_OFF
- platform: restart - platform: restart
name: "Filtration Restart" name: "Redémarrer"
id: ${name}_restart id: ${name}_restart
icon: "mdi:restart" icon: "mdi:restart"
light:
# The middle (blue) LED is used as wifi status indicator.
- platform: status_led
id: wifi_status_led
name: "Wifi"
pin:
number: GPIO15
inverted: true
sensor: sensor:
- platform: dallas_temp - platform: dallas_temp
@ -178,62 +179,165 @@ sensor:
id: ${name}_temp id: ${name}_temp
address: 0xfe3ce504578d3c28 address: 0xfe3ce504578d3c28
update_interval: 1s update_interval: 1s
web_server_sorting_weight: 05
climate: icon: mdi:pool-thermometer
- platform: thermostat
name: "${friendly_name} Climate"
sensor: ${name}_temp
default_preset: Home
preset:
- name: Home
default_target_temperature_low: 31 °C
mode: heat
min_heating_off_time: 300s
min_heating_run_time: 300s
min_idle_time: 30s
heat_action:
- switch.turn_on: mainRelayVirt
idle_action:
- switch.turn_off: mainRelayVirt
heat_deadband: 0.5 # how many degrees can we go under the temp before starting to heat
heat_overrun: 0.5 # how many degrees can we go over the temp before stopping
text_sensor: text_sensor:
- platform: wifi_info - platform: wifi_info
ip_address: ip_address:
name: "Addresse IP" name: "Addresse IP"
disabled_by_default: true disabled_by_default: true
icon: mdi:ip-network
interval: number:
- interval: 30s - platform: template
name: "Heure démarrage"
id: heure_depart
min_value: 0
max_value: 59
step: 1
restore_value: True
initial_value: 8
unit_of_measurement: s
mode: box
optimistic: True
icon: mdi:clock-start
web_server_sorting_weight: 20
- platform: template
name: "Durée de base"
id: duree_debase
min_value: 0
max_value: 60
step: 1
restore_value: False
initial_value: 0
unit_of_measurement: s
optimistic: True
internal: True
- platform: template
name: "Durée filtration H/j"
id: duree
min_value: 0
max_value: 60
step: 1
restore_value: False
initial_value: 0
unit_of_measurement: s
mode: SLIDER
optimistic: True
entity_category: config
icon: mdi:fan-clock
web_server_sorting_weight: 25
- platform: template
name: "Heure actuelle"
id: heure
internal: True
min_value: 0
max_value: 59
step: 1
unit_of_measurement: s
optimistic: True
- platform: template
name: "Heure fin filtration"
id: heure_fin
internal: True
min_value: 0
max_value: 59
step: 1
unit_of_measurement: s
optimistic: True
select:
- platform: template
name: "Mode"
id: mode
optimistic: true
options:
- Forcé
- Intensif
- Normal
- Économique
- Arrêt
initial_option: Normal
icon: mdi:power
web_server_sorting_weight: 2
on_value:
then: then:
if: - lambda: |-
condition: if (id(mode).state == "Intensif") {
wifi.connected: id(duree).state = id(duree_debase).state + 2;
then: if (id(duree).state > 59) {
- light.turn_on: wifi_status_led id(duree).state = 60;
else: }
- light.turn_off: wifi_status_led }
if (id(mode).state == "Normal") {
id(duree).state = id(duree_debase).state;
}
if (id(mode).state == "Économique") {
id(duree).state = id(duree_debase).state - 2;
if (id(duree).state < 0) {
id(duree).state = 0;
}
}
time: time:
- platform: sntp - platform: sntp
# ... id: sntp_time
on_time: timezone: Europe/Paris
# Every 5 minutes servers:
- seconds: /5 - 0.pool.ntp.org
#minutes: /5 - 1.pool.ntp.org
then: - 2.pool.ntp.org
- switch.toggle: ${name}_ext_led
# Every morning on weekdays
- seconds: 0
minutes: 30
hours: 7
days_of_week: MON-FRI
then:
- light.turn_on: wifi_status_led
# Cron syntax, trigger every 5 minutes interval:
- cron: '00 /5 * * * *' - interval: 1s
then: then:
- switch.toggle: ${name}_ext_led - lambda: |-
if (id(mode).state == "Forcé") {
id(mainRelayVirt).turn_on();
}
if ((id(mode).state == "Normal") || (id(mode).state == "Économique") || (id(mode).state == "Intensif")) {
if (id(sntp_time).now().second == (id(heure_depart).state)) {
id(duree_debase).state = (id(${name}_temp).state / 2);
id(duree).state = id(duree_debase).state;
}
ESP_LOGI("main", "Heure de début: %.0f", id(heure_depart).state);
id(heure_fin).state = id(heure_depart).state + (id(duree).state) -1;
ESP_LOGI("main", "Heure de fin: %.0f", id(heure_fin).state);
if (id(heure_fin).state > 59) {
id(heure_fin).state = id(heure_fin).state - 60;
}
ESP_LOGI("main", "Heure de fin: %.0f", id(heure_fin).state);
if (id(heure_fin).state >= id(heure_depart).state) {
if (((id(sntp_time).now().second) >= (id(heure_depart).state)) and ((id(sntp_time).now().second) <= (id(heure_fin).state))) {
id(mainRelayVirt).turn_on();
}
else {
id(mainRelayVirt).turn_off();
}
}
else {
if ((id(sntp_time).now().second) >= (id(heure_depart).state)) {
id(mainRelayVirt).turn_on();
}
else {
if ((id(sntp_time).now().second) <= (id(heure_fin).state)) {
id(mainRelayVirt).turn_on();
}
else {
id(mainRelayVirt).turn_off();
}
}
}
}
if (id(mode).state == "Arrêt") {
id(mainRelayVirt).turn_off();
}