I’m willing to bet the Sony remote is not BLE, but I’d still like to try. I’ve run into a bit of a compile problem on my MacOS machine. I had to use the latest ESP framework version and the platform version 6.5.0 just to get the ESP-IDF framework to work at all on my machine. For completeness, here’s the YAML I’m using:
substitutions:
# the first is meant to be overridden on the command line
name: default
# these can be left alone unless they really need to be changed
dname: ${name}-hid
uname: ${name}_hid
esphome:
name: ${dname}
esp32:
board: featheresp32
framework:
type: esp-idf
version: latest
platform_version: 6.5.0
api:
reboot_timeout: 5min
ota:
password: ''
logger:
time:
- platform: sntp
id: the_time
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_ssid_password
external_components:
# use ble_client_hid from this master branch in GitHub
- source: github://koying/esphome-ble-remote@master
components: [ ble_client_hid ]
refresh: 5min
# - source: github://koying/esphome-blekeyboard@no_nimble
# refresh: always
esp32_ble_tracker:
scan_parameters:
interval: 1100ms
window: 1100ms
active: true
bluetooth_proxy:
active: true
# ble_keyboard:
# id: esp_keyboard_2
# name: "ESPKeyboard2"
# manufacturer_id: "ESP"
# battery_level: 50
# reconnect: true
# buttons: true
# use_default_libs: false
ble_client:
- id: ble_client_1
mac_address: "20:9E:79:3C:67:FB" #Sony Remote
ble_client_hid:
- id: ble_client_hid_1
ble_client_id: ble_client_1
sensor:
- platform: template
id: ${uname}_esp_memory
icon: mdi:memory
name: ${uname} Free Memory
lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024;
unit_of_measurement: 'kB'
state_class: measurement
entity_category: "diagnostic"
- platform: wifi_signal
name: ${uname} wifi signal
update_interval: 60s
- platform: uptime
id: uptime_seconds
internal: true
- platform: ble_client_hid
type: battery
ble_client_hid_id: ble_client_hid_1
name: ${uname} Battery
- platform: ble_client_hid
type: last_event_value
ble_client_hid_id: ble_client_hid_1
name: ${uname} Last Event Value
text_sensor:
- platform: template
name: ${uname} uptime
entity_category: diagnostic
lambda: |-
int seconds = (id(uptime_seconds).state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days > 3650 ) {
return { "Starting up" };
} else if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else {
return { (String(seconds) +"s").c_str() };
}
icon: mdi:clock-start
# - platform: ble_scanner
# name: "BLE Devices Scanner"
- platform: ble_client_hid
ble_client_hid_id: ble_client_hid_1
name: ${uname} Last Event Usage
button:
- platform: restart
name: ${uname} restart
- platform: safe_mode
name: ${uname} restart safe
icon: mdi:restart-alert
binary_sensor:
- platform: status
name: ${uname} status
Anyway, here’s the error from the build log. If it’s an easy fix, great. If not, I’ll just go back to plan A and try the radio remote.
Compiling .pioenvs/livingroom-hid/src/esphome/components/button/button.o
In file included from src/esphome/components/ble_client_hid/hid_parser.cpp:4:
src/esphome/components/ble_client_hid/hid_parser.cpp: In static member function 'static esphome::ble_client_hid::HIDReportMap* esphome::ble_client_hid::HIDReportMap::parse_report_map_data(const uint8_t*, uint16_t)':
src/esphome/components/ble_client_hid/hid_parser.cpp:178:25: error: format '%X' expects argument of type 'unsigned int', but argument 5 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
178 | ESP_LOGD(TAG, "Usage page: %X", report_item_data);
| ^~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
72 | #define ESPHOME_LOG_FORMAT(format) format
| ^~~~~~
src/esphome/core/log.h:152:28: note: in expansion of macro 'esph_log_d'
152 | #define ESP_LOGD(tag, ...) esph_log_d(tag, __VA_ARGS__)
| ^~~~~~~~~~
src/esphome/components/ble_client_hid/hid_parser.cpp:178:11: note: in expansion of macro 'ESP_LOGD'
178 | ESP_LOGD(TAG, "Usage page: %X", report_item_data);
| ^~~~~~~~
src/esphome/components/ble_client_hid/hid_parser.cpp:178:39: note: format string is defined here
178 | ESP_LOGD(TAG, "Usage page: %X", report_item_data);
| ~^
| |
| unsigned int
| %lX
Compiling .pioenvs/livingroom-hid/src/esphome/components/esp32/core.o
In file included from src/esphome/components/sensor/sensor.h:3,
from src/esphome/components/ble_client_hid/ble_client_hid.h:4,
from src/esphome/components/ble_client_hid/ble_client_hid.cpp:1:
src/esphome/components/ble_client_hid/ble_client_hid.cpp: In member function 'void esphome::ble_client_hid::BLEClientHID::send_input_report_event(esp_ble_gattc_cb_param_t*)':
src/esphome/components/ble_client_hid/ble_client_hid.cpp:207:19: error: format '%d' expects argument of type 'int', but argument 6 has type 'int32_t' {aka 'long int'} [-Werror=format=]
207 | ESP_LOGD(TAG, "Send HID event to HomeAssistant: usage: %s, value: %d", usage.c_str(), value.value);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/core/log.h:72:36: note: in definition of macro 'ESPHOME_LOG_FORMAT'
72 | #define ESPHOME_LOG_FORMAT(format) format
| ^~~~~~
src/esphome/core/log.h:152:28: note: in expansion of macro 'esph_log_d'
152 | #define ESP_LOGD(tag, ...) esph_log_d(tag, __VA_ARGS__)
| ^~~~~~~~~~
src/esphome/components/ble_client_hid/ble_client_hid.cpp:207:5: note: in expansion of macro 'ESP_LOGD'
207 | ESP_LOGD(TAG, "Send HID event to HomeAssistant: usage: %s, value: %d", usage.c_str(), value.value);
| ^~~~~~~~
src/esphome/components/ble_client_hid/ble_client_hid.cpp:207:72: note: format string is defined here
207 | ESP_LOGD(TAG, "Send HID event to HomeAssistant: usage: %s, value: %d", usage.c_str(), value.value);
| ~^
| |
| int
| %ld
Compiling .pioenvs/livingroom-hid/src/esphome/components/esp32/gpio.o
cc1plus: some warnings being treated as errors
*** [.pioenvs/livingroom-hid/src/esphome/components/ble_client_hid/hid_parser.o] Error 1
cc1plus: some warnings being treated as errors
*** [.pioenvs/livingroom-hid/src/esphome/components/ble_client_hid/ble_client_hid.o] Error 1