BFT Gate Controle (ESP Home)

Привет. Подключил свои автоматические ворота BFT к Home Assistant с помощью ESP8266 и прошивкой ESP Home. Вот схема подключения:

Перемычку надо вытащить с пинов 70 и 71.
Так же нужно настроить саму плату, ищите в интернете инструкцию по настройки платы. BFT Deimos Ultra Bt a400. Там есть схема захода в настройки, и все пункты в меню.
У меня:
SAFE 1 - 4 (при открытие не реагировать на датчики фотоэлемента)
IC 1 - 2 (это нужно для открытия ESP)
IC 2 - 3 (это нужно для закрытия ESP)

ESP Home - прошивка
Надо пометь параметры open_duration и close_duration на время, которое открывается и закрываются у вас ворота.

web_server:
  port: 80

binary_sensor:
  - platform: gpio
    pin: 
      number: D5
      mode:
        input: true
        pullup: true
      inverted: true
    name: Status OPEN BFT
    device_class: garage_door

  - platform: gpio
    pin: 
      number: D6
      mode:
        input: true
        pullup: true
      inverted: true
    name: Status CLOSE BFT
    device_class: garage_door


text_sensor:
  - platform: template
    name: "Uptime BFT"
    lambda: |-
      int seconds = (id(uptime_sec).state);
      int days = seconds / (24 * 3600);
      seconds = seconds % (24 * 3600); 
      int hours = seconds / 3600;
      seconds = seconds % 3600;
      int minutes = seconds /  60;
      seconds = seconds % 60;
      return { (String(days) +" д. " + String(hours) +" ч. " + String(minutes) +" мин.").c_str() };
    icon: mdi:clock
    update_interval: 113s
    
sensor: 
  - platform: wifi_signal
    name: WiFi Signal BFT
    update_interval: 120s  
  - platform: adc
    pin: VCC
    name: VCC Voltage BFT
    
  - platform: uptime
    name: "Uptime BFT"
    id: uptime_sec
    internal: true
    
switch:
  - platform: gpio
    pin:
      number: D1
      inverted: yes
    name: Open Always BFT
    id: relay_1
    restore_mode: ALWAYS_OFF
    interlock: &interlock_group [relay_1, open_switch, close_switch, stop_switch]

  - platform: template
    name: Open BFT
    id: open_switch
    turn_on_action:
      - switch.turn_on: relay_1
      - delay: 200ms
      - switch.turn_off: relay_1
    lambda: |-
      if (id(relay_1).state) {
        return true;
      } else {
        return false;
      }

  - platform: gpio
    pin:
      number: D2
      inverted: yes
    name: Close BFT
    id: close_switch
    interlock: *interlock_group
    restore_mode: ALWAYS_OFF
    on_turn_on:
      then:  
        - delay: 200ms
        - switch.turn_off: close_switch


  - platform: gpio
    name: Semaphore BFT
    pin: D3
    inverted: yes
    restore_mode: RESTORE_DEFAULT_ON
    id: relay_3

  
  - platform: gpio
    name: Stop BFT
    pin: D4
    inverted: no
    interlock: *interlock_group
    id: stop_switch
    on_turn_on:
      then:  
        - delay: 200ms
        - switch.turn_off: stop_switch

globals:
  - id: global1
    type: int
    initial_value: '0'
        
cover:
  - platform: time_based
    name: "BFT Time-Based"
    device_class: garage
    id: vorota_dom
    has_built_in_endstop: true
    open_action:
      - switch.turn_on: open_switch
    open_duration: 22.40s
    close_action:
      - globals.set:
          id: global1
          value: !lambda |-
            return id(vorota_dom).position;
      - switch.turn_on: close_switch
    close_duration: 22.40s
    stop_action:
      - globals.set:
          id: global1
          value: !lambda |-
            return id(vorota_dom).position;
      - switch.turn_on: stop_switch

