ADC to turn on/off and dim light

Hi,

i’m trying to setup a esp12f module with a touch dimmer attached to A0 and a rgbw led strip attached to GPIO5, 12, 13, 14.

The Dimmer itself has an output from 0-3.3V. Simple Touch turns on or off, keeping pressed it dims up or down.

This is what my yaml looks like:

substitutions:
  device_name: "nightlight1"


esphome:
  name: ${device_name}
  platform: ESP8266
  board: esp12e

wifi:
  ssid: !secret wifi_ssid_2.4
  password: !secret wifi_password
  domain: .fritz.box
  use_address: nightlight1.local
  
#Enable logging
logger:

#Enable Home Assistant API
api:
  encryption:
    key: "key"

ota:
  - platform: esphome
    password: "password"

output:

  - platform: esp8266_pwm
    pin: GPIO5
    id: red_gpio

    
  - platform: esp8266_pwm
    pin: GPIO13
    id: blue_gpio


  - platform: esp8266_pwm
    pin: GPIO14
    id: green_gpio


  - platform: esp8266_pwm
    pin: GPIO12
    id: warm_white_gpio


  - platform: esp8266_pwm
    pin: GPIO4
    id: cold_white_gpio



light:

  - platform: rgbw
    
    name: "${device_name}"
    id: ambilight
    red: red_gpio
    green: green_gpio
    blue: blue_gpio
    white: warm_white_gpio

sensor:
  - platform: adc
    id: tdp
    internal: True
    pin: GPIO17
    name: "Touch Dimmer"
    update_interval: 10ms
    filters:
      - multiply: 3.3

        
web_server:
  port: 80

First strange behavior: With ADC Sensor i can turn on the light using web but cannot turn it off. to turn off i have to use home assistant.

Next problem, i don’t know how to program the lambda to turn on, off and dim the light using the adc readings.

Can you please help me?

Thank you.

How? I don’t see any automation on your yaml turning on the light.

Automation could be something like this. But your update interval is smaller than Esphome loop cycle…

sensor:
  - platform: adc
    id: tdp
    internal: True
    pin: GPIO17
    name: "Touch Dimmer"
    update_interval: 10ms
    on_value:
      then:
        - light.turn_on:
            id: ambilight
            brightness: !lambda "return x;"