Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- esphome:
- name: "garage-presence"
- friendly_name: "garage-presence"
- platform: ESP32
- board: esp32dev
- # Enable logging
- logger:
- # Enable Home Assistant API
- api:
- encryption:
- key: "*********"
- ota:
- password: "********"
- wifi:
- ssid: !secret wifi_ssid
- password: !secret wifi_password
- manual_ip:
- static_ip: 10.0.0.86
- gateway: 10.0.0.1
- subnet: 255.255.255.0
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: "Garage Presence Fallback Hotspot"
- password: "*******"
- captive_portal:
- esp32_ble_tracker:
- id: ble_tracker_id
- scan_parameters:
- interval: 10s
- window: 1100ms
- active: false
- ## I used this bit to figure out which byte held the battery data, it was byte 1.
- # on_ble_advertise:
- # - mac_address: **:**:**:**:**:**
- # then:
- # - lambda: |-
- # for (auto data : x.get_service_datas())
- # ESP_LOGI("main", "Data Update UUID: %s Data: %s", data.uuid.to_string().c_str(), format_hex_pretty(data.data).c_str());
- on_ble_service_data_advertise:
- - mac_address: **:**:**:**:**:**
- service_uuid: "5242"
- then:
- - lambda: |-
- id(penny_mazda_battery).publish_state(x[1]);
- binary_sensor:
- - platform: ble_presence
- mac_address: **:**:**:**:**:**
- id: penny_mazda
- name: "Penny Mazda"
- device_class: "presence"
- icon: mdi:car
- filters:
- - delayed_off: 30s
- on_press:
- - script.execute: ble_active_scan
- sensor:
- - platform: ble_rssi
- mac_address: **:**:**:**:**:**
- id: penny_mazda_rssi
- name: "Penny Mazda RSSI"
- entity_category: "diagnostic"
- - platform: template
- id: penny_mazda_battery
- name: "Penny Mazda Battery"
- device_class: "battery"
- unit_of_measurement: "%"
- entity_category: "diagnostic"
- accuracy_decimals: 0
- script:
- - id: ble_active_scan
- mode: single
- then:
- - lambda: |-
- id(ble_tracker_id).stop_scan();
- - delay: 2s
- - lambda: |-
- id(ble_tracker_id).set_scan_active(true);
- id(ble_tracker_id).start_scan();
- - logger.log:
- format: Active scan started
- level: INFO
- - delay: 30s
- - logger.log:
- format: Active scan stopped
- level: INFO
- - lambda: |-
- id(ble_tracker_id).stop_scan();
- - delay: 2s
- - lambda: |-
- id(ble_tracker_id).set_scan_active(false);
- id(ble_tracker_id).start_scan();
- interval:
- - interval: 10min
- then:
- - script.execute: ble_active_scan
- button:
- - platform: template
- name: "BLE Active Scan"
- id: run_active_scan
- on_press:
- - script.execute: ble_active_scan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement