esphome:
  name: esphome-web-120cbc
  friendly_name: House Security Panel

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

output:
  - platform: ledc
    pin: GPIO18
    id: rtttl_out

rtttl:
  output: rtttl_out
  on_finished_playback:
    - logger.log: 'Song ended!'

# Enable Home Assistant API
api:
  encryption:
    key: "YOUR KEY HERE"

  services:
    - service: play_rtttl
      variables:
        song_str: string
      then:
        - rtttl.play:
            rtttl: !lambda 'return song_str;'

ota:

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "YOUR SSID HERE"
    password: "YOUR PASSWORD HERE"

captive_portal:

i2c:
  sda: 21
  scl: 22
  scan: true
  id: bus_a
  frequency: 200kHz

# Each MCP23017 Chip has 16 IO pins, but the manufacturer says not to use A7(7) or B7(15) for inputs (Only outputs)
# so I am only using 14 of the 16 on each because I am using all of them for inputs
mcp23017:
  - id: 'mcp23017_hub1'
    address: 0x20
  - id: 'mcp23017_hub2'
    address: 0x21
  - id: 'mcp23017_hub3'
    address: 0x22    
    
binary_sensor:
# Start of zones on MCP23017 Chip number 1 - 14 zones
  - platform: gpio
    name: Front Door
    pin:
      mcp23xxx: mcp23017_hub1
      number: 0
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Back Door
    pin:
      mcp23xxx: mcp23017_hub1
      number: 1
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Interior Garage Door
    pin:
      mcp23xxx: mcp23017_hub1
      number: 2
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Crawl Space Door
    pin:
      mcp23xxx: mcp23017_hub1
      number: 3
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Dining Room Window - Left
    pin:
      mcp23xxx: mcp23017_hub1
      number: 4
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Dining Room Window - Right
    pin:
      mcp23xxx: mcp23017_hub1
      number: 5
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Garage Window - Left
    pin:
      mcp23xxx: mcp23017_hub1
      number: 6
      mode:
        input: true
        pullup: false
      inverted: false

#Pin number 7 is skipped as it is the 8th pin in group A and should not be used for inputs

  - platform: gpio
    name: Garage Window - Center
    pin:
      mcp23xxx: mcp23017_hub1
      number: 8
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Garage Window - Right
    pin:
      mcp23xxx: mcp23017_hub1
      number: 9
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Family Room Window - Side
    pin:
      mcp23xxx: mcp23017_hub1
      number: 10
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Family Room Window - Left
    pin:
      mcp23xxx: mcp23017_hub1
      number: 11
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Family Room Window - Right
    pin:
      mcp23xxx: mcp23017_hub1
      number: 12
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Kitchen Window - Left
    pin:
      mcp23xxx: mcp23017_hub1
      number: 13
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Kitchen Window - Right
    pin:
      mcp23xxx: mcp23017_hub1
      number: 14
      mode:
        input: true
        pullup: false
      inverted: false

# Pin number 15 is skipped as it is the 8th pin in group B and should not be used for inputs
# End of zones on MCP23017 Chip number 1


# Start of zones on MCP23017 Chip number 2

  - platform: gpio
    name: Living Room Window - Left
    pin:
      mcp23xxx: mcp23017_hub2
      number: 0
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Living Room Window - Right
    pin:
      mcp23xxx: mcp23017_hub2
      number: 1
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Bay Window - Left
    pin:
      mcp23xxx: mcp23017_hub2
      number: 2
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Bay Window - Right
    pin:
      mcp23xxx: mcp23017_hub2
      number: 3
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Stairwell Window - Left
    pin:
      mcp23xxx: mcp23017_hub2
      number: 4
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Stairwell Window - Right
    pin:
      mcp23xxx: mcp23017_hub2
      number: 5
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Morning Room Window - Left
    pin:
      mcp23xxx: mcp23017_hub2
      number: 6
      mode:
        input: true
        pullup: false
      inverted: false

#Pin number 7 is skipped as it is the 8th pin in group A and should not be used for inputs

  - platform: gpio
    name: Morning Room Window - Right
    pin:
      mcp23xxx: mcp23017_hub2
      number: 8
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Master Bedroom Window - Left
    pin:
      mcp23xxx: mcp23017_hub2
      number: 9
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Master Bedroom Window - Right
    pin:
      mcp23xxx: mcp23017_hub2
      number: 10
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Bedroom 2 Window - Left
    pin:
      mcp23xxx: mcp23017_hub2
      number: 11
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Bedroom 2 Window - Right
    pin:
      mcp23xxx: mcp23017_hub2
      number: 12
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Office Window - Left
    pin:
      mcp23xxx: mcp23017_hub2
      number: 13
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Office Window - Right
    pin:
      mcp23xxx: mcp23017_hub2
      number: 14
      mode:
        input: true
        pullup: false
      inverted: false

# Pin number 15 is skipped as it is the 8th pin in group B and should not be used for inputs
# End of zones on MCP23017 Chip number 2



# Start of zones on MCP23017 Chip number 3
  - platform: gpio
    name: Bedroom 3 Window - Left
    pin:
      mcp23xxx: mcp23017_hub3
      number: 0
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Bedroom 3 Window - Right
    pin:
      mcp23xxx: mcp23017_hub3
      number: 1
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Bedroom 4 Window - Left
    pin:
      mcp23xxx: mcp23017_hub3
      number: 2
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Bedroom 4 Window - Right
    pin:
      mcp23xxx: mcp23017_hub3
      number: 3
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: 2nd Floor Hallway Motion
    pin:
      mcp23xxx: mcp23017_hub3
      number: 4
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Office Motion
    pin:
      mcp23xxx: mcp23017_hub3
      number: 5
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Front Door Glass Break
    pin:
      mcp23xxx: mcp23017_hub3
      number: 6
      mode:
        input: true
        pullup: false
      inverted: false

#Pin number 7 is skipped as it is the 8th pin in group A and should not be used for inputs

  - platform: gpio
    name: Morning Room Glass Break
    pin:
      mcp23xxx: mcp23017_hub3
      number: 8
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Morning Room Motion
    pin:
      mcp23xxx: mcp23017_hub3
      number: 9
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Dining Room Motion
    pin:
      mcp23xxx: mcp23017_hub3
      number: 10
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Living Room Motion
    pin:
      mcp23xxx: mcp23017_hub3
      number: 11
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Family Room Motion
    pin:
      mcp23xxx: mcp23017_hub3
      number: 12
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Spare
    pin:
      mcp23xxx: mcp23017_hub3
      number: 13
      mode:
        input: true
        pullup: false
      inverted: false

  - platform: gpio
    name: Overhead Garage Door
    pin:
      mcp23xxx: mcp23017_hub3
      number: 14
      mode:
        input: true
        pullup: false
      inverted: false

# Pin number 15 is skipped as it is the 8th pin in group B and should not be used for inputs
# End of zones on MCP23017 Chip number 3


# Using GPIO pins on the main ESP32 board for the outputs
switch:   
  - platform: gpio
    pin: 
      number: 25
      inverted: false
    id: alarm1
    name: Interior Sirens    
    icon: mdi:bullhorn

  - platform: gpio
    pin: 
      number: 26
      inverted: false 
    id: alarm2
    name: Exterior Sirens    
    icon: mdi:bullhorn

  - platform: gpio
    pin: 
      number: 27
      inverted: false 
    id: alarm3
    name: Strobe Light    
    icon: mdi:bullhorn