---
substitutions:
  device: kitchen
  name: Kitchen
  area: Living Room & Kitchen
  comment: "${area} | Kitchen Worktop and Stove Lights"

esphome:
  name: mcu-${device}
  friendly_name: ${name}
  area: ${area}
  comment: ${comment}
  on_boot:
    # - priority: 600.0
    #   then:
    #     - light.turn_on: light_1
    #     - light.turn_on: light_2
    #     - light.turn_on: light_3
    #     - light.turn_on: light_4
    priority: -100.0
    then:
      - if:
          condition:
            api.connected:
          then:
            - light.turn_off: light_1
            - light.turn_off: light_2
            - light.turn_off: light_3
            # - light.turn_off: light_4

esp32:
  variant: esp32
  framework:
    type: esp-idf

packages:
  common: !include common/common.yaml

api:
  reboot_timeout: 300s

# PINOUTS: M5ATOM+Atom Hub Switch
# IR        G12
# NEO       G27 1x
# BUTTON    G39
# I2C0 SDA  G26 - white
# I2C0 SCL  G32
# I2C1 SDA  G25 - red
# I2C1 SCL  G21
# UART0 RX  G3
# UART0 TX  G1
# RS485 Rx  G33
# RS485 Tx  G23
# Relay1    G22
# Relay2    G19

time:
  - platform: homeassistant
    id: ha_time
    timezone: Europe/Bratislava

i2c:
  # - id: i2c0
  #   sda: 26
  #   scl: 32
  #   scan: true #false
  # - id: i2c1
  sda: 25
  scl: 21
  scan: true #false

pca9685:
  id: 'pca9685_hub1'
  frequency: 1000
  address: 0x40

# modbus:
#   uart_id: uart1

# uart:
#   - id: uart1
#     rx_pin: 33
#     tx_pin: 32
#     baud_rate: 9600
#     stop_bits: 2

binary_sensor:
  - platform: gpio
    name: Status Button
    filters:
      - invert:
    pin: 39

light:
  # - platform: esp32_rmt_led_strip
  #   name: Status Light
  #   id: neo
  #   rgb_order: GRB
  #   pin: 27
  #   num_leds: 1
  #   rmt_channel: 0
  #   chipset: ws2812
  #   restore_mode: ALWAYS_OFF
  - platform: cwww
    name: Worktop Left
    id: light_1
    default_transition_length: 200ms
    restore_mode: ALWAYS_ON
    cold_white: pwm_cw_1
    warm_white: pwm_ww_1
    cold_white_color_temperature: 6536 K
    warm_white_color_temperature: 2000 K
  - platform: cwww
    name: Stove
    id: light_2
    default_transition_length: 200ms
    restore_mode: ALWAYS_ON
    cold_white: pwm_cw_2
    warm_white: pwm_ww_2
    cold_white_color_temperature: 6536 K
    warm_white_color_temperature: 2000 K
  - platform: cwww
    name: Worktop Right
    id: light_3
    default_transition_length: 200ms
    restore_mode: ALWAYS_ON
    cold_white: pwm_cw_3
    warm_white: pwm_ww_3
    cold_white_color_temperature: 6536 K
    warm_white_color_temperature: 2000 K
  # - platform: cwww
  #   name: Light Spare
  #   id: light_4
  #   default_transition_length: 200ms
  #   restore_mode: ALWAYS_ON
  #   cold_white: pwm_cw_4
  #   warm_white: pwm_ww_4
  #   cold_white_color_temperature: 6536 K
  #   warm_white_color_temperature: 2000 K

output:
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    id: 'pwm_cw_1'
    channel: 0
    #min_power: 0.05
    zero_means_zero: true
    power_supply: power_supply1
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    id: 'pwm_ww_1'
    channel: 1
    #min_power: 0.05
    zero_means_zero: true
    power_supply: power_supply1
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    id: 'pwm_cw_2'
    channel: 2
    #min_power: 0.05
    zero_means_zero: true
    power_supply: power_supply1
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    id: 'pwm_ww_2'
    channel: 3
    #min_power: 0.07
    zero_means_zero: true
    power_supply: power_supply1
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    id: 'pwm_cw_3'
    channel: 4
    #min_power: 0.07
    zero_means_zero: true
    power_supply: power_supply1
  - platform: pca9685
    pca9685_id: 'pca9685_hub1'
    id: 'pwm_ww_3'
    channel: 5
    #min_power: 0.08
    zero_means_zero: true
    power_supply: power_supply1
  # - platform: pca9685
  #   pca9685_id: 'pca9685_hub1'
  #   id: 'pwm_cw_4'
  #   channel: 6
  #   #min_power: 0.08
  #   zero_means_zero: true
  #   power_supply: power_supply1
  # - platform: pca9685
  #   pca9685_id: 'pca9685_hub1'
  #   id: 'pwm_ww_4'
  #   channel: 7
  #   #min_power: 0.08
  #   zero_means_zero: true
  #   power_supply: power_supply1

power_supply:
  - id: 'power_supply1'
    pin: 22

# switch:
#   - platform: gpio
#     name: "${name} Relay Spare"
#     id: relay_2
#     pin: 19

bluetooth_proxy:
  active: true
