OK - I’ve got a chinese remote with 20 buttons. I’ve got the matrix wired in to a C6 Zero. The intention is to use it as a long lasting remote on 2xAAA batteries, so I’ve got diodes connecting the rows to GPIO0 ready to use it for deep sleep. However, in order to also save power, I’m trying to use BLE. There is a C3 Zero acting as a BLE proxy.
The ESPHome code wasn’t causing the remote to be picked up in HA, so AI told me to ditch ESPHome and use Arduino code on the C6 to present BTHome. So far it is working, to a point, the payload is wrong and I’ve run out of free queries on countless AI going round in circles. It comes out as “sound detected” or “distance” and I just can’t shake it.
So the question is… do I really have to use Arduino code to produce the signal, or can I use ESPHome on the C6?
This is the ESPHome code that wasn’t causing the device to be detected in HA…
# -------------------------
# BLE ADVERTISING
# -------------------------
esp32_ble:
id: ble_dev
esp32_ble_beacon:
type: iBeacon
uuid: "12345678-1234-1234-1234-1234567890ab"
major: 1
minor: 0
measured_power: -59
#deep_sleep:
# id: deep_sleep_1
# run_duration: 3s
# sleep_duration: 0s
# -------------------------
# KEYPAD
# -------------------------
matrix_keypad:
id: remote_keypad
rows:
- pin: GPIO18
- pin: GPIO19
- pin: GPIO20
- pin: GPIO21
- pin: GPIO14
columns:
- pin: GPIO1
- pin: GPIO2
- pin: GPIO3
- pin: GPIO22
has_diodes: true
keys: "1234567890ABCDEFGHIJ"
# -------------------------
# GLOBAL STATE (for BLE value)
# -------------------------
globals:
- id: key_value
type: int
restore_value: no
initial_value: '0'
# -------------------------
# BUTTON HANDLING
# -------------------------
binary_sensor:
- platform: matrix_keypad
keypad_id: remote_keypad
name: "Key 1"
key: "1"
on_press:
then:
- lambda: |-
id(key_value) = 1;
- logger.log: "Key 1 pressed"
- platform: matrix_keypad
keypad_id: remote_keypad
name: "Key 2"
key: "2"
on_press:
then:
- lambda: |-
id(key_value) = 2;
- logger.log: "Key 2 pressed"
# Add more keys as needed...
# -------------------------
# UPDATE BLE BEACON VALUE
# -------------------------
interval:
- interval: 300ms
then:
- lambda: |-
// Encode key into minor value
id(ble_dev).set_minor(id(key_value));