Giter VIP home page Giter VIP logo

esphome-ble-controller's People

Contributors

archef2000 avatar buergi avatar evlo avatar wifwucite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

esphome-ble-controller's Issues

So close ... how do I send commands over the command channel?

I think I have tried really hard to find an example of how to send commands over the command channel. I don't think I understand BLE enough to even ask a sensible question. Can you please provide an example of sending commands over the command channel?

Secure Pairing with esphome ble_client

Secure PIN not displayed

Now that ESPHome supports secure PIN pairing i tried it but the connection is failing and the "server" is not displaying the pin.

config A:

esphome:
  name: esp-a

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:
api:
  ***
ota:
  ***
wifi:
  ***

captive_portal:

web_server:
  port: 80

external_components:
  - source: github://wifwucite/esphome-ble-controller

esp32_ble_controller:
  security_mode: secure
  on_show_pass_key:
  - logger.log:
      format: "pass key is %s"
      args: 'pass_key.c_str()'
  on_authentication_complete:
  - logger.log:
      format: "BLE authentication complete %d" # shows 1 on success, 0 on failure
      args: 'success'
  maintenance: false
  on_connected:
    - logger.log: "Connected."
  on_disconnected:
    - logger.log: "Disconnected."

config B:

esphome:
  name: esp-b

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:
api:
  ***
ota:
  ***
wifi:
  ***

captive_portal:

web_server:
  port: 80

number:
  - platform: template
    name: "BLE Passkey"
    id: ble_passkey
    step: 1
    min_value: 000000
    max_value: 999999
    optimistic: True
    on_value:
      then:
        - ble_client.passkey_reply:
            id: ble_itag
            passkey: !lambda "return (int)id(ble_passkey).state;"

esp32_ble_tracker:
  scan_parameters:
    interval: 10s
    continuous: true
ble_client:
  - mac_address: EC:62:60:9C:9E:9A
    id: ble_itag
    on_passkey_request:
      then:
        - logger.log:
            format: "Waiting on passkey"
    on_passkey_notification:
      then:
        - logger.log:
            format: "Enter this passkey on your BLE device: %06d"
            args: [ passkey ]
    on_numeric_comparison_request:
      then:
        - logger.log:
            format: "Compare this passkey with the one on your BLE device: %06d"
            args: [ passkey ]
        - ble_client.numeric_comparison_reply:
            id: ble_itag
            accept: True
    on_connect:
      then:
        - lambda: |-
            ESP_LOGD("ble_client_lambda", "Connected to BLE device");
    on_disconnect:
      then:
        - lambda: |-
            ESP_LOGD("ble_client_lambda", "Disconnected from BLE device");

log A:

[D]	[esp32_ble_controller:491] BLE server - connected
[D]	[main:274] Connected.
[D]	[esp32_ble_controller:467] BLE authentication - failed
[D]	[main:268] BLE authentication complete 0
[D]	[esp32_ble_controller:499] BLE server - disconnected
[D]	[main:280] Disconnected.

log B:

[D]	[esp32_ble_tracker:245]	Starting scan...
[D]	[esp32_ble_client:048] [0] [EC:62:60:9C:9E:9A] Found device
[D]	[esp32_ble_tracker:213]	Pausing scan to make connection...
[I]	[esp32_ble_client:064] [0] [EC:62:60:9C:9E:9A] 0x00 Attempting BLE connection
[I]	[esp32_ble_client:265] [0] [EC:62:60:9C:9E:9A] auth complete. remote BD_ADDR: ec62609c9e9a
[E]	[esp32_ble_client:268] [0] [EC:62:60:9C:9E:9A] auth fail reason = 0x66
[D]	[ble_client_lambda:166]	Disconnected from BLE device
[D]	[esp32_ble_tracker:245]	Starting scan...

send custom data using ble

I have device which receives any data (digits) using ble and showing it on lcd
I'm using sketch in arduino ide for now.
Is it possible to send any data using ble with your module? I see only switch implementation
Thanks in advance

RSSI sensor

Hi @wifwucite!

