● ha작업) esp32 basic esphome 소스 2024_0410_0025_38




컨텐츠 정보


본문

● ha작업) esp32 basic esphome 소스 2024_0410_0025_38

3232235521_1712676627.4635.png

# esp32 basic esphome 소스 2024_0410_0025_38
esphome:
  name: "esp32-wroom-32-30pin"
  friendly_name: esp32_wroom_32_30pin

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
# logger:

# Enable Home Assistant API
api:
  encryption:
    key: "qA8xG6A2GaF7KqwZ6+a?????De2VxY/DA+FrrE="
  on_client_connected:
    - esp32_ble_tracker.start_scan: # C3 제품 싱글코어
       continuous: true
  on_client_disconnected:
    - esp32_ble_tracker.stop_scan:
     
ota:
  password: "d296a80ce1????e34ee35"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # ======================================
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  # add install after setting 1
  power_save_mode: LIGHT  
  manual_ip:
    static_ip: 192.168.0.119
    gateway: 192.168.0.1
    subnet: 255.255.255.0
    dns1: 8.8.8.8
    dns2: 8.8.4.4
  # ======================================
  ap:
    ssid: "Esp32-Woom Fallback Hotspot"
    password: "BodMG8v8lv1M"

captive_portal:
  # ======================================
# 초기 설치후 연결 작업 후에
# captive_portal: 다음에 붙여넣습니다.
  # ======================================
uart:
  rx_pin: GPIO3
  tx_pin: GPIO1
  baud_rate: 9600

   

logger:
  level: DEBUG  

time:
  - platform: homeassistant
    id: ha_time
# =================
debug:
  update_interval: 60s

# left-top no1 reversclock
# #no 15 = 5V (좌하단 상으로1)
# #no 16 = 3.3v (우하단 상으로1)
# #no 14(좌하단 상으로 2) = GND
# #no 17(우하단 상으로 2) = GND
# #no 21 = GPIO16
# #no 5 = GPIO35
# #no 10 = GPIO27

output:

  - platform: gpio
    pin: GPIO16
    id: pir_led_output_gpio16
    inverted: true

# =============
  - platform: gpio
    pin: GPIO32
    id: ble_led_output_gpio32
    inverted: true

  - platform: gpio
    pin: GPIO27
    id: sesing_led_output_gpio27
    inverted: true
 

light:
  - platform: binary
    name: "1_pir_led_output_gpio16_sw"
    output: pir_led_output_gpio16
    id: pir_led_output_gpio16_light

  - platform: binary
    name: "2_ble_led_output_gpio33_sw"
    output: ble_led_output_gpio32
    id: ble_led_output_gpio32_light

  - platform: binary
    name: "3_sesing_led_output_gpio27_sw"
    output: sesing_led_output_gpio27
    id: sesing_led_output_gpio27_light

switch:
  - platform: restart
    name: "Restart Node"
# switch:
  - platform: template
    name: "PIR Reset Count"
    turn_on_action:
      - lambda: |-
          id(seconds_since_last_detection) = 0;
          id(uptime_sensor).publish_state(std::to_string(id(seconds_since_last_detection)));    
# ========================================================
# ==========================================================        #
text_sensor:
  - platform: template
    name: PIR_uptime_sensor
    update_interval: 1s
    id: uptime_sensor
    entity_category: diagnostic
    lambda: |-
      if (id(pir_led_output_gpio16_motion).state) {
        id(seconds_since_last_detection) = 0;
      }
      id(seconds_since_last_detection)++;
      unsigned long uptime_seconds = id(seconds_since_last_detection);
      return esphome::optional<std::string>(std::to_string(uptime_seconds));


  - platform: version
    name: "Install Restart Time ESPHome Version"

  - platform: debug
    device:
      name: "Device Info"
    reset_reason:
      name: "Reset Reason"

  - platform: wifi_info
    ip_address:
      name: Address
      id: ip
    ssid:
      name: SSID
    mac_address:
      name: Mac

  - platform: template
    name: Uptime
    update_interval: 1s
    lambda: |-
      auto s = millis() / 1000;
      return str_snprintf("%02d:%02d:%02d:%02d", 11, s / 86400, s / 3600 % 24, s / 60 % 60, s % 60);

  - platform: template
    name: "PIR Sensor Counter"
    id: pir_countup
   
  - platform: template
    name: "PIR Last Trigger"
    id: pir_last_trigger

  - platform: template
    name: Uptime_PIR_Off
    update_interval: 1s
    entity_category: diagnostic
    lambda: |-
      if (id(pir_led_output_gpio16_motion).state) {
        id(seconds_since_last_detection) = 0;
      }
      id(seconds_since_last_detection)++;
      unsigned long uptime_seconds = id(seconds_since_last_detection);
      return esphome::optional<std::string>(std::to_string(uptime_seconds));

