From 1b3464f06eed947e9acf34b821b5b326d6baf8e0 Mon Sep 17 00:00:00 2001 From: Raymond Bourges Date: Wed, 28 May 2025 16:03:05 +0200 Subject: [PATCH] FEAT : Pilotage TV OK --- config/tv.yaml | 1 - config/tv2.yaml | 95 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 config/tv2.yaml diff --git a/config/tv.yaml b/config/tv.yaml index 4ad35d7..14672a4 100644 --- a/config/tv.yaml +++ b/config/tv.yaml @@ -23,7 +23,6 @@ wifi: ssid: !secret wifi_ssid password: !secret wifi_password -# Example configuration entry uart: tx_pin: GPIO44 # Il faut les inverser !!!! rx_pin: GPIO43 diff --git a/config/tv2.yaml b/config/tv2.yaml new file mode 100644 index 0000000..5270dfb --- /dev/null +++ b/config/tv2.yaml @@ -0,0 +1,95 @@ +esphome: + name: tv2 + friendly_name: tv2 + on_boot: + then: + - output.turn_off: relais + - output.turn_on: bouton_vert + - output.turn_off: bouton_rouge + +esp32: + board: esp32-c6-devkitc-1 + variant: esp32c6 + framework: + type: esp-idf + +# Enable logging +logger: + +uart: + tx_pin: GPIO17 # Il faut les inverser !!!! + rx_pin: GPIO16 + baud_rate: 9600 + # debug: + # direction: BOTH + # dummy_receiver: false + # after: + # delimiter: "\n" + # sequence: + # - lambda: UARTDebug::log_string(direction, bytes); + +modbus: + +output: + - platform: gpio + pin: GPIO1 + id: relais + - platform: gpio + pin: GPIO22 + id: bouton_vert + - platform: gpio + pin: GPIO23 + id: bouton_rouge + +globals: + - id: low_power_count + type: int + initial_value: '0' + - id: from_start_count + type: int + initial_value: '0' + - id: puissance_faible + type: bool + initial_value: 'false' + +sensor: + - platform: pzemac + address: 4 + power: + name: "PZEM-004T V3 Power" + on_value: + then: + - lambda: |- + if (id(from_start_count) < 10) { + id(from_start_count)++; + id(bouton_rouge).turn_on(); + id(relais).turn_on(); + ESP_LOGD("main", "--> Démarrage... (%d / 10)", id(from_start_count)); + } else { + if (id(puissance_faible)) { + id(low_power_count)++; + ESP_LOGD("main", "--> Puissance faible (%d / 5)", id(low_power_count)); + } + if (id(low_power_count) >= 5) { + ESP_LOGD("main", "--> TV OFF !"); + id(relais).turn_off(); + } + } + on_value_range: + - below: 40 + then: + - lambda: |- + ESP_LOGD("main", "--> Puissance faible !"); + id(puissance_faible) = true; + id(bouton_vert).turn_off(); + - above: 40 + then: + - lambda: |- + ESP_LOGD("main", "--> Puissance normale."); + id(puissance_faible) = false; + id(bouton_vert).turn_on(); + id(relais).turn_on(); + id(low_power_count) = 0; + + update_interval: 5s + \ No newline at end of file