새창 작성 수정 목록 링크 Edit G카랜다 HDD HDD HDD 게시물 주소 복사


● ha작업) 현관문 열기 sensor.wifi 이전 상태를 저장하고 추적할 수 있도록 설정하여 자동화 구성

♨ 카랜더 일정 : 2024년09월12일
  • 링크

  • 첨부

  • 컨텐츠 정보

    본문

    ● ha작업) 현관문 열기 sensor.wifi  이전 상태를 저장하고 추적할 수 있도록 설정하여 자동화 구성


    현관문 열기에  >  무엇이 빠르게 인식 하는가

    1) ESP32 의 BLE인식 --->  ESP32의 TIME별 인식 시간 차이 발생

    2) WIFI 모바일 센서 외출에서 재실 인식 TIME차이 발생 

    ----> 스마트폰 모바일 WIFI 센서의 인식 차이

    3) BLE 인식후 도어 열기가 인식하다 다른 휴대폰은 인식 불가 발생


    < 동작 구성>

    1) 트리거> BLE 인식 >>  외출에서 재실 변화

    2) 조건> 1분전 의 상태가 WIFI 모바일 센서 외출 인식 ( 현제 상태가  외출에서 재실로 바로 변경  됨)

    3) 동작 > BLE 재실에서 무선 도어락 열기 


    3232235521_1726151162.9884.png

    ===============

    alias: 현관문 9045열기_BLE_wifi
    description: 현관문 9045열기_BLE_wifi
    trigger:
      - platform: state
        entity_id:
          - binary_sensor.9045_ble_ble2_tracker_s3pin_2410out_ip74
        from: "off"
        to: "on"
        enabled: true
    condition:
      - condition: template
        value_template: >
          {% set last_changed_9045 =
          as_timestamp(states.sensor.wifi_presence_status_9045.last_changed) %} {%
          set now = as_timestamp(now()) %} {% set previous_state_9045 =
          states('input_text.wifi_presence_previous_state_9045') %} {{ (now -
          last_changed_9045) < 60 and previous_state_9045 == '외출' }}
    action:
      - if:
          - condition: state
            entity_id: binary_sensor.9045_ble_ble2_tracker_s3pin_2410out_ip74
            state: "on"
        then:
          - action: light.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: light.ble2_tracker_s3pin_2410out_ip74_beef_sound
            enabled: true
          - delay:
              hours: 0
              minutes: 0
              seconds: 0
              milliseconds: 100
          - metadata: {}
            data: {}
            target:
              entity_id: switch.dooropen_socket_1
            action: switch.turn_on
          - delay:
              hours: 0
              minutes: 0
              seconds: 2
              milliseconds: 100
          - action: switch.turn_off
            target:
              entity_id: light.ble2_tracker_s3pin_2410out_ip74_beef_sound
            data: {}
          - metadata: {}
            data:
              cache: false
              entity_id: media_player.speaker_1
              message: "현관문 열기 되었습니다 ,_9045 door open "
            action: tts.google_say
        enabled: true
    mode: single

    동작 테스트

    3232235521_1726162693.9296.png


    =====  input_text 활용 상태 저장 구성 하기 ======

    상기 조건을 구성을 위하여 상태저장 센서를 추가 방법 ( 상기 그리고 만약에 설정)

    하겠습니다.

    input_text를 사용하여 두 센서의 이전 상태를 저장하고, 상태 변경 시 자동으로 업데이트되도록 할 수 있습니다.

    ● ha작업) sensor.wifi_presence_status_9045에 대해서도 이전 상태를 저장하고 추적할 수 있도록 설정

    을 추가하겠습니다. input_text를 사용하여 두 센서의 이전 상태를 저장하고, 상태 변경 시 자동으로 업데이트되도록 할 수 있습니다.

    1. input_text 구성

    yaml 코드

    input_text:
      wifi_presence_previous_state_5763:
        name: "Previous WiFi Presence Status 5763"
        initial: "Unknown"
      wifi_presence_previous_state_9045:
        name: "Previous WiFi Presence Status 9045"
        initial: "Unknown"

    2. 상태 변경 시 input_text 업데이트 자동화

    yaml 코드

    automation:
      - alias: Update Previous WiFi Presence Status 5763
        trigger:
          - platform: state
            entity_id: sensor.wifi_presence_status_5763
        action:
          - service: input_text.set_value
            target:
              entity_id: input_text.wifi_presence_previous_state_5763
            data:
              value: "{{ trigger.from_state.state }}"


      - alias: Update Previous WiFi Presence Status 9045
        trigger:
          - platform: state
            entity_id: sensor.wifi_presence_status_9045
        action:
          - service: input_text.set_value
            target:
              entity_id: input_text.wifi_presence_previous_state_9045
            data:
              value: "{{ trigger.from_state.state }}"
    3. 상태 변경 시 60초 이내의 이전 상태 확인 조건

    yaml 코드

    condition:
      - condition: template
        value_template: >
          {% set last_changed_5763 = as_timestamp(states.sensor.wifi_presence_status_5763.last_changed) %}
          {% set last_changed_9045 = as_timestamp(states.sensor.wifi_presence_status_9045.last_changed) %}
          {% set now = as_timestamp(now()) %}
          {% set previous_state_5763 = states('input_text.wifi_presence_previous_state_5763') %}
          {% set previous_state_9045 = states('input_text.wifi_presence_previous_state_9045') %}
          {{ (now - last_changed_5763) < 60 and previous_state_5763 == '외출' }}
          or
          {{ (now - last_changed_9045) < 60 and previous_state_9045 == '외출' }}

    이 설정으로:

    input_text.wifi_presence_previous_state_5763와 input_text.wifi_presence_previous_state_9045가 각각의 센서의 이전 상태를 저장합니다.
    상태가 변경될 때 자동으로 input_text가 업데이트됩니다.
    상태 변경이 60초 이내에 '외출'이었던 경우를 확인하는 조건을 설정합니다.
    이렇게 하면 두 센서 모두의 상태를 추적하고, 필요한 경우 적절히 비교할 수 있습니다.

    각 센서에 대해 개별적인 조건을 만들고자 하는 경우, 두 개의 별도의 템플릿 조건을 설정할 수 있습니다.

    아래는 각각의 조건을 분리한 예입니다:

    1. sensor.wifi_presence_status_5763의 조건
    yaml 코드 복사

    condition:
      - condition: template
        value_template: >
          {% set last_changed_5763 = as_timestamp(states.sensor.wifi_presence_status_5763.last_changed) %}
          {% set now = as_timestamp(now()) %}
          {% set previous_state_5763 = states('input_text.wifi_presence_previous_state_5763') %}
          {{ (now - last_changed_5763) < 60 and previous_state_5763 == '외출' }}

    이 조건은 sensor.wifi_presence_status_5763의 상태가 마지막으로 변경된 시각이 60초 이내이고, 이전 상태가 '외출'인지 확인합니다.

    2. sensor.wifi_presence_status_9045의 조건
    yaml 코드 복사

    condition:
      - condition: template
        value_template: >
          {% set last_changed_9045 = as_timestamp(states.sensor.wifi_presence_status_9045.last_changed) %}
          {% set now = as_timestamp(now()) %}
          {% set previous_state_9045 = states('input_text.wifi_presence_previous_state_9045') %}
          {{ (now - last_changed_9045) < 60 and previous_state_9045 == '외출' }}

    이 조건은
    sensor.wifi_presence_status_9045의 상태가 마지막으로 변경된 시각이 60초 이내이고,
    이전 상태가 '외출'인지 확인합니다.
    이렇게 설정하면 각 센서의 상태를 독립적으로 확인할 수 있습니다.

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

    [ 추가 정보 ... 더보기) ]
    뷰PDF 1,2



    office view

    관련자료

    댓글목록

    등록된 댓글이 없습니다.


    새창 작성 수정 목록 링크 Edit G카랜다 HDD HDD HDD 게시물 주소 복사


    ♥간단_메모글♥


    최근글


    새댓글



    PHP 안에 HTML ☞ 홈페이지 화면갱신 시간은 ♨
    ▶ 2024-09-18 06:38:16

    오늘의 홈 현황


    • 현재 접속자♨ 303 명
    • 오늘 가입자※ 0 명
    • 어제 가입자※ 4 명
    • 주간 가입자※ 13 명
    • 오늘 방문자 952 명
    • 어제 방문자 2,222 명
    • 최대 방문자 13,042 명
    • 전체 방문자 4,563,992 명
    • 전체 게시물※ 8,794 개
    • 전체 댓글수※ 25,098 개
    • 전체 회원수 11,242 명

    QR코드


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

    알림 0








    최신글↑