Custom PCB light controller w/Adafruit QT PY Esp32-s3, binary motion sensor on GPIO17, ledc on GPIO7

I’ve looked at every example for PWM control of an ledc, triggered by a binary motion sensor. This yaml code works but motion turns it on and off WITHOUT PWM. If I use the buttons in Overview they preempt the binary trigger and turn on and off ledc WITH PWM. My ledc output circuitry is capable of driving a very powerful LED array, and PWM control is critical.

How can I get the ledc output to use PWM when triggered by the motion sensor?

Ive tried both “Esp32-S3-Devkitc-1”, and “adafruit_qtpy_esp32s3_nopsram”, both behave the same.

I am planning of making a second cut of my Light Controller PCB, and I would be happy to accept advice on pin-out changes for compatibility, or any reasonable features to add. Currently I’ve included a Panasonic motion sensor, CDS photo-resistor light sensor, touch pad inputs, and the MOSFET has been upgraded to be able to control over 800 Watts with only a 7 degree rise above ambient. The light sensor was moved to GPIO9 (A2) because of a conflict with WiFi using bank ADC2 channels.

esphome:
  name: studymotionlight
  platform: ESP32
  board: adafruit_qtpy_esp32s3_nopsram

# Enable logging
logger:

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

ota:
  - platform: esphome
    password: ""

wifi:
  ssid: 
  password: 
 
 # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-S3-Devkitc-1"
    password: ""

captive_portal:

light:
  - platform: monochromatic
    name: "study room"
    output: studylight

output:
  - platform: ledc
    pin: GPIO7
    id: studylight
    frequency: 1000
    
# Configuration entry for Panasonic Motion Sensor
binary_sensor:
  - platform: gpio
    pin: 17
    name: "PIR sensor"
    device_class: motion 
    on_press:
      then: 
        - output.turn_on: studylight
    filters:
      - delayed_off: 6sec
    on_release:
      - output.turn_off: studylight

As an amendment to my original post, I understand there might be a variable.value exchange code process, that could treat a separate configuration of a binary motion sensor to trigger an ledc type light as a separate config target device, that could be triggered via WiFi delay back & forth, is arguably satisfactory, but I must disagree on shear local hardware signal efficiency grounds.

Please forgive me as a double-E, who is weak on software, but a target device (PWM ledc) should be available for PWM on/off control from a binary motion sensor resident on the same hardware!

I don’t reach out very often, but I consider Home Assistant as a very worthy pursuit!
Thank you in advance!

I found a very close example that has pretty much solved my programming weakness. I would like to thank Wojtek80, truglodite, and Klops.

The following works well, the PIR motion sensor now controls the ledc (output_componet1) with smooth PWM, and now the buttons in the overview turn the ledc on and off without PWM, but that is OK. If I ever develop an “alarm state” automation then turning on/off these light without PWM is a good warning signal!

Next is to calibrate the cadmium photo-resistor for Lux output, and choose a level where I don’t want the light turned on, or have it turn on dimly, as I stumble around the house at night, when I don’t want bright lights!

Again, thanks go to Wojtek80, Truglodite, and Klops!!!

light:
  - platform: monochromatic
    name: "PWM Light"
    output: output_component1
    id: output_component1_light
    default_transition_length: 20ms

output:
  - platform: ledc
    pin: 7
    id: output_component1
    inverted: False

binary_sensor:
  - platform: gpio
    pin: 17
    name: "PIR sensor"
    device_class: motion
    id: move
    filters:
      - delayed_off: 4s      #  set to 4 sec for testing only
    on_press:
      if:
        condition:
          binary_sensor.is_on: move
        then:
          - light.turn_on: 
              id: output_component1_light
              brightness: 100%
              transition_length: 2s              
    on_release:
      then:
        - light.turn_off:
            id: output_component1_light
            transition_length: 2s

sensor:
  - platform: adc
    pin: GPIO9
    name: "Study Illuminance"
    update_interval: 1sec
    unit_of_measurement: lx
    attenuation: auto
    filters:
      - lambda: |-
          return (x * 2000.0);