lovelace

      - type: grid
        square: false
        columns: 2
        cards:
          - type: markdown
            content: |
                      **{{ states('binary_sensor.status_close_bft') | replace("on","Ворота закрыты") | replace("off","Ворота открыты") }}: {% set t = states('sensor.time')%} {{ relative_time(states.binary_sensor.status_close_bft.last_changed) | replace("hours","ч.") | replace("minutes","мин.") |  replace("seconds","сек.") | replace("hour","ч.") |  replace("minute","мин.") | replace("day","д.")  }} назад**
          - type: custom:mushroom-cover-card
            entity: cover.bft_time_based
            fill_container: true
            primary_info: none
            secondary_info: none
            icon_type: none
            show_position_control: true

      - type: horizontal-stack
        cards:
          - type: conditional
            conditions:
              - entity: binary_sensor.status_open_bft
                state_not: 'on'
            card:
                show_name: true
                show_icon: true
                type: button
                tap_action:
                  action: call-service
                  service: cover.open_cover
                  service_data: {}
                  target:
                    entity_id: cover.bft_time_based
                entity: binary_sensor.status_open_bft
                name: Открыть
                icon: mdi:gate-arrow-right
                show_state: true

          - type: conditional
            conditions:
              - entity: binary_sensor.status_open_bft
                state_not: 'on'
              - entity: binary_sensor.status_close_bft
                state_not: 'on'
            card:
              show_name: true
              show_icon: true
              type: button
              tap_action:
                action: call-service
                service: cover.stop_cover
                service_data: {}
                target:
                  entity_id: cover.bft_time_based
              entity: binary_sensor.status_open_bft
              icon: mdi:stop-circle
              name: Стоп

          - type: conditional
            conditions:
              - entity: cover.bft_time_based
                state_not: opening
              - entity: binary_sensor.status_close_bft
                state_not: 'on'
            card:
              show_name: true
              show_icon: true
              type: button
              tap_action:
                action: call-service
                service: cover.close_cover
                service_data: {}
                target:
                  entity_id: cover.bft_time_based
              entity: binary_sensor.status_open_bft
              icon: mdi:gate-arrow-left
              name: Закрыть ворота
              show_state: true

          - type: conditional
            conditions:
              - entity: binary_sensor.status_close_bft
                state: 'on'
            card:
              show_name: true
              show_icon: true
              type: button
              tap_action:
                action: call-service
                service: cover.set_cover_position
                service_data:
                  position: 40
                target:
                  entity_id: cover.bft_time_based
              entity: binary_sensor.status_open_bft
              icon: ''
              name: Режим калитки
              show_state: true

Можно создать любые автоматизации, когда машина заведена - открыть, утром открыть. Зимой открывать, что бы не замерзли. Автоматически закрывать.

Примеры:

- id: BFT Gate - Controle morning WORK (OPEN)
  alias: BFT Gate - контроль утром на работу (открыть на выезд)
  mode: single
  trigger:
    platform: time
    at: "06:14:00"
  condition:
    - condition: time
      weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
  action:
  - service: switch.turn_on
    target:
      entity_id: switch.open_always_bft
  - service: notify.telegram_group
    data:
      message: Ворота открыты по времени 

- id: BFT Gate - Zone Silmala Enter (Open)
  alias: BFT Gate - Вход в Зону Силмала (Открыть)
  trigger:
  - platform: zone
    entity_id: sensor.car_gps_sensor
    zone: zone.silmala
    event: enter
  condition:
  - condition: state
    entity_id: binary_sensor.status_close_bft
    state: "on"
  action:
  - service: switch.turn_on
    target:
      entity_id: switch.open_always_bft
  - service: notify.telegram_group
    data:
      message: Машина вошла в зону посёлка. Ворота открыты.
  mode: single

- id: BFT Gate - ENTER Zone Home (Closed)
  alias: BFT Gate - Вход в зону дома (Закрыть)
  trigger:
  - platform: zone
    entity_id: sensor.car_gps_sensor
    zone: zone.home
    event: enter
  - platform: state
    entity_id:
      - person.anti_spy
      - person.ieva
    from: not_home
    to: home
  condition:
  - condition: state
    entity_id: switch.open_always_bft
    state: "on"
  action:
  - service: switch.turn_off
    target:
      entity_id: switch.open_always_bft
  - service: notify.telegram_group
    data:
      message: Ворота закрываются по таймеру.
  mode: single

- id: BFT Gate - Open to Bluetooth
  alias: BFT Gate - Открытие по Bluetooth
  mode: single
  trigger:
  # Телефон Максима
    - platform: template
      value_template: >
        {{ '00:00:01:18:DC:B9 (睿米车载蓝牙播放器)' in state_attr('sensor.sm_g965f_bluetooth_connection', 'connected_paired_devices') }}
    - platform: template
      value_template: >
        {{ '00:10:3D:E8:2F:AC (Nokia CK-7W)' in state_attr('sensor.sm_g965f_bluetooth_connection', 'connected_paired_devices') }}
  # Телефон Иева
    - platform: template
      value_template: >
        {{ '00:00:01:18:DC:B9 (睿米车载蓝牙播放器)' in state_attr('sensor.vog_l29_bluetooth_connection', 'connected_paired_devices') }}
    - platform: template
      value_template: >
        {{ '00:10:3D:E8:2F:AC (Nokia CK-7W)' in state_attr('sensor.vog_l29_bluetooth_connection', 'connected_paired_devices') }}
  condition:
    - condition: state
      entity_id: binary_sensor.status_close_bft
      state: "on"
  action:
    - service: switch.turn_on
      target:
        entity_id: switch.open_always_bft
    - service: notify.telegram_group
      data:
        message: Ворота открыты (bluetooth)!
Summary





2 Likes