interval:
  - interval: 1s
    then:
      - if:
          condition:
            binary_sensor.is_on: pir_led_output_gpio16_motion
          then:
            - lambda: |-
                static int seconds_since_last_detection = 0;
                seconds_since_last_detection++;
                id(uptime_sensor).publish_state(std::to_string(seconds_since_last_detection));
          else:
            - lambda: |-
                static int seconds_since_last_detection = 0;
                seconds_since_last_detection = 0;

globals:
  - id: seconds_since_last_detection
    type: int
    restore_value: no
    initial_value: '0'

# ========================================      #

# wifi power_save_mode: LIGHT
bluetooth_proxy:
  active: false

esp32_ble_tracker:
  scan_parameters:  # 휴대폰 blu 인식 정보
    interval: 1100ms  # 스캔 간격을 더 자주 스캔하도록 변경
    window: 1100ms     # 스캔 창을 더 넓게 설정하여 더 많은 장치를 감지할 수 있도록 함
    active: true     # 활성 스캔 활성화

binary_sensor:
  - platform: ble_presence
    ibeacon_uuid: 'a26fbca9????aab3e0defc4e'
    name: "my_phone_9045"
    id: my_phone_9045
    timeout: 50s
    on_press:
      then:
        - light.turn_on: ble_led_output_gpio32_light
    on_release:
      then:
        - light.turn_off: ble_led_output_gpio32_light

  - platform: ble_presence
    ibeacon_uuid: '7cad13d3-e0????71-c2a27e46695c'
    name: "wife_phone_5763"
    id: wife_phone_5763
    timeout: 50s
      # on_press:
      #   then:
      #     - light.turn_on: ble_led_output_gpio32_light
      # on_release:
      #   then:
      #     - light.turn_off: ble_led_output_gpio32_light

  - platform: ble_presence
    ibeacon_uuid: '4f36ad4e-d??????b-447f9de146b5'
    name: "home_phone_8655"
    id: home_phone_8655
    timeout: 50s

# =========================
  - platform: gpio
    pin: GPIO2
    name: "PIR Sensor"
    device_class: motion
    id: pir_led_output_gpio16_motion
    on_press:
      then:
        - light.turn_on: pir_led_output_gpio16_light
        - text_sensor.template.publish:
            id: pir_countup
            state: !lambda |-
              static int pir_counter = 0;
              pir_counter++;
              id(pir_last_trigger).publish_state(std::to_string(pir_counter));
              // 매 60분마다 초기화
              if ((millis() / 60000) % 60 == 0) pir_counter = 0;
              return std::to_string(pir_counter);        
    on_release:
      then:
        - light.turn_off: pir_led_output_gpio16_light


sensor:
  - platform: uptime
    name: Uptime
    update_interval: 60s
   
  - platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
    name: "WiFi Signal dB"
    id: wifi_signal_db
    update_interval: 60s
    entity_category: "diagnostic"

  - platform: copy # Reports the WiFi signal strength in %
    source_id: wifi_signal_db
    name: "WiFi Signal Percent"
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "Signal %"
    entity_category: "diagnostic"
    device_class: ""
# # ===========================================  #  

☞ https://11q.kr 에 등록된 자료 입니다. ♠ 정보찾아 공유 드리며 출처는 링크 참조 바랍니다♠1.png

뷰PDF add1,add2



관련자료




♥간단_메모글♥


최근글


새댓글



PHP 안에 HTML ☞ 홈페이지 화면갱신 시간은 ♨
▶ 2024-11-23 00:52:09

오늘의 홈 현황


  • 현재 접속자♨ 361 명
  • 오늘 가입자※ 0 명
  • 어제 가입자※ 3 명
  • 주간 가입자※ 9 명
  • 오늘 방문자 1,315 명
  • 어제 방문자 3,461 명
  • 최대 방문자 13,042 명
  • 전체 방문자 4,803,932 명
  • 전체 게시물※ 8,855 개
  • 전체 댓글수※ 25,231 개
  • 전체 회원수 11,325 명

QR코드


☞ QR코드 스캔은 kakao앱 자체 QR코드

알림 0








최신글↑