So the workaround approach appeals…though to be fair I feels like I have no idea what I’m doing…so it’s probably true.
With my Studio Code addon I created custom_components folder under esphome, and a lib folder under that. I placed your ble_dist.h in custom_components and OneEuro under the lib sub folder.
I then tooled up a yaml that I thought might work:
esphome:
name: example
includes:
- custom_components/lib/OneEuro.h
- custom_components/ble_dist.h
on_boot:
then:
lambda: |-
addTracker("bt_s20_ble", "0d591b07-5d2c-4551-a8cc-39a38968e462");
esp32:
board: esp32dev
framework:
type: arduino
api:
ota:
#Set WiFi
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
logger:
level: DEBUG
logs:
esp32_ble_tracker: INFO
esp32_ble_tracker:
scan_parameters:
duration: 60s
active: false
on_ble_advertise:
then:
- lambda: |-
parseAdvertisement(x);
sensor:
- platform: template
name: "BT S20 BLE (Lounge)"
id: lounge_bt_s20_ble_dist
update_interval: 30s
unit_of_measurement: "ft"
device_class: ""
state_class: "measurement"
accuracy_decimals: 1
entity_category: "diagnostic"
lambda: |-
return getTracker("bt_s20_ble").get_dist();
It is slightly different to your reference example…it just complained with that one that:
‘board’ is a required option for [ESP32]
And when I added that detail is wasn’t happy with the Platform: ESP32 bit…so…snipping done, edit window happy, lets install!
Then I get this error:
Compiling /data/example/.pioenvs/example/FrameworkArduino/esp32-hal-rmt.c.o
Compiling /data/example/.pioenvs/example/FrameworkArduino/esp32-hal-sigmadelta.c.o
Compiling /data/example/.pioenvs/example/FrameworkArduino/esp32-hal-spi.c.o
Compiling /data/example/.pioenvs/example/FrameworkArduino/esp32-hal-time.c.o
/data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-spi.c: In function 'spiTransferBytesNL':
/data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-spi.c:922:39: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
uint8_t * last_out8 = &result[c_longs-1];
^
/data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-spi.c:923:40: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
uint8_t * last_data8 = &last_data;
^
Compiling /data/example/.pioenvs/example/FrameworkArduino/esp32-hal-timer.c.o
Compiling /data/example/.pioenvs/example/FrameworkArduino/esp32-hal-touch.c.o
Compiling /data/example/.pioenvs/example/FrameworkArduino/esp32-hal-uart.c.o
Compiling /data/example/.pioenvs/example/FrameworkArduino/libb64/cdecode.c.o
Compiling /data/example/.pioenvs/example/FrameworkArduino/libb64/cencode.c.o
Compiling /data/example/.pioenvs/example/FrameworkArduino/main.cpp.o
In file included from src/main.cpp:30:0:
src/ble_dist.h: In member function 'void BeaconTracker::update(int, int)':
src/ble_dist.h:61:14: error: 'to_string' is not a member of 'std'
s += std::to_string(b) + ", ";
^
src/ble_dist.h:61:14: note: suggested alternatives:
In file included from src/esphome/core/preferences.h:6:0,
from src/esphome/core/application.h:6,
from src/esphome/components/api/api_connection.h:4,
from src/esphome.h:2,
from src/main.cpp:3:
src/esphome/core/helpers.h:398:20: note: 'esphome::to_string'
inline std::string to_string(const std::string &val) { return val; }
^
src/esphome/core/helpers.h:398:20: note: 'esphome::to_string'
In file included from src/esphome/components/sensor/sensor.h:3:0,
from src/esphome/core/application.h:16,
from src/esphome/components/api/api_connection.h:4,
from src/esphome.h:2,
from src/main.cpp:3:
src/ble_dist.h: In function 'BeaconTracker& getTracker(std::__cxx11::string)':
src/esphome/core/log.h:117:99: warning: format '%s' expects a matching 'char*' argument [-Wformat=]
esp_log_printf_(ESPHOME_LOG_LEVEL_WARN, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__)
^
src/esphome/core/log.h:151:28: note: in expansion of macro 'esph_log_w'
#define ESP_LOGW(tag, ...) esph_log_w(tag, __VA_ARGS__)
^
src/ble_dist.h:105:3: note: in expansion of macro 'ESP_LOGW'
ESP_LOGW(TAG, "BeaconTracker %s not recognized, returning the first tracker (hopefully one exists)");
^
Compiling /data/example/.pioenvs/example/FrameworkArduino/stdlib_noniso.c.o
Compiling /data/example/.pioenvs/example/FrameworkArduino/wiring_pulse.c.o
Compiling /data/example/.pioenvs/example/FrameworkArduino/wiring_shift.c.o
*** [/data/example/.pioenvs/example/src/main.cpp.o] Error 1
========================== [FAILED] Took 4.33 seconds ==========================
I’m sure it is something simple…but I don’t know much about this code…
Help?
Thanks,
CP.