## MoseHouse 2touch switch
## �����̹�

substitutions:
  node_name: mosehouse02_2touch
  device_name: MoseHouse02 2Touch

esphome:
  name: ${node_name}
  platform: ESP8266
  board: esp01_1m
  on_boot:
    priority: -50
    then:      
      - delay: 10s
      - homeassistant.service:
          service: notify.theniz_telegram
          data:
            message: "Esphome ${device_name}��(��) ���� �Ǿ����ϴ�."

wifi:
  ssid: # WiFi SSID ���
  password: # WiFi ��ȣ ���

logger:

api:

ota:

time:
  - platform: sntp
    timezone: UTC-9
    servers:
      - time.bora.net
      - 0.pool.ntp.org
      - 1.pool.ntp.org

sensor:
  - platform: wifi_signal
    name: "${device_name} Wifi Signal"
    id: wifi_sig
    internal: true
    update_interval: 60s
  - platform: template
    name: "${device_name} Wifi Quality"
    icon: "mdi:wifi"
    update_interval: 60s
    unit_of_measurement: '%'
    accuracy_decimals: 0
    lambda: !lambda |-
      if (id(wifi_sig).state < -92.0) {
        return 100.0;
      } else if (id(wifi_sig).state > -21.0) {
        return 1.0;
      } else {
        return round(( -0.0154 * id(wifi_sig).state * id(wifi_sig).state )-( 0.3794 * id(wifi_sig).state ) + 98.182 );
      }

# �Է���ġ ����
binary_sensor:
  # touch 1st
  - platform: gpio
    internal: true
    pin:
      number: GPIO12
      mode: INPUT
      inverted: True
    name: "touch1"
    on_press:
      - switch.toggle: button1
  
  # touch 2st
  #- platform: gpio
  #  internal: true
  #  pin:
  #    number: GPIO3
  #    mode: INPUT
  #    inverted: True
  #  name: "touch2"
  #  on_press:
  #    - switch.toggle: button2
  
  # touch 3st
  - platform: gpio
    internal: true
    pin:
      number: GPIO5
      mode: INPUT
      inverted: True
    name: "touch3"
    on_press:
      - switch.toggle: button3

# ���۹�ư = �����ġ ����
switch:
  # Button 1 / Relay 1st
  - platform: gpio
    name: ${device_name} Button1"
    pin: GPIO13
    id: button1
    icon: "mdi:lightbulb"
    on_turn_on:
      - switch.turn_on: led1
    on_turn_off:
      - switch.turn_off: led1
  
  # Button 2 / Relay 2st
  #- platform: gpio
  #  name: ${device_name} Button2"
  #  pin: GPIO4
  #  id: button2
  #  icon: "mdi:lightbulb"
  #  on_turn_on:
  #    - switch.turn_on: led2
  #  on_turn_off:
  #    - switch.turn_off: led2
  
  # Button 2 / Relay 3st
  - platform: gpio
    name: ${device_name} Button2"  # <-- rename
    pin: GPIO15
    id: button3
    icon: "mdi:lightbulb"
    on_turn_on:
      - switch.turn_on: led3
    on_turn_off:
      - switch.turn_off: led3
  
  # LED ����
  # LED 1st
  - platform: gpio
    internal: true
    name: "LED1"
    pin: GPIO16
    id: led1
  
  # LED 2st
  #- platform: gpio
  #  internal: true
  #  name: "LED2"
  #  pin: GPIO14
  #  id: led2
  
  # LED 3st
  - platform: gpio
    internal: true
    name: "LED3"
    pin: GPIO2
    id: led3

# ����ED ����
status_led:
  pin:
    number: GPIO0
    # inverted: yes