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