From 0b7971da3cf5a1de8d867b0be16f133e61d8b735 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 29 Mar 2025 17:47:27 +0100 Subject: [PATCH] Added File for Schallplaten Relay controler --- Mini-OLED.yml | 2 + schall-relay.yml | 150 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 schall-relay.yml diff --git a/Mini-OLED.yml b/Mini-OLED.yml index 830777d..fef4452 100644 --- a/Mini-OLED.yml +++ b/Mini-OLED.yml @@ -73,6 +73,8 @@ sensor: temperature: name: "Tim Schreibtisch Temperatur" id: "tim_schreib_temp" + filters: + offset: -3.5 humidity: name: "Tim Schreibtisch Luftfeuchte" id: "tim_schreib_hum" diff --git a/schall-relay.yml b/schall-relay.yml new file mode 100644 index 0000000..f1b56a0 --- /dev/null +++ b/schall-relay.yml @@ -0,0 +1,150 @@ +esphome: + name: d1-schallplatten-relay + friendly_name: D1 Schallplatten Relay + +esp8266: + board: esp12e + +# Enable logging +logger: + +# Enable Home Assistant API +api: + encryption: + key: "tY/skBnkQn1sZRBYYJ4LL571z+aA1P463WvaX58Zu2w=" + +ota: + platform: esphome + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + +captive_portal: + +globals: + - id: mode + type: int + restore_value: no + initial_value: '0' + + +binary_sensor: +# Erster Knopf: Mode Select + - platform: gpio + pin: + number: 2 + mode: INPUT_PULLUP + inverted: true + name: "Mode-Select" + internal: true + on_press: + then: + - lambda: |- + id(mode) = (id(mode) + 1) % 3; + ESP_LOGD("Mode", "Neuer Modus: %d", id(mode)); + + auto call_off = id(rgb_led).turn_off(); + auto call_on = id(rgb_led).turn_on(); + if (id(mode) == 0) { + call_off.perform(); + ESP_LOGD("LED", "LED wird ausgeschaltet"); + } else if (id(mode) == 1) { + ESP_LOGD("LED", "LED auf Grün"); + call_on.set_rgb(0.0, 1.0, 0.0); + call_on.perform(); + } else if (id(mode) == 2) { + ESP_LOGD("LED", "LED auf Rot"); + call_on.set_rgb(1.0, 0.0, 0.0); + call_on.perform(); + } + + + +# Zweiter Knopf: Verhalten abhängig vom Modus + - platform: gpio + pin: + number: 5 + mode: INPUT_PULLUP + inverted: true + name: "Funktion-Vertärker" + internal: true + on_press: + then: + - lambda: |- + if (id(mode) == 0) { + ESP_LOGD("Action", "Modus 0: Keine Aktion"); + } else if (id(mode) == 1) { + ESP_LOGD("Action", "Modus 1: Ausgang EIN"); + id(relay_1).turn_on(); + } else if (id(mode) == 2) { + ESP_LOGD("Action", "Modus 2: Ausgang AUS"); + id(relay_1).turn_on(); + } + - platform: gpio + pin: + number: 0 + mode: INPUT_PULLUP + inverted: true + name: "Funktion-BT" + internal: true + on_press: + then: + - lambda: |- + if (id(mode) == 0) { + ESP_LOGD("Action", "Modus 0: Keine Aktion"); + } else if (id(mode) == 1) { + ESP_LOGD("Action", "Modus 1: Ausgang EIN"); + id(relay_2).turn_on(); + } else if (id(mode) == 2) { + ESP_LOGD("Action", "Modus 2: Ausgang AUS"); + id(relay_2).turn_off(); + } + + + +button: + - platform: + name: Vertärker + on_press: + then: + - switch.turn_on: relay_1 + +switch: + - platform: gpio + id: relay_1 + inverted: true + internal: true + on_turn_on: + - delay: 500ms + - switch.turn_off: relay_1 + pin: 13 + + - platform: gpio + id: relay_2 + name: "BT-Adapter" + inverted: true + pin: 15 + +light: + - platform: rgb + name: "Status-LED" + id: rgb_led + red: red_out + green: green_out + blue: blue_out + + +output: + - platform: esp8266_pwm + id: red_out + pin: 4 + + - platform: esp8266_pwm + id: green_out + pin: 14 + + - platform: esp8266_pwm + id: blue_out + pin: 12 +