I would like to create a smart lock with ESPhome.
(I dont want to publish a beacon with my phone)
My idea is to pair my andorid phone with the esphome device, for security reasons.
I guess it will auto-connect if in range.
I need to measure the rssi value to calculate distance, then set it as a sensor value.

I can't get pairing with the core esphome ble server.
What do you think about this?
Is it possible anyway and with your controller lib?

Add an option to disable maintenance service

Hi!

First of all, thanks a lot for an amazing component! It's a shame something like this is not available in the official ESPHome.

I have to ESP32 nodes, and I'm setting up one with esphome-ble-controller to expose some sensors (indoor air quality etc), and I plan to use the other one with ble_client to consume the data, so that it could update the attached eInk display every time it awakes from deep sleep.

The issues is that ble_client doesn't support secure connections, and this means I'd have to run esphome-ble-controller in an insecure mode, potentially exposing my node for others to abuse. I'm looking to address this issue either by disabling the maintenance service so that even if someone connects they can only see the sensor data, or hiding the advertisement so that it's possible to connect to esphome-ble-controller node only if you know its MAC address.

Thanks!

I could use this library and suddenly it started giving me this error, could you help?

src/esphome/components/esp32_ble_controller/ble_command.cpp: In member function 'virtual void esphome::esp32_ble_controller::BLECommandLogLevel::execute(const std::vector<std::__cxx11::basic_string >&) const':
src/esphome/components/esp32_ble_controller/ble_command.cpp:144:33: error: 'parse_number' was not declared in this scope
const optional level = parse_number(log_level);
^
src/esphome/components/esp32_ble_controller/ble_command.cpp:144:46: error: expected primary-expression before 'int'
const optional level = parse_number(log_level);
^
*** [.pioenvs/sound_unit/src/esphome/components/esp32_ble_controller/ble_command.cpp.o] Error 1

ADD GATT-Format for Characteristics

Hello WiFiuCite,

nice developtment and thx for you pubishing. the code handles all values of sensors in the same format. Some clients are expecting GATT - Format so Temperature GATT-ID 2A6E like uint 16 with exp -2 - so 2343 for 23.43 °C.
If you are open for futher features you I can support you with another parameter on characteristics like

Temperature

  - characteristic: "00002a6e-0000-1000-8000-00805f9b34fb"
    exposes: s_BME_T
    GATT_Format: "16_2"

I have implemted in the fork sfeli if you are courios.

Thanks another time for the well done 99% of the solution.

Illegalinstruction error when using esphome-ble-controller

I am trying to expose a template switch, I get the following error

[23:58:39]Fatal exception (0): IllegalInstruction
[23:58:39]epc1=0x4008033a, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000

YAML

esphome:
  name: esp32bleserver
  platform: ESP32
  board: nodemcu-32s


wifi:
  fast_connect: True
  networks:
  - ssid: !secret myssid
    password: !secret mypass
    hidden: True


captive_portal:

web_server:
  port: 8080

logger:

ota:

api:

external_components:
  - source: github://wifwucite/esphome-ble-controller

esp32_ble_controller:
  services:
  - service: "4fafc201-1fb5-459e-8fcc-c5c9c331915d"
    characteristics:
      - characteristic: "beb5483e-36e1-4688-b7f5-ea07361b26ab"
        exposes: fanon  

remote_transmitter:
  pin: 3
  carrier_duty_percent: 50%

climate:
  - platform: daikin
    id: Aircon_BLE_Server
    name: "Aircon_BLE_Server"
    supports_heat: false

esp32_ble_server:

switch:
  - platform: template
    id: fanon
    turn_on_action:
      - climate.control:
          id: Aircon_BLE_Server
          mode: FAN_ONLY

Switch / Sensor data in Advertisement Beacon

I am using this module as BLE Server quite successfully. However, I realized I would need multiple client to use this. Hence can you check if the "Exposed" switch or sensor data can be pushed as value for Advertisement data? This way I could have multiple devices utilize this. I understand that depending upon the beacon interval, the sensor data may be a bit delayed, but thats okay

I am also trying to check how can I modify to incorporate the same, but I guess you would have already though about it

Allow exposing internal components

