跳转到内容

暴露通知监听器

exposure_notifications 组件使用 Esp32 Ble 跟踪器来发现 运行 Google/Apple 暴露通知服务的手机发送的附近 COVID-19 暴露通知蓝牙消息。

# Example configuration entry
esp32_ble_tracker:
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);

暴露通知载荷包含:

  • 滚动邻近标识符(RPI):一个 16 字节长的值,用于在 10 分钟的时间窗口内识别给定的设备。
  • 关联的加密元数据(AEM):额外的加密元数据,如发射功率。

由于 GAEN 框架旨在防止跟踪个人,这些数据基本上只能用来检查启用暴露通知的设备是否在附近(并在有限程度上对它们进行计数)。

以下配置可以用作暴露通知启用的设备是否在附近的指示器。只要在过去一分钟内收到过暴露通知,指示器就会亮起。

esp32_ble_tracker:
switch:
- platform: gpio
pin: GPIOXX
id: led
script:
- id: start_led
then:
- switch.turn_on: led
- delay: 1min
- switch.turn_off: led
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);
# Stop existing timer so that turn_off doesn't get called
- script.stop: start_led
- script.execute: start_led