esphome:
  name: halloweencontroller1
  friendly_name: HalloweenController1

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

# Enable logging
logger:

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

ota:
  password: "c5236ff01cdcb3c5b40b9e24d0278301"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Halloweencontroller1"
    password: "U6Q1tMpNMpel"

captive_portal:
    
switch:
  - platform: gpio
    inverted: no
    name: "Output 1"
    pin: 1
    id: output_1

  - platform: gpio
    inverted: no
    name: "Output 2"
    pin: 2
    id: output_2

  - platform: gpio
    inverted: no
    name: "Output 3"
    pin: 3
    id: output_3

  - platform: gpio
    inverted: no
    name: "Output 4"
    pin: 4
    id: output_4

  - platform: gpio
    inverted: no
    name: "Output 5"
    pin: 5
    id: output_5

binary_sensor:
  - platform: gpio
    id: input_1
    pin:
      number: 34
      mode: INPUT_PULLDOWN
    name: "Input 1"

  - platform: gpio
    id: input_2
    pin:
      number: 9
      mode: INPUT_PULLDOWN
    name: "Input 2"

  - platform: gpio
    id: input_3
    pin:
      number: 8
      mode: INPUT_PULLDOWN

    name: "Input 3"

  - platform: gpio
    id: input_4
    pin:
      number: 7
      mode: INPUT_PULLDOWN
    name: "Input 4"

  - platform: gpio
    id: input_5
    pin:
      number: 6
      mode: INPUT_PULLDOWN
    name: "Input 5"



external_components:
  - source: github://andyboeh/esphome-dmx512

uart:
  id: uart_bus
  baud_rate: 250000
  tx_pin: GPIO21
  stop_bits: 2

dmx512:
  id: dmx
  uart_id: uart_bus
  tx_pin: GPIO21
  uart_num: 1

output:
  - platform: dmx512
    channel: 1
    universe: dmx
    id: par1_brightness
  - platform: dmx512
    channel: 2
    universe: dmx
    id: par1_red
  - platform: dmx512
    channel: 3
    universe: dmx
    id: par1_green    
  - platform: dmx512
    channel: 4
    universe: dmx
    id: par1_blue


  - platform: dmx512
    channel: 8
    universe: dmx
    id: par2_brightness
  - platform: dmx512
    channel: 9
    universe: dmx
    id: par2_red
  - platform: dmx512
    channel: 10
    universe: dmx
    id: par2_green    
  - platform: dmx512
    channel: 11
    universe: dmx
    id: par2_blue


  - platform: dmx512
    channel: 16
    universe: dmx
    id: par3_brightness
  - platform: dmx512
    channel: 17
    universe: dmx
    id: par3_red
  - platform: dmx512
    channel: 18
    universe: dmx
    id: par3_green    
  - platform: dmx512
    channel: 19
    universe: dmx
    id: par3_blue

  - platform: dmx512
    channel: 32
    universe: dmx
    id: par4_brightness
  - platform: dmx512
    channel: 33
    universe: dmx
    id: par4_red
  - platform: dmx512
    channel: 34
    universe: dmx
    id: par4_green    
  - platform: dmx512
    channel: 35
    universe: dmx
    id: par4_blue

  - platform: dmx512
    channel: 64
    universe: dmx
    id: par5_brightness
  - platform: dmx512
    channel: 65
    universe: dmx
    id: par5_red
  - platform: dmx512
    channel: 66
    universe: dmx
    id: par5_green    
  - platform: dmx512
    channel: 67
    universe: dmx
    id: par5_blue

  - platform: dmx512
    channel: 128
    universe: dmx
    id: par6_brightness
  - platform: dmx512
    channel: 129
    universe: dmx
    id: par6_red
  - platform: dmx512
    channel: 130
    universe: dmx
    id: par6_green    
  - platform: dmx512
    channel: 131
    universe: dmx
    id: par6_blue



light:
  - platform: monochromatic
    name: Par 1 Dimmer
    output: par1_brightness
    icon: mdi:blur
    default_transition_length: 0s
    gamma_correct: 0
    restore_mode: RESTORE_DEFAULT_ON

  - platform: rgb
    name: Par 1
    id: dmx_par1
    red: par1_red
    green: par1_green
    blue: par1_blue
    icon: mdi:spotlight
    default_transition_length: 0.3s
    gamma_correct: 0
    restore_mode: RESTORE_DEFAULT_ON

  - platform: monochromatic
    name: Par 2 Dimmer
    output: par2_brightness
    icon: mdi:blur
    default_transition_length: 0s
    gamma_correct: 0
    restore_mode: RESTORE_DEFAULT_ON

  - platform: rgb
    name: Par 2
    id: dmx_par2
    red: par2_red
    green: par2_green
    blue: par2_blue
    icon: mdi:spotlight
    default_transition_length: 0.3s
    gamma_correct: 0
    restore_mode: RESTORE_DEFAULT_ON

  - platform: monochromatic
    name: Par 3 Dimmer
    output: par3_brightness
    icon: mdi:blur
    default_transition_length: 0s
    gamma_correct: 0
    restore_mode: RESTORE_DEFAULT_ON

  - platform: rgb
    name: Par 3
    id: dmx_par3
    red: par3_red
    green: par3_green
    blue: par3_blue
    icon: mdi:spotlight
    default_transition_length: 0.3s
    gamma_correct: 0
    restore_mode: RESTORE_DEFAULT_ON

  - platform: monochromatic
    name: Par 4 Dimmer
    output: par4_brightness
    icon: mdi:blur
    default_transition_length: 0s
    gamma_correct: 0
    restore_mode: RESTORE_DEFAULT_ON

  - platform: rgb
    name: Par 4
    id: dmx_par4
    red: par4_red
    green: par4_green
    blue: par4_blue
    icon: mdi:spotlight
    default_transition_length: 0.3s
    gamma_correct: 0
    restore_mode: RESTORE_DEFAULT_ON

  - platform: monochromatic
    name: Par 5 Dimmer
    output: par1_brightness
    icon: mdi:blur
    default_transition_length: 0s
    gamma_correct: 0
    restore_mode: RESTORE_DEFAULT_ON

  - platform: rgb
    name: Par 5
    id: dmx_par5
    red: par5_red
    green: par5_green
    blue: par5_blue
    icon: mdi:spotlight
    default_transition_length: 0.3s
    gamma_correct: 0
    restore_mode: RESTORE_DEFAULT_ON

  - platform: monochromatic
    name: Par 6 Dimmer
    output: par6_brightness
    icon: mdi:blur
    default_transition_length: 0s
    gamma_correct: 0
    restore_mode: RESTORE_DEFAULT_ON

  - platform: rgb
    name: Par 6
    id: dmx_par6
    red: par6_red
    green: par6_green
    blue: par6_blue
    icon: mdi:spotlight
    default_transition_length: 0.3s
    gamma_correct: 0
    restore_mode: RESTORE_DEFAULT_ON