I was trying to setup esphome-ble-controller and couldn't figure out why I only saw the maintenance service.
Only after I checked logs, I realized that all the sensors I was exposing were marked as internal, and esphome-ble-controller was ignoring them.
I think it's a common pattern to use internal [template] sensors to format data etc, so that they're available on ESP, but are not pushed to HomeAssistant.

It'd be convenient if there was a flag to tell esphome-ble-controller that I want my internal services exposed over BLE.
Also, it'd be very helpful if log messages such as about internal components being ignored would show up in the default log from ESP (to the best of my understanding they're only shown now if higher verbosity is enabled).

Thanks!

Custom on/off values for the Switch component

I have few very strange BLE sockets. I've parsed on/off commands and them looks like
0x0f06030001000005ffff - on
0x0f06030000000004ffff - off

This is hex values. Can I use your library to control this sockets?

How to use with ble_client?

This is not an issue, but I'm trying to figure out a way, how to use this to directly communicate between two ESP32s (toggle a light directly without wifi)

Form this #4 it seems possible

server exposes switch
my goal is when client calls the switch service it would toggle the light, however I do get nothing in the log on server. I do NOT even get message Cannot write to BLE characteristic - not connected on client if the server is not powered on.

Only one client can be connected at one time.

I can't connect two devices to one ble_controller at the same time is this a limitation or a bug?

I have one esp32 that is the ble_controller and two other connecting to it.
I Just wanted to ask if it is limitation as the "normal" ble_server supports 3 connections?

Secure connection between two esphome devices

Hi,
Is it possible to connect two esphome devices without displays using an encrypted BLE connection? I tried different variations of security configurations with esp32_ble_controller and ble_client but didn't manage to get it to work. I'm thinking on the last example in the readme with security switched on.

BLE notifications?

I am new to BLE so not sure if this question is valid or makes sense. Is there a way for this to publish a notification with data? Or is the only way to poll the data?

Light component support

Hi, i saw commented lines in the code for light control, why are they commented?
Is it possible to control lighting via ble?

BLE MAC Address

Is there a way to get the MAC address of the BLE controller? Could it be configured, logged, or reported via maintenance service?

Thanks!

Disable/enable BLE for low power applications

I am currently working on a project with very high energy limitations. I use BLE for sending the WiFi credentials to the device for the first time. However, the BLE service service starts at boot and does not stop (never). In my use case, the BLE server becomes useless once the device has connected to a WiFi network.

For this reason, it would be ideal to be able to turn the BLE service off and on on demand with actions like ble.enable and ble.disable like the existing wifi.enable and wifi.disable. Furthermore, I having a parameter to select if the service should start at boot or not will be ideal for further energy savings if the device has already WiFi credentials.

@wifwucite, thanks a lot for the work. I know that managing an open source project like this can be exhausting. I can help if you provide me some indications. Do you think this feature fits this project? If that is the case, do you plan adding this feature in the near future? If not, I can work on a PR, but I will need some initial guidance on where I should start.

I tried your example I get this, can you help? thanks!

Compiling .pioenvs\core_v2\src\esphome\components\binary_sensor\automation.cpp.o
Compiling .pioenvs\core_v2\src\esphome\components\binary_sensor\binary_sensor.cpp.o
Compiling .pioenvs\core_v2\src\esphome\components\binary_sensor\filter.cpp.o
xtensa-esp32-elf-g++: fatal error: no input files
compilation terminated.
xtensa-esp32-elf-g++: fatal error: no input files
compilation terminated.
xtensa-esp32-elf-g++: fatal error: no input files
compilation terminated.
*** [.pioenvs\core_v2\src\esphome\components\binary_sensor\automation.cpp.o] Error 1
Compiling .pioenvs\core_v2\src\esphome\components\captive_portal\captive_portal.cpp.o
*** [.pioenvs\core_v2\src\esphome\components\binary_sensor\binary_sensor.cpp.o] Error 1
*** [.pioenvs\core_v2\src\esphome\components\binary_sensor\filter.cpp.o] Error 1
xtensa-esp32-elf-g++: fatal error: no input files
compilation terminated.
*** [.pioenvs\core_v2\src\esphome\components\captive_portal\captive_portal.cpp.o] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.