Coder Social home page Coder Social logo

Comments (31)

joshuajeschek avatar joshuajeschek commented on June 16, 2024 3

@leukanos at least you progressed 3 handles! 😁
does anybody know if it is possible to use esphome at the pull requests head?
(esphome/esphome#3320)

I think I'll try the pull request out with my installation (guide)

from esphome-idasen-desk-controller.

joshuajeschek avatar joshuajeschek commented on June 16, 2024 1

Looking at the documentation for BLE error codes:

Status Status Hex Description
5 0x05 BLE_HCI_AUTHENTICATION_FAILURE

Seems to be some sort of authentication failure. Any idea why? I pressed the pairing button, maybe I could also try completely resetting the desk

from esphome-idasen-desk-controller.

DJAMIRSAM avatar DJAMIRSAM commented on June 16, 2024 1

hmm so its nothing new then, where did u get your esp 32 i got mine off amazon it may be the ble chip (which i doubt)

from esphome-idasen-desk-controller.

DJAMIRSAM avatar DJAMIRSAM commented on June 16, 2024 1

Unfortunately we have not found a fix yet. But please send your progress here so others don’t have the same issue

from esphome-idasen-desk-controller.

ammmze avatar ammmze commented on June 16, 2024 1

See below for what I'm running currently. This is running on ESPHome 2022.3.2. I have 2 external_components setup:

  1. My fork of this repository, which I've enhanced (or fixed?) the ability to auto drive on the desks that don't have auto drive. For example, when the component received a request to go to a certain position, it was sending that to the desk and the desk would start moving, but it would only move a couple of inches at most and then stop. But the component didn't attempt to continue sending the command even though it could see that it wasn't at the right position. I'm not sure if this was intentional or not...but regardless, I can auto drive my desk now. I still need to figure out the calibration though because I'm pretty sure the numbers are off, but I haven't measured. Also there are some edge cases where I've found that it gets stuck in the loop continuously sending the command to move, but the desk doesn't move. However because the ESP keeps sending the command, the paddle on the desk becomes non-responsive until I restart the ESP (and maybe the desk). Also, I think when the desk is moving, there are a lot of updates that come through, but I don't think all of them make it to home assistant. The buffer of queued messages gets too full. So for example, on my home assistant card I have a stand position at 117cm and if I press it, the desk does it's thing and it does in fact make it to the position, but home assistant may get the last update at like 115cm. A quick tap of the paddle that effectively doesn't move the desk much causes one more update to run through and home assistant shows it at 117cm.
  2. The PR I had submitted to ESPHome, which I believe is in the 2022.4.0b1 release
esphome:
  name: office-desk-controller-frontier

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
  level: INFO

# Enable Home Assistant API
api:

ota:
  password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Office-Desk-Controller-Frontier"
    password: !secret ap_password

captive_portal:

external_components:
  - source: github://ammmze/esphome-idasen-desk-controller@make-it-work
  - source: github://pr#3320
    components:
      # list all components modified by this Pull Request here
      - ble_client
      - esp32_ble_tracker

globals:
  # To store the Desk Connection Status
  - id: ble_client_connected
    type: bool
    initial_value: 'false'

esp32_ble_tracker:

ble_client:
  - mac_address: "00:00:00:00:00:00" # Replace with the desk bluetooth mac address
    id: idasen_desk
    on_connect:
      then:
        # Update the Desk Connection Status
        - lambda: |-
            id(ble_client_connected) = true;
        - delay: 5s
        # Update desk height and speed sensors after bluetooth is connected
        - lambda: |-
            id(desk_height).update();
            id(desk_speed).update();
    on_disconnect:
      then:
        # Update the Desk Connection Status
        - lambda: |-
            id(ble_client_connected) = false;

idasen_desk_controller:
    # Reference to the ble client component id
    # -----------
    # Required
    ble_client_id: idasen_desk
    # Fallback to use only up and down commands (less precise)
    # -----------
    # Optional
    only_up_down_command: false

cover:
  - platform: idasen_desk_controller
    name: "Office Desk"

sensor:
  # Desk Height Sensor
  - platform: ble_client
    ble_client_id: idasen_desk
    id: desk_height
    name: 'Office Desk Height'
    service_uuid: '99fa0020-338a-1024-8a49-009c0215f78a'
    characteristic_uuid: '99fa0021-338a-1024-8a49-009c0215f78a'
    icon: 'mdi:arrow-up-down'
    unit_of_measurement: 'cm'
    accuracy_decimals: 1
    update_interval: never
    notify: true
    # filters:
    #   - debounce: 0.5s
    lambda: |-
      uint16_t raw_height = ((uint16_t)x[1] << 8) | x[0];
      unsigned short height_mm = raw_height / 10;

      return (float) height_mm / 10;

  # Desk Speed Sensor
  - platform: ble_client
    ble_client_id: idasen_desk
    id: desk_speed
    name: 'Office Desk Speed'
    service_uuid: '99fa0020-338a-1024-8a49-009c0215f78a'
    characteristic_uuid: '99fa0021-338a-1024-8a49-009c0215f78a'
    icon: 'mdi:speedometer'
    unit_of_measurement: 'cm/min' # I'm not sure this unit is correct
    accuracy_decimals: 0
    update_interval: never
    notify: true
    # filters:
    #   - debounce: 0.5s
    lambda: |-
      uint16_t raw_speed = ((uint16_t)x[3] << 8) | x[2];
      return raw_speed / 100;

binary_sensor:
  # Desk Bluetooth Connection Status
  - platform: template
    name: 'Office Desk Connection'
    id: desk_connection
    lambda: 'return id(ble_client_connected);'

  # Desk Moving Status
  - platform: template
    name: 'Office Desk Moving'
    id: desk_moving
    lambda: 'return id(desk_speed).state > 0;'

from esphome-idasen-desk-controller.

DJAMIRSAM avatar DJAMIRSAM commented on June 16, 2024

hey did you get a fix for this?

from esphome-idasen-desk-controller.

joshuajeschek avatar joshuajeschek commented on June 16, 2024

I didn't! If you have any additional information though, please let me know!

from esphome-idasen-desk-controller.

DJAMIRSAM avatar DJAMIRSAM commented on June 16, 2024

I was thinking maybe the desk is asking for a code but esphome does not support codes yet
If there was a code I’d would be 0000 or 1111

from esphome-idasen-desk-controller.

joshuajeschek avatar joshuajeschek commented on June 16, 2024

mmmh, that could be a reason but I wouldn't think so, this is working for so many other people
what kind of board are you using?

from esphome-idasen-desk-controller.

DJAMIRSAM avatar DJAMIRSAM commented on June 16, 2024

esp 32 and my table is a new idasen

from esphome-idasen-desk-controller.

joshuajeschek avatar joshuajeschek commented on June 16, 2024

Okay, I bought mine in september 2020 πŸ€”

from esphome-idasen-desk-controller.

nenadmilano avatar nenadmilano commented on June 16, 2024

Got the same errors in the log unfortunately. Was working with 1.2.3 until a few days ago but now neither 3.0.0. nur 1.2.3 is working.

from esphome-idasen-desk-controller.

DJAMIRSAM avatar DJAMIRSAM commented on June 16, 2024

@j5lien can you please look into this?

from esphome-idasen-desk-controller.

zmasek avatar zmasek commented on June 16, 2024

Happens to me, too.

Workaround:

  1. add v1.2.3 with the accompanying config and install
  2. overwrite with the 3.0.0 config

Sensors are not updating, though...

from esphome-idasen-desk-controller.

silverdna avatar silverdna commented on June 16, 2024

I have the same issue :(

I was thinking maybe the desk is asking for a code but esphome does not support codes yet If there was a code I’d would be 0000 or 1111

I don't think this is the case, since when pairing the desk to my phone it didn't ask for any pairing code

from esphome-idasen-desk-controller.

leukanos avatar leukanos commented on June 16, 2024

Workaround:

  1. add v1.2.3 with the accompanying config and install
  2. overwrite with the 3.0.0 config

Sensors are not updating, though...

In my case workaround doesn't help. Actually, it helps for a moment, and then I get the same error.

from esphome-idasen-desk-controller.

silverdna avatar silverdna commented on June 16, 2024

Happens to me, too.

Workaround:

1. add v1.2.3 with the accompanying config and install

2. overwrite with the 3.0.0 config

Sensors are not updating, though...

In the end, I tried this yesterday, and it worked! I've used v1.2.2, because v1.2.3 did not work for me. Saw this workaround originally here and followed its steps.

It is working since yesterday, both moving the desk and reading the sensors

To do the initial pairing with the desk used the following config:

esphome:
  name: *********    <- put the desired name here
  platform: ESP32
  board: esp32dev
  libraries:
    - "ESP32 BLE Arduino"
# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: ***************************************

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "*********"
    password: "**************"

captive_portal:

external_components:
  - source: github://j5lien/[email protected]
    

idasen_desk_controller:
  mac_address: "**:**:**:**:**:**"

  
cover:
  - platform: idasen_desk_controller
    name: "Desk"

Once paired successfully, used the following config:

esphome:
  name: *********    <- put the desired name here

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: ***************************************

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: *********************
    password:  *********************

captive_portal:

external_components:
  - source: github://j5lien/[email protected]
    
esp32_ble_tracker:

globals:
  # To store the Desk Connection Status
  - id: ble_client_connected
    type: bool
    initial_value: 'false'

ble_client:
  - mac_address: "**:**:**:**:**:**"
    id: idasen_desk
    on_connect:
      then:
        # Update the Desk Connection Status
        - lambda: |-
            id(ble_client_connected) = true;
        - delay: 5s
        # Update desk height and speed sensors after bluetooth is connected
        - lambda: |-
            id(desk_height).update();
            id(desk_speed).update();
    on_disconnect:
      then:
        # Update the Desk Connection Status
        - lambda: |-
            id(ble_client_connected) = false;

idasen_desk_controller:
  ble_client_id: idasen_desk
  only_up_down_command: false
  
cover:
  - platform: idasen_desk_controller
    name: "Desk"

sensor:
  # Desk Height Sensor
  - platform: ble_client
    ble_client_id: idasen_desk
    id: desk_height
    name: 'Desk Height'
    service_uuid: '99fa0020-338a-1024-8a49-009c0215f78a'
    characteristic_uuid: '99fa0021-338a-1024-8a49-009c0215f78a'
    icon: 'mdi:arrow-up-down'
    unit_of_measurement: 'cm'
    accuracy_decimals: 1
    update_interval: never
    notify: true
    lambda: |-
      uint16_t raw_height = ((uint16_t)x[1] << 8) | x[0];
      unsigned short height_mm = raw_height / 10;

      return (float) height_mm / 10;

  # Desk Speed Sensor
  - platform: ble_client
    ble_client_id: idasen_desk
    id: desk_speed
    name: 'Desk Speed'
    service_uuid: '99fa0020-338a-1024-8a49-009c0215f78a'
    characteristic_uuid: '99fa0021-338a-1024-8a49-009c0215f78a'
    icon: 'mdi:speedometer'
    unit_of_measurement: 'cm/min' # I'm not sure this unit is correct
    accuracy_decimals: 0
    update_interval: never
    notify: true
    lambda: |-
      uint16_t raw_speed = ((uint16_t)x[3] << 8) | x[2];
      return raw_speed / 100;

binary_sensor:
  # Desk Bluetooth Connection Status
  - platform: template
    name: 'Desk Connection'
    id: desk_connection
    lambda: 'return id(ble_client_connected);'

  # Desk Moving Status
  - platform: template
    name: 'Desk Moving'
    id: desk_moving
    lambda: 'return id(desk_speed).state > 0;'

from esphome-idasen-desk-controller.

leukanos avatar leukanos commented on June 16, 2024

Thanks for sharing. I'll try this approach.

from esphome-idasen-desk-controller.

leukanos avatar leukanos commented on June 16, 2024

Reading sensors works, for now, however moving is not :(
I'll see if it keep working over longer period of time

from esphome-idasen-desk-controller.

leukanos avatar leukanos commented on June 16, 2024

And it got disconnected after 2 days and doesn't connect anymore...

[W][idasen_desk_controller:104]: Error reading char at handle 29, status=5
[W][ble_sensor:082]: Error reading char at handle 29, status=5
[W][ble_sensor:082]: Error reading char at handle 29, status=5
[W][idasen_desk_controller:104]: Error reading char at handle 29, status=5
[W][ble_sensor:082]: Error reading char at handle 29, status=5
[W][ble_sensor:082]: Error reading char at handle 29, status=5

🀞 for @ammmze PR mentioned above

from esphome-idasen-desk-controller.

zmasek avatar zmasek commented on June 16, 2024

I did pretty much what andrethrill said in the comment below me. Things work, but the sensors don't :/ I'm using Adafruit ESP32 feather board if that's any help. The controls don't work for down (up and stop do), but the automation does (because it's behaving like a curtain).

from esphome-idasen-desk-controller.

ammmze avatar ammmze commented on June 16, 2024

@leukanos at least you progressed 3 handles! 😁
does anybody know if it is possible to use esphome at the pull requests head?
(esphome/esphome#3320)

I think I'll try the pull request out with my installation (guide)

πŸ‘πŸ» Let us know how it goes. Hopefully it gets things rolling. While I got mine paired and from the logs it looks pretty good, I did notice some quirks in home assistant. Often I would be manually raising and lowering the desk and the speed and other statuses would get stuck showing it in motion (i.e. having a positive speed value greater than 0), however in the esphome logs I did see 0 as the last speed. So I wonder if esphome is throttling the messages to esphome and dropping some of them. Regardless, I think it's a separate issue that we can dig into more once we are successful in the pairing process.

Edit: Ah...yea...looks like the reason why home assistant doesn't always see the final state is because there's not enough buffer space to store all the messages that get produced when moving the desk up/down.

[10:43:45][V][api.connection:893]: Cannot send message because of TCP buffer space

from esphome-idasen-desk-controller.

d0ugal avatar d0ugal commented on June 16, 2024

I’m also seeing this issue. I just got a new desk, partly because I wanted to automate it with this project πŸ˜„

Is there anything I can do to test/debug? It isn’t clear from reading the thread if there are any leads to follow up on.

Otherwise I’ll do my own investigation

from esphome-idasen-desk-controller.

joshuajeschek avatar joshuajeschek commented on June 16, 2024

small update from me:

  • I've updated my esphome in home assistant to this version (look at these release notes, they changed the install method: https://esphome.io/changelog/2022.2.0.html)

  • it worked for a bit, but the card showed wrong values so i tinkered a bit with the configuration. The reported height is correct now, but the connection status is false and sometimes it randomly stops working - I haven't found out why yet.

  • I'll post my configuration here later, probably tomorrow. I'll also continue to look into why the bugs are still occuring

from esphome-idasen-desk-controller.

DJAMIRSAM avatar DJAMIRSAM commented on June 16, 2024

well thanks to you this is the first time HA moved my desk

from esphome-idasen-desk-controller.

d0ugal avatar d0ugal commented on June 16, 2024

@ammmze Neat! I also tried this config out and it seems to partially work. I can now move the desk up and down with Home Assistant. However, the sensors don't seem to be updating. I don't need them for now, it isn't quite as nice but I can work with a cover percentage in Home Assistant so I just removed them for now. My more minimal config therefore look like...

external_components:
  - source: github://ammmze/esphome-idasen-desk-controller@make-it-work
  - source: github://pr#3320
    components:
      - ble_client
      - esp32_ble_tracker

substitutions:
   nicename: Study
   devicename: study

esphome:
  name: ${devicename}
  platform: ESP32
  board: esp32dev

# Enable logging
logger:
  level: INFO

# Enable Home Assistant API
api:

ota:
  password: "***************************************"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
  
esp32_ble_tracker:
ble_client:
  - mac_address: "00:00:00:00:00:00" # Replace with the desk bluetooth mac address
    id: idasen_desk

idasen_desk_controller:
    ble_client_id: idasen_desk
    only_up_down_command: false

cover:
  - platform: idasen_desk_controller
    name: "Study Desk"

from esphome-idasen-desk-controller.

DJAMIRSAM avatar DJAMIRSAM commented on June 16, 2024

@d0ugal the first time I loaded it in the sensors did not update but then I unplugged it and plugged it back in (the esp) and it’s working

from esphome-idasen-desk-controller.

d0ugal avatar d0ugal commented on June 16, 2024

Good point, the height did seem to update once after restart. It didn't seem to update after that but I'll do some experimentation.

from esphome-idasen-desk-controller.

callumgare avatar callumgare commented on June 16, 2024

@d0ugal Did you ever get a chance to do some experimenting? I'm getting the same thing where the sensors are updated when the ESP first boots up but never again.

Update: Slightly frustratingly the sensors seem to have started updating for me now and I'm not really sure why. The main thing I did before they started working was pair the desk to my computer using Bluetility (it's a mac app but I'm sure sure there are similar ones for other platforms) and subscribed to height changes there. Then I turned off bluetooth for my computer and my phone which I've previously connected to the desk and restarted the ESP holding down the pairing button on the physical desk control. I've restarted the ESP and unplugged and replugged in my desk many times at that point so I'm assuming it was something to do with the pairing and unpairing that did it rather than just the restarting but honestly I don't really have any idea what happened πŸ€·β€β™€οΈ

from esphome-idasen-desk-controller.

d0ugal avatar d0ugal commented on June 16, 2024

@callumgare I had some problems until 4.0.0 was released. Since then it has worked fine and I don't get the issue anymore. My full config is now the following;

external_components:
  - source: github://j5lien/[email protected]

substitutions:
   name: study-desk

esphome:
  name: ${name}
  platform: ESP32
  board: esp32dev

esp32_ble_tracker:

ble_client:
  - mac_address: "00:00:00:00:00:00" # Replace with the desk bluetooth mac address
    id: idasen_desk

idasen_desk_controller:
    ble_client_id: idasen_desk
    only_up_down_command: false

cover:
  - platform: idasen_desk_controller
    name: "Study Desk"

# These just include some common things like wifi details that I share between devices. Nothing speicifc to the desk.
<<: !include .common.yaml
<<: !include .atom-identify.yaml

from esphome-idasen-desk-controller.

callumgare avatar callumgare commented on June 16, 2024

Thanks for that @d0ugal!

from esphome-idasen-desk-controller.

Related Issues (20)

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.