j5lien / esphome-idasen-desk-controller

ESPHome component for Ikea Idasen desk control
MIT License
187 stars 36 forks source link

Not Moving and disconnecting #28

Open ArsenioLupin opened 3 years ago

ArsenioLupin commented 3 years ago

Hi, I tried every configuration and read all the issue but still doesn't work Every time I need to push pairing button on the desk to seen the green light (connected) on the card on home assistant After that when I try to move the desktop this is the log

[esp32_ble_tracker:180]: Starting scan...
[ble_client:045]: Found device at MAC address [my desk mac address]
[ble_client:083]: Attempting BLE connection to [my desk mac address]
[ble_sensor:033]: [Desk Height] Connected successfully!
[ble_sensor:033]: [Desk Speed] Connected successfully!
[binary_sensor:036]: 'Desk Connection': Sending state ON
[ble_client:159]: Service UUID: 0x1800
[ble_client:160]:   start_handle: 0x1  end_handle: 0x9
[ble_client:339]:  characteristic 0x2A00, handle 0x3, properties 0xa
[ble_client:339]:  characteristic 0x2A01, handle 0x5, properties 0x2
[ble_client:339]:  characteristic 0x2A04, handle 0x7, properties 0x2
[ble_client:339]:  characteristic 0x2AA6, handle 0x9, properties 0x2
[ble_client:159]: Service UUID: 0x1801
[ble_client:160]:   start_handle: 0xa  end_handle: 0xd
[ble_client:339]:  characteristic 0x2A05, handle 0xc, properties 0x20
[ble_client:159]: Service UUID: 99FA0001338A10-248A-4900-9C02-15F78A
[ble_client:160]:   start_handle: 0xe  end_handle: 0x13
[ble_client:339]:  characteristic 99FA0002338A10-248A-4900-9C02-15F78A, handle 0x10, properties 0xc
[ble_client:339]:  characteristic 99FA0003338A10-248A-4900-9C02-15F78A, handle 0x12, properties 0x12
[ble_client:159]: Service UUID: 99FA0010338A10-248A-4900-9C02-15F78A
[ble_client:160]:   start_handle: 0x14  end_handle: 0x17
[ble_client:339]:  characteristic 99FA0011338A10-248A-4900-9C02-15F78A, handle 0x16, properties 0x1e
[ble_client:159]: Service UUID: 99FA0020338A10-248A-4900-9C02-15F78A
[ble_client:160]:   start_handle: 0x18  end_handle: 0x1f
[ble_client:339]:  characteristic 99FA0021338A10-248A-4900-9C02-15F78A, handle 0x1a, properties 0x12
[ble_client:339]:  characteristic 99FA0029338A10-248A-4900-9C02-15F78A, handle 0x1d, properties 0x2
[ble_client:339]:  characteristic 99FA002A338A10-248A-4900-9C02-15F78A, handle 0x1f, properties 0x2
[ble_client:159]: Service UUID: 99FA0030338A10-248A-4900-9C02-15F78A
[ble_client:160]:   start_handle: 0x20  end_handle: 0xffff
[ble_client:339]:  characteristic 99FA0031338A10-248A-4900-9C02-15F78A, handle 0x22, properties 0xc
[esp32_ble_tracker:180]: Starting scan...
[ble_client:170]: No descriptor found for notify of handle 0x1a

Here my configuration

esphome:
  name: esp32deb2
  platform: ESP32
  board: esp32dev

esp32_ble_tracker:

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

ble_client:
  - mac_address: "My desk 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;

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;'

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "e9ec71a7e3c7ee62f43657bcf891d980"

wifi:
  ssid: "my ssid"
  password: "my psw"
  fast_connect: true

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32Deb2 Fallback Hotspot"
    password: "H8L6h0RhHT01"

captive_portal:
j5lien commented 2 years ago

Have you connected another device to your desk throught bluetooth ? (like a phone ?)

Could you check if you can retrieve the desk height without using this custom component like I explained here ? https://github.com/j5lien/esphome-idasen-desk-controller/issues/25#issuecomment-883697499