Link Search Menu Expand Document

Parse data from ESPHome


Table of contents

Parse_data service

Introduction

BLE monitor has a service to parse BLE advertisements. This service can e.g. be used with ESPHome BLE Gateway.

You can also use this service to debug for you own home-brew sensor, as long as you make sure you follow the format of one of the existing sensors or better, our own HA BLE format.

In this example you can see the BLE data packet from device with MAC address A4:C1:38:B4:94:4C, in the packet it’s in reverse order 4C94B438C1A4. The BLE packet should be in HCI format, with packet type HCI Event (0x04). The gateway id is optional and can e.g. be used to identify which ESPHome device did receive the message, which can be usefull for room localization.

parse_data_service

Example of an automation

The automation example below is parsing BLE advertisements that are received by ESPHome BLE Gateway. At the moment a BLE advertisement arrives (trigger), it is calling the parse_data service (action) with the received data. BLE Monitor will than take care of the rest, and will add and/or update your BLE Monitor sensors, similar as like it has received an BLE advertisement via the Bluetooth adapter.

automation:
  - alias: ESPHome BLE Advertise
    mode: queued
    trigger:
      - platform: event
        event_type: esphome.on_ble_advertise
    action:
      - service: ble_monitor.parse_data
        data:
          packet: "{{ trigger.event.data.packet }}"
          gateway_id: "{{ trigger.event.data.gateway_id }}" # Optional. If your gateway sends.

More information on how to configure ESPHome BLE Gateway can be found on the ESPHome BLE Gateway GitHub page.