substitutions:
  device_name: kc868-a8-d758d0
  friendly_name: kc868-a8
  project_name: "kc868.a8"
  project_version: "1.0"
  adresse_ip: 10.0.2.177
  #outlet_icon: mdi:power-socket-au
  #switch_restore: ALWAYS_ON

packages:
  ## include wifi networks, manual_ip, ap
  wifi: !include common/wifi.yaml
  #include logger with syslog, api, ota, webserver, captive portal
  device_base: !include common/device_base.yaml

esphome:
  name: "${device_name}"
  name_add_mac_suffix: true
  friendly_name: ${friendly_name}
  project:
    name: "${project_name}"
    version: "${project_version}"

esp32:
  board: esp32dev

 

# Example configuration entry for ESP32
i2c:
  sda: 4
  scl: 5
  scan: true
  id: bus_a


# Example configuration entry
pcf8574:
  - id: "pcf8574_hub_out_1" # for output channel 1-8
    address: 0x24

  - id: "pcf8574_hub_in_1" # for input channel 9-16
    address: 0x22

switch:
#include restart
  - <<: !include common/generic_switch.yaml

  - platform: gpio
    name: "relay1_kc"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 0
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "relay2_kc"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 1
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "relay3_kc"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 2
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "relay4_kc"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 3
      mode: OUTPUT
      inverted: true
# eclairage plafond est branché entre NC et commum
  - platform: gpio
    name: "eclairage plafond_kc"
  #      name: "relay5"
    restore_mode: ALWAYS_ON
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 4
      mode: OUTPUT
      inverted: false
# niche cuisine est branché entre NC et commum
  - platform: gpio
    name: "niche cuisine_kc"
    restore_mode: ALWAYS_ON
    #    name: "relay6"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 5
      mode: OUTPUT
      inverted: false
# tableau domotique est branché entre NC et commum
  - platform: gpio
    name: "tableau_domo_kc"
     #   name: "relay7"
    restore_mode: ALWAYS_ON
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 6
      mode: OUTPUT
      inverted: false
# lumiere comble est branché entre N0 et commum
  - platform: gpio
    name: "lumiere_comble_kc"
    #name: "relay8"
    pin:
      pcf8574: pcf8574_hub_out_1
      number: 7
      mode: OUTPUT
      inverted: true

binary_sensor:
#include status
  - <<: !include common/generic_binarysensor.yaml
  # - platform: gpio
  #   name: "input1"
  #   pin:
  #     pcf8574: pcf8574_hub_in_1
  #     number: 0
  #     mode: INPUT
  #     inverted: true

  # - platform: gpio
  #   name: "input2"
  #   pin:
  #     pcf8574: pcf8574_hub_in_1
  #     number: 1
  #     mode: INPUT
  #     inverted: true

  # - platform: gpio
  #   name: "input3"
  #   pin:
  #     pcf8574: pcf8574_hub_in_1
  #     number: 2
  #     mode: INPUT
  #     inverted: true

  # - platform: gpio
  #   name: "input4"
  #   pin:
  #     pcf8574: pcf8574_hub_in_1
  #     number: 3
  #     mode: INPUT
  #     inverted: true

  # - platform: gpio
  #   name: "input5"
  #   pin:
  #     pcf8574: pcf8574_hub_in_1
  #     number: 4
  #     mode: INPUT
  #     inverted: true

  # - platform: gpio
  #   name: "input6"
  #   pin:
  #     pcf8574: pcf8574_hub_in_1
  #     number: 5
  #     mode: INPUT
  #     inverted: true

  - platform: gpio
    name: "interrupteur_chambre1"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 6
      mode: INPUT
      inverted: false
    filters:
      - delayed_on: 80ms

  - platform: gpio
    name: "porte_dressing"
    pin:
      pcf8574: pcf8574_hub_in_1
      number: 7
      mode: INPUT
      inverted: false
    device_class: door
    filters:
      - delayed_on: 60ms


dallas:
  - pin: GPIO14
    update_interval: 240s


sensor:
#include uptime et wifisignal
  - <<: !include common/generic_sensor.yaml

  - platform: dallas
    address: 0x50031771df43ff28
    name: "Temp_salon"

  - platform: bh1750
    name: "BH1750 Illuminance"
    address: 0x23
    update_interval: 20s

text_sensor:
#include wifi info : ipaddress ssid
  - <<: !include common/generic_textsensor.yaml
