Done. Created an issue.
Hi,
I added multiple updates to the code. Controlling multiple lights separately should now be possible. The unpairing functionality was also added - but I haven’t had a chance to test it yet. Please check it out and let me know if it’s working as expected (it’s a separate branch for now, so simply add @add-unpair-functionality
reference to your external_components
declaration, like so:
external_components:
# shorthand
source: github://aronsky/esphome-components@add-unpair-functionality
Please note that with this branch, a new ID is generated for each light, and used during pairing and commanding instead of the default 0xcafebabe
used in the main branch. So you’ll have to re-pair all the lights.
Great…Will feedback after I test it.
@aronsky I am very happy to tell you that all is working as expected. I am able to pair and unpair as well as pairing the 3 lights as individual lights as can be seen in the attached photo.
The only tricky part is that when you pair, you need to only have the lights you want to be paired turned on. I have 2 of the lights initially connected to the same switch and even though one of them was already paired, when I off and on the switch to pair the second light, both of them got paired together and its previous pairing is lost. Thus I have to take out the 3rd light and pair it while connecting to different socket.
Great to hear! I merged the branch, so it’s now available in main
.
Regarding the last issue you describe (pairing 2 lights on the same physical switch), unfortunately that seems to be a limitation of the platform and protocol, I don’t think it can be solved any way other than your suggested workaround.
I believed so too as the app is having same behavior.
I’ve just got a few Lampsmart Pro BLE lights off thelightzey, and was delighted to find this thread!
My lights appear to be running the same hardware, so I’ll do some digging and see what happens - at the moment they’re in boxes waiting for the ceiling to be plastered, but I might wire them to a socket and have a test. Will post my findings here
First, terrific work! I’m trying to get this lamp working since February… I tried your code, but it does not work for my lamp. I’ve moved the ESP32 under the lamp, I tried dozens of times the pairing and unpairing. It works nice with the remote and with LampSmart Pro from my iPhone. I also tried to put it to “pairing” with the setup button on the remote and various combinations of all of this.
When I pair the lamp on the phone app, it starts to blink, when I call the ESPHome pairing service, it never starts to blink.
Can you help me with some instructions on how to debug? I bought an Adafruit BLE Sniffer 2 months ago but never put it to use.
Similar experience here. I’ve got the ESP32 set up, and can see on_pair called!
in the logs but nothing from the light. I’ve got a couple of different brands so I’m going to set up another one and see if I get different results.
@aronsky is there any debug information which might be gettable and helpful from the Android app?
Hi,
Unfortunately, the code is pretty much one-way right now, so whether the lamp is receiving the messages or not is unknown to the ESP32, and not debuggable…
If you have a working BLE sniffer, you can try sniffing the pairing requests from the app and from the ESP32, and compare them.
I’m a bit stumped as to how it works with the app but not with the ESP32. As far as pairing and dimming messages go, the ESP32 should be immitating the app pretty well, and I didn’t see any other types of BLE communication in the code. The remote seems to be using a different kind of messages, but the app doesn’t support that…
Is it possible to use the RPi itself as a BLE sniffer?
Maybe, I haven’t tried it.
Thanks for the extra info. This is my first interaction with ESPHome and I may not have my nodeMCU set up right. I’ll keep playing with the settings and see if I can coax it into life
okay, having tried for a while longer, I’m coming to the conclusion that there’s either something wrong with my ESP32 board or something wrong with my config.
- I’m using a nodeMCU ES32S board with a ESP32-WROOM-32 chip.
- I can successfully flash the board over wifi
- The logs suggest everything is working fine
- None of the three light fittings I’ve tried (all of which work with the Lampsmart Pro app) will pair
- I’ve confirmed the bluetooth chip is at least somewhat working by installing the
esp_blue_tracker
on the chip and setting the logger level toVERY_VERBOSE
. Lots of stuff starts showing up in the logs. - my suspicion is that the bluetooth module isn’t actually transmitting anything.
output from “Validate”:
INFO ESPHome 2023.5.5
INFO Reading configuration /config/esphome/bt-lamp-controller.yaml...
INFO Configuration is valid!
esphome:
name: bt-lamp-controller
friendly_name: bt-lamp-controller
build_path: .esphome/build/bt-lamp-controller
platformio_options: {}
includes: []
libraries: []
name_add_mac_suffix: false
min_version: 2023.5.5
esp32:
board: nodemcu-32s
framework:
version: 2.0.5
source: ~3.20005.0
platform_version: platformio/[email protected]
type: arduino
variant: ESP32
logger:
level: VERY_VERBOSE
baud_rate: 115200
tx_buffer_size: 512
deassert_rts_dtr: false
hardware_uart: UART0
logs: {}
api:
encryption:
key: **redacted**
port: 6053
password: ''
reboot_timeout: 15min
ota:
password: **redacted**
safe_mode: true
port: 3232
reboot_timeout: 5min
num_attempts: 10
wifi:
ap:
ssid: Test Fallback Hotspot
password: iFxZ67E0jxbL
ap_timeout: 1min
domain: .local
reboot_timeout: 15min
power_save_mode: LIGHT
fast_connect: false
passive_scan: false
networks:
- ssid: !secret 'wifi_ssid'
password: !secret 'wifi_password'
priority: 0.0
use_address: bt-lamp-controller.local
external_components:
- source:
url: https://github.com/aronsky/esphome-components.git
type: git
components: all
refresh: 1d
light:
- platform: lampsmart_pro_light
name: Porch Light
duration: 1000
default_transition_length: 0s
disabled_by_default: false
restore_mode: ALWAYS_OFF
gamma_correct: 2.8
flash_transition_length: 0s
constant_brightness: false
reversed: false
min_brightness: 0x07
Anything weird in there?
EDIT: I’ve tested another very similar nodemcu ESP32 board which to me confirms it’s not a dud chip.
Those who’ve had success: what module and config YAML are you using?
set on ESP32 to listen and the other as a light controller.
EDIT:
okay. Getting somewhere, I hope.
I think it’s a different prefix:
ESP32 controller sends:
Adv data: 02.01.02.1B.16.F0.08.10.80.0A.EE.31.BE.0A.F3.67.CB.A9.E3.C2.0E.9B.5C.9E.D4.BA.0F.29.31.31.93 (31)
Whereas hitting “pair” in the Android app sends (example):
Adv data: 02.01.01.1B.03.77.F8.B6.5F.2B.5E.00.FC.31.51.CC.E4.92.56.2E.4A.1B.FC.AC.ED.F4.1B.7C.B6.89.00 (31)
Looking at the lampify library (which admittedly I haven’t tested) the first 5 digits match the Android app pairing code start. I’m going to fork and see if I can get it working with a different start code.
Below is the board (CH9102X) I use…
My YAML:
substitutions:
devicename: esp32-lampsmart-pro
friendly_name: Lampsmart Pro
esphome:
name: $devicename
name_add_mac_suffix: false
friendly_name: $friendly_name
esp32:
board: esp32dev
# Enable logging
logger:
baud_rate: 0
#level: VERBOSE
# Enable Home Assistant API
api:
encryption:
key: !secret esphome_api_key
ota:
password: !secret esphome_ota_password
wifi:
ssid: !secret esphome_wifi_ssid
password: !secret esphome_wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "$friendly_name Fallback Hotspot"
password: !secret esphome_wifi_ap_password
#LampSmart Pro
external_components:
# shorthand
source: github://aronsky/esphome-components
sensor:
- platform: uptime
name: Uptime Sensor
- platform: wifi_signal
name: WiFi Signal
update_interval: 60s
binary_sensor:
- platform: status
name: Status
#LampSmart Pro
light:
- platform: lampsmart_pro_light
name: Main Hallway
duration: 1000
default_transition_length: 0s
cold_white_color_temperature: 6500 K
warm_white_color_temperature: 2700 K
min_brightness: 5
Thanks. That does appear to be an identical chip. It’s very weird. I can’t figure out if my lights are particularly picky, or if they’re running a different firmware, or what else could be going on.
@aronsky is working with me over on github but nothing I do seems to make a difference. It works from my phone, and doesn’t from the ESP32
wish there was aguide for us noobs.
Thanks, totally forgot to look at this thread I will try to see if it works for me
You are just 6 months late only
Hope it works out for you.