219 lines
5.6 KiB
Django/Jinja
219 lines
5.6 KiB
Django/Jinja
---
|
|
|
|
substitutions:
|
|
id_prefix: "{{ item.name.replace('-', '_') }}"
|
|
|
|
esphome:
|
|
name: "{{ item.name }}"
|
|
name_add_mac_suffix: false
|
|
#friendly_name: BLE Monitor
|
|
#project:
|
|
# name: esphome.bluetooth-proxy
|
|
# version: "1.0"
|
|
|
|
esp32:
|
|
board: nodemcu-32s
|
|
|
|
logger:
|
|
|
|
api:
|
|
encryption:
|
|
key: "{{ hass_esphome_api_key }}"
|
|
|
|
ota:
|
|
- platform: esphome
|
|
id: esphome_ota
|
|
password: "{{ hass_esphome_ota_password }}"
|
|
|
|
wifi:
|
|
ssid: "{{ hass_esphome_wifi_ssid }}"
|
|
password: "{{ hass_esphome_wifi_password }}"
|
|
domain: .{{ inventory_hostname.split('.')[1:] | join('.') }}
|
|
# use_address:
|
|
|
|
ap:
|
|
# ssid:
|
|
password: "{{ hass_esphome_fallback_wifi_password }}"
|
|
|
|
mdns:
|
|
disabled: true
|
|
|
|
captive_portal:
|
|
|
|
web_server:
|
|
port: 80
|
|
version: 2
|
|
include_internal: true
|
|
js_url: "https://www.{{ domain }}/esphome/webserver-v2.min.js"
|
|
|
|
esp32_ble_tracker:
|
|
#scan_parameters:
|
|
# active: true
|
|
|
|
#bluetooth_proxy:
|
|
# active: true
|
|
# cache_services: true
|
|
|
|
ble_client:
|
|
{% for item in hass_esphome_ble_client %}
|
|
{% set item_id = item.name.lower().replace(' ', '_').replace('-', '_').replace("'","").replace('.', '_') %}
|
|
- mac_address: {{ item.mac }}
|
|
id: "ble_client_{{ item_id }}"
|
|
{% endfor %}
|
|
|
|
|
|
binary_sensor:
|
|
{% for ble_device in hass_esphome_ble_presence %}
|
|
{% set ble_device_id = ble_device.name.lower().replace(' ', '_').replace('-', '_').replace("'","").replace('.', '_') %}
|
|
- platform: ble_presence
|
|
{% if 'ibeacon_uuid' in ble_device -%}
|
|
ibeacon_uuid: {{ ble_device.ibeacon_uuid }}
|
|
{% else -%}
|
|
mac_address: {{ ble_device.mac }}
|
|
{% endif -%}
|
|
name: "BLE {{ ble_device.name }}"
|
|
id: "ble_{{ ble_device_id }}"
|
|
{% if ble_device.disable_delay_off|default(false) != true -%}
|
|
filters:
|
|
- delayed_off: "{{ ble_device.delay_off | default('5min') }}"
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
- platform: status
|
|
name: "{{ item.name }} ESHome status"
|
|
entity_category: "diagnostic"
|
|
id: ${id_prefix}_status
|
|
|
|
## A sensor that always is (should be) true, just to clearly mark
|
|
## an esphome node as a BLE proxy (if it is one).
|
|
#- platform: template
|
|
# id: is_ble_proxy
|
|
# #name: "{{ item.name }} ESPHome BLE Proxy"
|
|
# name: "ESPHome BLE Proxy blemon"
|
|
# icon: "mdi:bluetooth"
|
|
# publish_initial_state: true
|
|
# internal: false
|
|
# disabled_by_default: false
|
|
# entity_category: "diagnostic"
|
|
|
|
sensor:
|
|
|
|
{% for item in hass_esphome_ble_client %}
|
|
{% set item_id = item.name.lower().replace(' ', '_').replace('-', '_').replace("'","").replace('.', '_') %}
|
|
- platform: ble_client
|
|
type: characteristic
|
|
ble_client_id: "ble_client_{{ item_id }}"
|
|
name: "Battery level BLE client {{ item.name }}"
|
|
service_uuid: '180f'
|
|
characteristic_uuid: '2a19'
|
|
icon: 'mdi:battery'
|
|
unit_of_measurement: '%'
|
|
|
|
{% endfor %}
|
|
|
|
{% for ble_device in hass_esphome_ble_presence %}
|
|
{% if ble_device.track_rssi|default(false) %}
|
|
{% set ble_device_id = ble_device.name.lower().replace(' ', '_').replace('-', '_').replace("'", "").replace('.', '_') %}
|
|
- platform: ble_rssi
|
|
{% if 'ibeacon_uuid' in ble_device -%}
|
|
ibeacon_uuid: {{ ble_device.ibeacon_uuid }}
|
|
{% else -%}
|
|
mac_address: {{ ble_device.mac }}
|
|
{% endif -%}
|
|
name: "RSSI {{ ble_device.name }}"
|
|
id: "ble_{{ ble_device_id }}_rssi"
|
|
internal: true
|
|
filters:
|
|
- throttle: 900s
|
|
|
|
- platform: copy
|
|
source_id: "ble_{{ ble_device_id }}_rssi"
|
|
name: "Signal {{ ble_device.name }}"
|
|
id: "ble_{{ ble_device_id }}_signal"
|
|
unit_of_measurement: "%"
|
|
device_class: power_factor
|
|
filters:
|
|
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
# ESPHome
|
|
- platform: internal_temperature
|
|
name: "{{ item.name }} ESP Temperature"
|
|
|
|
- platform: wifi_signal
|
|
internal: true
|
|
name: "{{ item.name }} WiFi signal strength"
|
|
id: ${id_prefix}_wifi_signal_strength
|
|
update_interval: 60s
|
|
entity_category: "diagnostic"
|
|
unit_of_measurement: "dBm"
|
|
filters:
|
|
- throttle: 900s
|
|
|
|
- platform: copy
|
|
source_id: ${id_prefix}_wifi_signal_strength
|
|
name: "{{ item.name }} WiFi signal"
|
|
unit_of_measurement: "%"
|
|
device_class: power_factor
|
|
entity_category: "diagnostic"
|
|
filters:
|
|
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
|
|
|
|
switch:
|
|
- platform: restart
|
|
name: "{{ item.name }} reboot"
|
|
icon: mdi:power-cycle
|
|
id: ${id_prefix}_reboot
|
|
|
|
- platform: gpio
|
|
name: "{{ item.name }} BLE exposure notification seen"
|
|
pin: GPIO22
|
|
id: exp_notif
|
|
|
|
script:
|
|
- id: exp_notif_on
|
|
then:
|
|
- switch.turn_on: exp_notif
|
|
- delay: 15min
|
|
- switch.turn_off: exp_notif
|
|
|
|
exposure_notifications:
|
|
on_exposure_notification:
|
|
then:
|
|
#- lambda: |
|
|
# ESP_LOGD("main", "Got notification:");
|
|
# ESP_LOGD("main", " RPI: %s", format_hex_pretty(x.rolling_proximity_identifier).c_str());
|
|
# ESP_LOGD("main", " RSSI: %d", x.rssi);
|
|
- script.stop: exp_notif_on
|
|
- script.execute: exp_notif_on
|
|
button:
|
|
- platform: wake_on_lan
|
|
name: "{{ item.name }} Wake-on-LAN TV Livingroom"
|
|
target_mac_address: {{ s21_mac_samsung_tv }}
|
|
|
|
text_sensor:
|
|
- platform: wifi_info
|
|
ip_address:
|
|
name: "{{ item.name }} IP address"
|
|
entity_category: "diagnostic"
|
|
ssid:
|
|
name: "{{ item.name }} SSID"
|
|
entity_category: "diagnostic"
|
|
mac_address:
|
|
name: "{{ item.name }} WiFi mac address"
|
|
entity_category: "diagnostic"
|
|
dns_address:
|
|
name: "{{ item.name }} DNS address"
|
|
entity_category: "diagnostic"
|
|
- platform: version
|
|
id: ${id_prefix}_version
|
|
entity_category: "diagnostic"
|
|
name: "{{ item.name }} ESPHome version"
|
|
|
|
|
|
|
|
# from esphome/bluetooth-proxies/esp32-generic.yaml, see https://esphome.io/components/improv_serial.html
|
|
# improv_serial:
|