Giter VIP home page Giter VIP logo

imicknl / loctekmotion_iot Goto Github PK

View Code? Open in Web Editor NEW
528.0 18.0 54.0 1.29 MB

Learn how to connect your Flexispot (LoctekMotion) desk to the internet. This repository contains a collection of scripts to get your started, combined with research and instructions.

License: MIT License

Python 30.81% C++ 69.19%
flexispot loctek smart-desk esp8266 esp32 home-assistant standing-desk loctekmotion flexispot-desks

loctekmotion_iot's People

Contributors

adezwart avatar andybalze avatar bitsofthr avatar foxytocin avatar fruchtzwerg94 avatar gitolicious avatar glanch avatar heilmoa avatar imicknl avatar jodevsa avatar mad2xlc avatar pepsinio avatar spaeck avatar staxdb 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

loctekmotion_iot's Issues

Error E03 results in desk height 3cm reported

First of all: general functionality is flawless with my CB38M2L(IB)-1 and HS01B-1 connected to a NodeMCU v3 module. Kudos for the work so far! 🏅

Just a small issues I came across: When going all the way down with my desk, E03 is shown in the display (not sure if that's normal, but that's what it does). The script interprets this as 3cm desk height and reports it to HomeAssistant. Probably it would be a good idea to check for E in the first digit and not update the height if it is recognized.

image

The error can be seen in this video: https://www.youtube.com/watch?v=TS27ZzjOrfk

Wakeup Issues with Esphome

Hi there,

I've successfully integrated my flexispot desk to Home Assistant using your project. Thanks for that!

One problem I am having is, that I need to trigger the wakeup switch (and wait like 5 seconds) before I can send presets events.
Is there any way that this could be more integrated? Ideally I would like to just trigger the preset and the desk to always react.

Thanks!

No Issue | Tip for a Mushroom-Desk-Card

Hi. Thanks to this project i can move my desk up and down with home assistant. awesome.

I've made a card that uses custom:button-card and custom:mushroom-card to create a mushroom-like desk-card.

The card looks like this (with the typical big padding for mushroom cards)
image

or like this (with my smaller paddings around the card)
image

The Buttons on the right side on the card...
1.) turn on the switch.down-entity
2.) turn off the switch.up and switch-down-entity
3.) turn on the swith.up-entity
4.) call the button.sit-entity
5.) call the button.stand-entity

To do this you need:

  • Button-Card
  • Mushroom-Cards
  • the following little script that switches switch.up and switch.down off (for the pause-button)
alias: schreibtisch anhalten
sequence:
  - service: switch.turn_off
    data: {}
    target:
      entity_id:
        - switch.up
        - switch.down
mode: single

And this yaml-code

type: custom:button-card
entity: cover.desk
show_name: false
show_state: false
show_icon: false
styles:
  card:
    - overflow: unset
    - padding: 3px
  grid:
    - grid-template-areas: '"mushroom colors"'
    - grid-template-columns: auto 15rem
custom_fields:
  mushroom:
    card:
      type: custom:mushroom-template-card
      entity: '[[[ return entity.entity_id ]]]'
      tap_action:
        action: more-info
      icon_color: blue
      primary: '{{ state_attr(entity,"friendly_name") }}'
      secondary: >-
        {{ states("sensor.desk_height") }} {{
        state_attr("sensor.desk_height","unit_of_measurement") }}
      icon: '{{ state_attr(entity,"icon") }}'
      card_mod:
        style: |
          ha-card {
            padding: 3px 3px 3px 3px !important; #comment this line out if you want the bigger paddings around the card
            text-align: left !important;
            border: none !important;
            box-shadow: none !important;
          }
  colors:
    card:
      type: grid
      columns: 5
      square: false
      cards:
        - type: custom:button-card
          tap_action:
            action: call-service
            service: switch.turn_on
            service_data:
              entity_id: switch.down
          size: 70%
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:arrow-down
          styles:
            card:
              - padding: 3px
              - height: 40px
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
        - type: custom:button-card
          tap_action:
            action: call-service
            service: script.schreibtisch_anhalten
          size: 70%
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:pause
          styles:
            card:
              - padding: 3px
              - height: 40px
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
        - type: custom:button-card
          tap_action:
            action: call-service
            service: switch.turn_on
            service_data:
              entity_id: switch.up
          size: 70%
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:arrow-up
          styles:
            card:
              - padding: 3px
              - height: 40px
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
        - type: custom:button-card
          tap_action:
            action: call-service
            service: button.press
            service_data:
              entity_id: button.sit
          size: 70%
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:chair-rolling
          styles:
            card:
              - padding: 0px
              - height: 40px
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
        - type: custom:button-card
          tap_action:
            action: call-service
            service: button.press
            service_data:
              entity_id: button.stand
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:human-handsup
          size: 70%
          styles:
            card:
              - padding: 0px
              - height: 100%
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)

Would this work using an USB to RJ45 adapter using a normal linux machine?

Hello - I was wondering whether an Ethernet / RJ 45 adapter such as this one attached to a linux machine could potentially work. Since the PI uses Linux anyways, the question to me is:

  • can we send GPIO commands over the serial port?
  • is there anything "special" or incompatible about a USB to Ethernet adapter?

I might give it a go during the weekend unless someone thinks that there is something fundamentally wrong with this approach.

Anti-Collision function not present.

I have a LocTek Motion desk with the CB28M1B-1 controller.
The Instruction Manual mentions Anti-Collision as an Optional feature, but it seems to be absent in my setup.
Did anyone find a way to enable/configure this?

No Bug or issue - but i think i found the Bluetooth Adapter

Hello, first at all - sorry that i need to use the Bug / Issue section, but i didnt found another way to write this publicly^^ i am new to github :).

As i am not that into programming i searched for the Bluetooth Adatper and i think i found him. It's from Linak, the same company which produces the controller boxes called CBD6S - every flexispot or other standing desk with these type of control boxes should be compatible to this Bluetooth Adatper - this Adapter gives you access through smartphone app and a windows desktop app (should be in windows store).

Legend:
wrong assumption

The thing is, Linak didn't sell them on their own - or seems to be they just sell their products to other Stores. So i just found a Store and i gonna order one now to try it on my just "new" Flexispot E6.

Here are the links to the Bluetooth adapter and the compatible control box

Bluetooth Adatper: https://www.linak-us.com/products/accessories/bluetooth-adapter-desk/

Control Box: https://www.linak-us.com/products/control-boxes/cbd6s

Store i found: https://www.kuechenkonsum.de/4260433394794-linak-bluetooth-adapter-desk-ble2lin002-stick-hb11-vollversion.html

After i tested this adapter i'll get back to you! :)

Edit: watch out for BLE2LIN002 - this is the full version Adapter - BLE2LIN003 is the limited one and offer "no wireless control through app and no automatic drive"

BLE2LIN002
Full version Wireless control through app and automatic drive possible

Edit 2: my bad, i just recognized the control box of flexispot isn't the cbd6s - but i am gonna try this adapter anyway - if it's not gonna work i am able to return it.

FlexiSpot E7 Pin Map in Readme

I think the pin values in the pin mapping are inverted.
Using this:
image
White Orange is Pin 1
IMG20230620113612
This pic has the E7 Panel cable upside down from the above diagram to see the wire color,
Yellow is on the left, but when flipped to match the orientation of the diagram it is pin 8.

[No Issue] My config; more Buttons/Features/ "wakeup"

Hello,
i wanted to share my config with you for Esphome:

1
2

Features:

  • Pull Height on boot

  • Set wifi static ip

  • ESP Status

  • ESP restart

  • ESP Home version

  • ESP IP Address

  • ESP SSID

  • On Sit/Stand button get height (after 7.5 seconds, which my table needs to get up/down) set the delay to your need

  • Button Anti Collision for setting up sensitivity (0/1/2/3)

  • Button Child Lock

  • Button 1+2; Does nothing for my E7 so i use it as wakeup which works to get an update of the height (Display goes on)

  • Button M + sitting which shows some letter and numbers at my display. i dont know what it means

  • Button Factory reset to reset the table; for more info see the comment

The only thing i would like to add would be to get the height when manually driving up/down via display. but im not sure how to do that

i also changed line 9 in desk_height_sensor.h
from float value = NULL;
to float value = 0.0;

to solve the warning in ESPHOME when compiling

substitutions:
  device_name: Flexispot E7
  name: flexispot_e7
  min_height: "60.5" # Min height + 0.1
  max_height: "126" # Max height - 0.1

esphome:
  name: ${name}
  comment: ${device_name}
  includes:
    - desk_height_sensor.h
  on_boot:
    priority: -10
    then:
      - switch.turn_on: switch_1_2

esp8266:
  board: d1_mini

logger:
  esp8266_store_log_strings_in_flash: false
  #level: DEBUG
  baud_rate: 0

#Enable Home Assistant API
api:
  encryption:
    key: XXXXXXXXXXXXXXXXXXXXXXX

ota:
  password: XXXXXXXXXXXXXXXXXXXXX

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  reboot_timeout: 60min
  manual_ip:
    static_ip: 192.168.0.24
    gateway: XXXXXX
    subnet: XXXXXXX
  fast_connect: true

  #Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Flexispot-Wemos Fallback Hotspot"
    password: XXXXXXX

captive_portal:
    
uart:
  id: desk_uart
  baud_rate: 9600
  tx_pin: D5
  rx_pin: D6
  
binary_sensor:
  - platform: status
    name: "${device_name} Status"
  
sensor:
  - platform: wifi_signal
    name: "${device_name} WiFi Signal"
    update_interval: 60s
    accuracy_decimals: 0

  - platform: uptime
    name: "${device_name} Uptime"
    unit_of_measurement: minutes
    update_interval: 60s
    accuracy_decimals: 0
    filters:
      - lambda: return x / 60.0;

  - platform: custom
    lambda: |-
      auto desk_height_sensor = new DeskHeightSensor(id(desk_uart));
      App.register_component(desk_height_sensor);
      return {desk_height_sensor};
    sensors:
      id: "desk_height"
      name: "${device_name} Tischhöhe"
      unit_of_measurement: cm
      accuracy_decimals: 1
      icon: "mdi:counter"

switch:
  - platform: gpio
    name: "Virtual Screen"
    pin:
      number: D2
      mode: OUTPUT
    restore_mode: ALWAYS_OFF
    internal: true
    
  - platform: restart
    name: "${device_name} Restart"
    id: reset

  - platform: uart
    name: "${device_name} Preset 1"
    id: switch_preset1
    icon: mdi:numeric-1-box
    data: [0x9b, 0x06, 0x02, 0x04, 0x00, 0xac, 0xa3, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "${device_name} Preset 2"
    id: switch_preset2
    icon: mdi:numeric-2-box
    data: [0x9b, 0x06, 0x02, 0x08, 0x00, 0xac, 0xa6, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "${device_name} Sitzen" # Preset 3 on some control panels
    id: switch_sit
    icon: mdi:chair-rolling
    data: [0x9b, 0x06, 0x02, 0x00, 0x01, 0xac, 0x60, 0x9d]
    uart_id: desk_uart
    on_turn_off:
      - delay: 7500ms
      - switch.turn_on: switch_1_2

  - platform: uart
    name: "${device_name} Stehen" # Not available for all control panels
    id: switch_stand
    icon: mdi:human-handsup
    data: [0x9b, 0x06, 0x02, 0x10, 0x00, 0xac, 0xac, 0x9d]
    uart_id: desk_uart
    on_turn_off:
      - delay: 7500ms
      - switch.turn_on: switch_1_2

  - platform: uart
    name: "${device_name} Hoch"
    id: switch_up
    icon: mdi:arrow-up-bold
    data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
    uart_id: desk_uart
    internal: true

  - platform: uart
    name: "${device_name} Runter"
    id: switch_down
    icon: mdi:arrow-down-bold
    data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
    uart_id: desk_uart
    internal: true

  - platform: uart
    name: "${device_name} M"
    id: switch_m
    icon: mdi:alpha-m-circle
    data: [0x9b, 0x06, 0x02, 0x20, 0x00, 0xac, 0xb8, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "${device_name} (wake up)" # Not available on all control panels
    id: switch_wake_up
    icon: mdi:gesture-tap-button
    data: [0x9b, 0x06, 0x02, 0x00, 0x00, 0x6c, 0xa1, 0x9d]
    uart_id: desk_uart
    
    #https://github.com/Dude88/loctek_IOT_box/blob/main/code_send_by_controllbox
  - platform: uart
    name: "${device_name} Anti Collision"
    id: switch_anti_kollision
    icon: mdi:card-remove
    data: [0x9b, 0x06, 0x02, 0x03, 0x00, 0x9C, 0xa1, 0x9d]
    uart_id: desk_uart
    send_every: 1ms
    on_turn_on:
      - delay: 6000ms
      - switch.turn_off: switch_anti_kollision
    
  - platform: uart
    name: "${device_name} Child Lock"
    id: switch_lock
    icon: mdi:account-lock
    data: [0x9b, 0x06, 0x02, 0x20, 0x00, 0xac, 0xb8, 0x9d]
    uart_id: desk_uart
    send_every: 1ms
    on_turn_on:
      - delay: 5000ms
      - switch.turn_off: switch_lock
    
  - platform: uart
    name: "${device_name} 1 + 2" # Not available for all control panels // Could be used as wake up ?
    id: switch_1_2
    icon: mdi:counter
    data: [0x9b, 0x06, 0x02, 0x0c, 0x01, 0xac, 0x65, 0x9d]
    uart_id: desk_uart
    send_every: 1ms
    on_turn_on:
      - delay: 5000ms
      - switch.turn_off: switch_1_2
    
  - platform: uart
    name: "${device_name} M + sitting" # While holding it shows some numbers / M+sitting
    id: switch_m_sitting
    icon: mdi:script
    data: [0x9b, 0x06, 0x02, 0x20, 0x01, 0x6c, 0x79, 0x9d]
    uart_id: desk_uart
    send_every: 1ms
    on_turn_on:
      - delay: 15500ms
      - switch.turn_off: switch_m_sitting
    
    #RESET TO FACTORY SETTINGS
    #AFTER DISPLAY SHOWS RST, PRESS THE DOWN BUTTON UNTIL THE TABLE REACHES THELOWEST
    #POINT AND REBOUNDS. THAT MEANS RESET IS FINISHED
    #IF DISPLAY SHOED E01 OR E02, RETRY 18 MINUTES LATER
  - platform: uart
    name: "${device_name} Factory Reset" # M+standing 3sec
    id: switch_factory_reset
    icon: mdi:factory
    data: [0x9b, 0x06, 0x02, 0x30, 0x00, 0x6c, 0xb5, 0x9d]
    uart_id: desk_uart
    send_every: 1ms
    on_turn_on:
      - delay: 5000ms
      - switch.turn_off: switch_factory_reset
      
cover:
  - platform: template
    #icon: mdi:table-chair
    #icon: mdi-human-male-height-variant
    name: "${device_name} Tisch"
    assumed_state: true

    #Move desk up
    open_action:
      - while:
          condition:
            sensor.in_range:
              id: desk_height
              below: ${max_height}
          then:
          - logger.log: "Executing up command"
          - switch.turn_on: switch_up
          - delay: 10ms
    
    #Move desk down
    close_action:
      - while:
          condition:
            sensor.in_range:
              id: desk_height
              above: ${min_height} 
          then:
          - logger.log: "Executing down command"
          - switch.turn_on: switch_down
          - delay: 10ms
          
    # Stop Button
    stop_action:
      - logger.log: "Executing stop command"
      - switch.turn_on: switch_up
      - switch.turn_on: switch_down
      
    optimistic: true
    
#Sensors for ESP version and WIFI information
text_sensor:
  - platform: version
    name: "${device_name} ESPHome Version"
    
  - platform: wifi_info
    ip_address:
      name: "${device_name} ip"
    ssid:
      name: "${device_name} ssid"

EDIT:
i changed the code for the cover, so the STOP button will work

thanks to guevara777 for his mushroom card here:
#59

since i needed to make some changes because of the cover i use, this is the card:

image

type: custom:button-card
entity: cover.flexispot_e7_tisch
show_name: false
show_state: false
show_icon: false
styles:
  card:
    - overflow: unset
    - padding: 3px
  grid:
    - grid-template-areas: '"mushroom colors"'
    - grid-template-columns: auto 15rem
custom_fields:
  mushroom:
    card:
      type: custom:mushroom-template-card
      entity: '[[[ return entity.entity_id ]]]'
      tap_action:
        action: more-info
      icon_color: blue
      primary: '{{ state_attr(entity,"friendly_name") }}'
      secondary: >-
        {{ states("sensor.flexispot_e7_tischhohe") }} {{
        state_attr("sensor.flexispot_e7_tischhohe","unit_of_measurement") }}
      icon: '{{ state_attr(entity,"icon") }}'
      card_mod:
        style: |
          ha-card {
            padding: 3px 3px 3px 3px !important; #comment this line out if you want the bigger paddings around the card
            text-align: left !important;
            border: none !important;
            box-shadow: none !important;
          }
  colors:
    card:
      type: grid
      columns: 5
      square: false
      cards:
        - type: custom:button-card
          tap_action:
            action: call-service
            service: cover.close_cover
            service_data:
              entity_id: cover.flexispot_e7_tisch
          size: 70%
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:arrow-down
          styles:
            card:
              - padding: 3px
              - height: 40px
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
        - type: custom:button-card
          tap_action:
            action: call-service
            service: cover.stop_cover
            service_data:
              entity_id: cover.flexispot_e7_tisch
          size: 70%
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:pause
          styles:
            card:
              - padding: 3px
              - height: 40px
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
        - type: custom:button-card
          tap_action:
            action: call-service
            service: cover.open_cover
            service_data:
              entity_id: cover.flexispot_e7_tisch
          size: 70%
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:arrow-up
          styles:
            card:
              - padding: 3px
              - height: 40px
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
        - type: custom:button-card
          tap_action:
            action: call-service
            service: switch.turn_on
            service_data:
              entity_id: switch.flexispot_e7_sitzen
          size: 70%
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:chair-rolling
          styles:
            card:
              - padding: 0px
              - height: 40px
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
        - type: custom:button-card
          tap_action:
            action: call-service
            service: switch.turn_on
            service_data:
              entity_id: switch.flexispot_e7_stehen
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:human-handsup
          size: 70%
          styles:
            card:
              - padding: 0px
              - height: 100%
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)

D1 mini seems to crash when power is supplied via Ethernet [HS13B-1, Flexispot E7]

Hello all,

Thanks to the great documentation, I was able to connect my table [HS13B-1, Flexispot E7] with HomeAssistant. However, the D1 mini seems to restart occasionally - it loses the connection with HomeAssistant (buttons are grey). After a few seconds, the D1 restarts and connects with HomeAssistant and works as desired again. This is also evident in the uptime (screenshot). I suspect that the power supply through the table is not stable. Is this already known to be a problem?

Screenshot_20230918-123848~2

If I do not connect the D1 mini to the table and power it via USB, it runs stably for 30,000 seconds (approx. 8 h).

[No issue] working setup for Home Assistant + ESPHome + esp32dev + CB28M1B-1 + HS13A-1

Thank you to @iMicknl for helping me out with this! I´d like to share my working setup with others :)

Hardware

Disclaimer: I power my ESP32 with USB. I did not test to power it via V5-Pin. Please check the Documentation of your Board!

Wiring
image

ESPHome

Don`t forget to put this file -> https://github.com/iMicknl/LoctekMotion_IoT/blob/main/packages/esphome/desk_height_sensor.h
in the same folder as your .yaml-file for esphome!

substitutions:
  device_name: Schreibtisch # <- Friendlyname of your Device in Home Assistant
  name: esp-schreibtisch # <- name of your device in Home Assistant
  min_height: "75.1" # Min height + 0.1
  max_height: "109.1" # Max height - 0.1

esphome:
  name: ${name}
  comment: ${device_name}
  platform: esp32 # TODO Change to your platform
  board: esp32dev # TODO Change to your board
  includes:
    - desk_height_sensor.h

  project:
    name: "imicknl.loctekmotion_iot"
    version: "1.0.0"

  # Wake Desk by sending the "M" command
  # This will pull the current height after boot
  on_boot:
    priority: -10
    then:
      - button.press: button_m

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-Schreibtisch"
    password: "<supersecretpassword>"

captive_portal:

# Enable logging
logger:
  level: DEBUG
  # level: VERBOSE # Makes uart stream available in esphome logstream
  baud_rate: 0 # Disable logging over uart


# Enable Home Assistant API
api:

ota:
  password: "<supersecretpassword>"

uart:
  id: desk_uart
  baud_rate: 9600
  tx_pin: GPIO17
  rx_pin: GPIO16

sensor:
  - platform: wifi_signal
    name: "WiFi Signal"
    update_interval: 60s

  - platform: uptime
    name: Uptime

  - platform: custom
    lambda: |-
      auto desk_height_sensor = new DeskHeightSensor(id(desk_uart));
      App.register_component(desk_height_sensor);
      return {desk_height_sensor};
    sensors:
      id: "desk_height"
      name: Desk Height
      unit_of_measurement: cm
      accuracy_decimals: 1
      icon: "mdi:counter"
      state_class: "measurement"
      on_value:
        then:
          - cover.template.publish:
              id: desk_cover
              position: !lambda |-
                  // The sensor outputs values from min_height (cm) to max_height (cm)
                  // We need to translate this to 0 - 1 scale.
                  float position = (float(x) - float(${min_height})) / (float(${max_height}) - float(${min_height}));
                  ESP_LOGD("main", "X is %f", x);
                  ESP_LOGD("main", "Current position is %f", position);
                  return position;
switch:
  # PIN20
  - platform: gpio
    name: "Virtual Screen"
    pin:
      number: GPIO23
      mode: OUTPUT
    restore_mode: ALWAYS_ON
    entity_category: "config" 
    internal: true

  - platform: uart
    name: "Up"
    id: switch_up2
    icon: mdi:arrow-up-bold
    data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
    uart_id: desk_uart
    send_every: 108ms

  - platform: uart
    name: "Down"
    id: switch_down2
    icon: mdi:arrow-down-bold
    data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
    uart_id: desk_uart
    send_every: 108ms

button:
  - platform: template
    name: "Preset 1"
    icon: mdi:numeric-1-box
    on_press:
      - uart.write:
          id: desk_uart
          data: [0x9b, 0x06, 0x02, 0x04, 0x00, 0xac, 0xa3, 0x9d] 

  - platform: template
    name: "Preset 2"
    icon: mdi:numeric-2-box
    on_press:
      - uart.write:
          id: desk_uart
          data: [0x9b, 0x06, 0x02, 0x08, 0x00, 0xac, 0xa6, 0x9d]

  - platform: template
    name: "Sit" # Preset 3 on some control panels
    icon: mdi:chair-rolling
    on_press:
      - uart.write:
          id: desk_uart
          data: [0x9b, 0x06, 0x02, 0x00, 0x01, 0xac, 0x60, 0x9d]

  - platform: template
    name: "Stand"
    icon: mdi:human-handsup
    on_press:
      - uart.write:
          id: desk_uart
          data: [0x9b, 0x06, 0x02, 0x10, 0x00, 0xac, 0xac, 0x9d]

  - platform: template
    name: "Memory"
    id: button_m
    icon: mdi:alpha-m-box
    entity_category: "config"
    on_press:
      - uart.write:
          id: desk_uart
          data: [0x9b, 0x06, 0x02, 0x20, 0x00, 0xac, 0xb8, 0x9d]

  - platform: template
    name: "Wake Screen"
    id: button_wake_screen
    icon: mdi:gesture-tap-button
    entity_category: "config"
    on_press:
      - uart.write:
          id: desk_uart
          data: [0x9b, 0x06, 0x02, 0x00, 0x00, 0x6c, 0xa1, 0x9d]

  - platform: template
    name: "Alarm"
    id: button_alarm
    icon: mdi:alarm
    on_press:
      - uart.write:
          id: desk_uart
          data: [0x9b, 0x06, 0x02, 0x40, 0x00, 0xAC, 0x90, 0x9d]

  - platform: restart
    name: "Restart"
    entity_category: "config"

cover:
  - platform: template
    id: "desk_cover" 
    icon: mdi:desk # or mdi:human-male-height-variant
    name: "Desk"
    device_class: blind # makes it easier to integrate with Google/Alexa
    has_position: true
    position_action:
      - logger.log: "Requesting action change"

    # Move desk up
    open_action:
      - while:
          condition:
            sensor.in_range:
              id: desk_height
              below: ${max_height}
          then:
            - logger.log: "Executing up command"
            - cover.template.publish:
                id: desk_cover
                current_operation: OPENING
            - uart.write:
                id: desk_uart
                data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
            - delay: 108ms
    
    # Move desk down
    close_action:
      - while:
          condition:
            sensor.in_range:
              id: desk_height
              above: ${min_height} 
          then:
            - logger.log: "Executing down command"
            - cover.template.publish:
                id: desk_cover
                current_operation: CLOSING
            - uart.write:
                id: desk_uart
                data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
            - delay: 108ms
    optimistic: true

Please add the following code at the botton of the yaml-file if you want to have a position control in Home Assistant. The Position-range is from 0% to 100% and you can use it with alexa like "set desk to 70%" if you populate the cover-entity to alexa (i did it with Nabu-Casa).

    # Move desk to desired position
    position_action:
    #Check if we need to move desk up or down from current position
      if:
        condition:
        #Current height is more than target height, then move desk down
          lambda: |-
            float position = (float(id(desk_height).state) - float(${min_height})) / (float(${max_height}) - float(${min_height}));
            return pos < position;
        then:
          - logger.log: "Schreibtisch muss runter gefahren werden"
          - while:
              condition:
                # Move down till the current height is smaller then the target height
                lambda: |-
                  float position = (float(id(desk_height).state) - float(${min_height})) / (float(${max_height}) - float(${min_height}));
                  return pos < position;
              then:
                - logger.log: "Executing down command"
                - cover.template.publish:
                    id: desk_cover
                    current_operation: CLOSING
                - uart.write:
                    id: desk_uart
                    data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
                - delay: 108ms
        else:
          - logger.log: "Schreibtisch muss hoch gefahren werden"
          - while:
              condition:
                # Move up till the current height is bigger then the target height
                lambda: |-
                  float position = (float(id(desk_height).state) - float(${min_height})) / (float(${max_height}) - float(${min_height}));
                  return pos > position;
              then:
                - logger.log: "Executing up command"
                - cover.template.publish:
                    id: desk_cover
                    current_operation: OPENING
                - uart.write:
                    id: desk_uart
                    data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
                - delay: 108ms

Picture of my setup
image

Voice-Control with Alexa
You can control your desk via Alexa now. To do so, expose the button.sit and button.stand to alexa (i use Naba Casa for this). In the Alexa App i createt 2 routines that trigger the "Sit" and "Stand"-Scenes with a Voice command like "Alexa, im stehen arbeiten" (Alexa, work standing).

ESP32 D1 mini, CB38M2J(IB)-1 combination

Hi, all,

I have the CB38M2J(IB)-1, with two keypad RJ45 ports. I stripped standard Ethernet cable and used the following scheme:

ESP32 Name HS13A-1 T568B
GND GND Green White-blue
GPIO16 RX Purple White-Green
GPIO17 TX Red Blue
GPIO23 PIN20 White Orange
VIN +5V (VDD) Black Green

The following issues I have. The VCC from CB38M2J(IB)-1, seems not +5V, but used at the beginning external power. And the ESP32 does not see any activity.

Esphome config used for ESP32 D1 mini:

substitutions:
  device_name: desk-guestroom
  name: desk-guestroom
  min_height: "73.6" # Min height + 0.1
  max_height: "122.9" # Max height - 0.1

esphome:
  name: ${name}
  comment: ${device_name}
  platform: ESP32
  board: mhetesp32minikit
  includes:
    - desk_height_sensor.h

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${device_name} Fallback Hotspot"
    password: !secret ap_fallback_password


captive_portal:

# Enable logging
logger:
  #level: DEBUG
  baud_rate: 0

# Enable Home Assistant API
api:
  password: !secret api_password

ota:
  password: !secret ota_password

uart:
  id: desk_uart
  baud_rate: 9600
  tx_pin: GPIO17
  rx_pin: GPIO16

sensor:
  - platform: wifi_signal
    name: "WiFi Signal"
    update_interval: 60s

  - platform: uptime
    name: Uptime

  - platform: custom
    lambda: |-
      auto desk_height_sensor = new DeskHeightSensor(id(desk_uart));
      App.register_component(desk_height_sensor);
      return {desk_height_sensor};
    sensors:
      id: "desk_height"
      name: Desk Height
      unit_of_measurement: cm
      accuracy_decimals: 1
      icon: "mdi:counter"

switch:
  - platform: gpio
    name: "Virtual Screen"
    pin:
      number: GPIO23
      mode: OUTPUT
    restore_mode: ALWAYS_OFF
    internal: true

  - platform: uart
    name: "Preset 1"
    id: switch_preset1
    icon: mdi:numeric-1-box
    data: [0x9b, 0x06, 0x02, 0x04, 0x00, 0xac, 0xa3, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "Preset 2"
    id: switch_preset2
    icon: mdi:numeric-2-box
    data: [0x9b, 0x06, 0x02, 0x08, 0x00, 0xac, 0xa6, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "Sit" # Preset 3 on some control panels
    id: switch_sit
    icon: mdi:chair-rolling
    data: [0x9b, 0x06, 0x02, 0x00, 0x01, 0xac, 0x60, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "Stand" # Not available for all control panels
    id: switch_stand
    icon: mdi:human-handsup
    data: [0x9b, 0x06, 0x02, 0x10, 0x00, 0xac, 0xac, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "Up"
    id: switch_up
    icon: mdi:arrow-up-bold
    data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
    uart_id: desk_uart
    internal: true

  - platform: uart
    name: "Down"
    id: switch_down
    icon: mdi:arrow-down-bold
    data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
    uart_id: desk_uart
    internal: true

  - platform: uart
    name: "M"
    id: switch_m
    icon: mdi:alpha-m-circle
    data: [0x9b, 0x06, 0x02, 0x20, 0x00, 0xac, 0xb8, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "(wake up)" # Not available on all control panels
    id: switch_wake_up
    icon: mdi:gesture-tap-button
    data: [0x9b, 0x06, 0x02, 0x00, 0x00, 0x6c, 0xa1, 0x9d]
    uart_id: desk_uart

cover:
  - platform: template
    # icon: mdi:table-chair
    # icon: mdi-human-male-height-variant
    name: "Desk"
    assumed_state: true

    # Move desk up
    open_action:
      - while:
          condition:
            sensor.in_range:
              id: desk_height
              below: ${max_height}
          then:
          - logger.log: "Executing up command"
          - switch.turn_on: switch_up
          - delay: 10ms
    
    # Move desk down
    close_action:
      - while:
          condition:
            sensor.in_range:
              id: desk_height
              above: ${min_height} 
          then:
          - logger.log: "Executing down command"
          - switch.turn_on: switch_down
          - delay: 10ms
    optimistic: true

Help with ESP32 HS01B-1 + CB22M2A-1

Hello everyone.

So for some days I tried to get this working.
I wired up my hardware with passthrough like this:
image
Taken from here: https://github.com/iMicknl/LoctekMotion_IoT/tree/main/packages/esphome#hs01b-1
Correct me if my wiring is wrong. Maybe I misunderstood the wiring for passthrough with esp32.

It does not work. Display stays dark. Can't control it via home assistant. The buttons also don't work.
I checked my wiring a lot of times with multimeter. I'm certain it is correctly wired up just like on the picture.

Sometimes I had luck (2-3 times) after replugging HS01B-1 the display turns on and the table height is published in home assistant.

I'm sure my wiring is correct. It must be something else.

Please help me so I can sleep at night again :) 😅

Miswired, still works

ED9CA906-3B39-4D21-A5EB-D425C2BD38B7
Not really an issue, but i accidentally wired my CB38M2B(IB)-1 / HS13A-1

with the other wiring scheme.
Still worked! How can this be? According to the scheme it should have zapped the board with 23v and rx/tx doesnt line up.
Does the control box switch or has some handshake protocol ?
Uploading 71A73EAE-CECF-4294-938D-9EB0BCF22594.jpeg…

Support request for CB28M1S(IB)-1

Hello,

would it be possible to add the support of CB28M1S(IB)-1 model?

Model: CB28M1S(IB)-1
Input: 19-33V V, 150W
Output M.1: 19-33V V, 4A
Duty Cycle: 2 Minutes ON, 18 Minutes OFF
M.D.: 1F10

Here is a picture below:
IMG_6201
IMG_6202
IMG_6203

Flexispot EF1

For flexispot EF1 the Desk model: Flexispot E5B works.
I have the Flexispot EF1 und I used the table from the E5B and it is working.

Update height when controlling through original keypad

Hi, thanks so much for this repo! I have followed the instructions over a year ago using the Flexispot E7 and it works quite well! I'm using the following keypad:

image

Luckily my adapter provides two RJ45 ports, so I still use the original keypad while also being able to control it using Home Assistant.

My problem

I'm trying to create push notifications and collect statistics, so that I can better motivate myself to regularly stand. But when I use the keypad, the new height doesn't get detected. It is displayed on the keypad itself but the only way to also get it into Home Assistant is by sending the the "M" command or rebooting the device. This is quite annoying because it always lights up the display (I sleep in the same room).

Is there any way to properly read out the current height without having to send the "M" command or control the device using Home Assistant? I would love to keep using the keypad but get the benefit of collecting statistics and to set up push notifications to remind myself to stand (for example when I'm currently in a work meeting).

ASR

I've been using the ESPHome variant for a few days and today set up an automation to press M1 / M2 every 30 minutes. After some time it failed and the display showed "ASR".
Couldn't control anything with the ESP anymore and needed to attach the panel and move the desk all the way down to reset it.
Anyone already had similar issues? Something to expect to happen more often?

HS11A-1C0

Got this Control Panel but no second LAN Port.
Trying to Set this Up with a sonoff 4 way Relais.
Could you Help me Out with the wiring pls?
Saw a video of Someone doing it that way but with a different Panel. See in the Pictures.

https://youtu.be/vKwUHvPv-U8?si=AMcpmLU7QAEaEQzd

IMG_1047
IMG_1063
IMG_1064
IMG_1065
IMG_1066

CB28M1B-1 - up/down switches not working

Hi all, my controller box is a CB28M1B-1 with a HS01B-1 keypad.
I disconnected the keypad and connected an ESP8266 as described with esphome.
Preset 1-3 and wakeup is working fine. But with up and down nothing happens.
Is there any way to debug this?

Many thanks for this awesome work!

[HS01B-1] None of the commands work

Hey, damn cool project and just what I was looking for!

I am having a few issues in my setup though: I have been trying ,to control a flexispot desk remotely. Unfortunately none of the scenarios work.
I first tried the ESPHome solution and used an ESP8266. Since this did not work (or my desk did not respond at all), I still tried the variant with the Raspberry Pi - Unfortunately also unsuccessful. I even tried to execute the single "Up" command alone with a Python script, but the desk does not react to it.

Which setup I have: A Flexispot E5B with an HS01B-1 control unit and a CB38M2A-1 control module. I connected the Raspberry Pi and also the ESP8266 to the control module (CB38M2A-1) via a modified Ethernet cable. For the correct ethernet cable mapping I used this table as a guideline:
https://github.com/deskmatik/deskmatik#wiring-flexispot

Do you have any idea where I made a mistake? Is my control module possibly not compatible, since I also have only one Ethernet port?

Where to buy a controller

Hi, does anyone know where to buy controller like:
CB38M2B(IB)-1
?

I've had one, but now it's broken :/

ESP32 error with ethernet only

Hi,

using a WT32-ETH01 and trying to setup my new desk via ESPHome.
However the image compilation fails if I don't setup wifi (or setup ethernet).

If my yaml contains a simple wifi config, image compilation works fine.

But if my yaml uses the following (which requires wifi to be removed from config):
ethernet: type: LAN8720 mdc_pin: GPIO23 mdio_pin: GPIO18 clk_mode: GPIO0_IN phy_addr: 1 power_pin: GPIO16
the compilation fails with reference to desk_height_sensor.h see -> logs_flexispot_upload.txt

So either the removal of wifi oder the addition of ethernet seams to break it. Sadly my programming fu is not enough for this to solve.
any fix appreciated.
Regards

Help figuring out possible support for CB38M2D(PB)-2

I'm hoping to work out whether or not this can be used with my Flexispot EQ5 model which uses the CB38M2D(PB)-2 control unit with Sanodesk LCD controller.
The control unit doesn't have a spare RJ45 port. The LCD button panel connects to the Control box with one cable which splits into two - an RJ45 and a 2 pin connector which both go into the control box.
The units appear to be sealed/glued with no easy access so I can't open them to view the boards inside, and with it still being under warranty I'm a bit hesitant to try and split the cases!
Pictures to show the units, but I suppose it's a long shot hoping to get this working unless anyone else with the same model has been brave enough to open the units up to investigate?

20220911_104402
20220911_104412
20220911_110953
20220911_111030
20220911_111054

Add support for HCB103A-1

I love the idea of this project and would love to have support added for the model HCB103A-1 controller. It appears that this is one of the newer models that they are using in several of their desks. What can I do to help get what is needed to add support for the HCB103A-1?


Example desks:

I wasn't able to find the model listed on Flexispot's or LoctekMotion's websites.
An example desk with documentation for the HCB103A-1: https://www.flexispot.my/wp-content/uploads/2021/08/EF1-Manual.pdf


Images

image

Exterior

20220126_171030544

PXL_20220126_175533298

PXL_20220126_175518594

PXL_20220126_175523250
(The port shown to the right labeled as "HS" is the RJ45 port)

PXL_20220126_175507716
(There is a slot on the side that looks suspiciously like a USB port)

Internals

PXL_20220126_174718549

PXL_20220126_174750699

PXL_20220126_175055776

PXL_20220126_174806350

PXL_20220126_174818202

Discord link

Does anyone have the Discord link? Links that are available are expired.

One command - 2cm change

Hi. I have a problem because I can't control my desk well. Sending one command over uart changes the height by about 2cm which is not the case with a regular controller. Is there any way to make the control more precise?

Strange managing

In the meantime I have successfully connected my E7 via MQTT.
Unfortunately I have sometimes very strange entries in the log and as a result I can no longer control the table. it looks to me as if he sends a signal unnecessarily often and then hangs in a loop.

INFO Reading configuration /config/Flexispot_E7_MQTT_control.yaml... INFO Starting log output from flexispot7.iot.local using esphome API INFO Successfully connected to flexispot7.iot.local [14:16:41][I][app:102]: ESPHome version 2023.2.4 compiled on Mar 10 2023, 19:04:18 [14:16:41][C][wifi:504]: WiFi: [14:16:41][C][wifi:362]: Local MAC: XXX [14:16:41][C][wifi:363]: SSID: 'XXX'[redacted] [14:16:41][C][wifi:364]: IP Address: 192.168.2.210 [14:16:41][C][wifi:365]: BSSID: XXX[redacted] [14:16:41][C][wifi:367]: Hostname: 'flexispot7' [14:16:41][C][wifi:369]: Signal strength: -67 dB ▂▄▆█ [14:16:41][C][wifi:373]: Channel: 13 [14:16:41][C][wifi:374]: Subnet: 255.255.255.0 [14:16:41][C][wifi:375]: Gateway: XXX [14:16:41][C][wifi:376]: DNS1: XXX [14:16:41][C][wifi:377]: DNS2: XXX [14:16:41][C][logger:293]: Logger: [14:16:41][C][logger:294]: Level: DEBUG [14:16:41][C][logger:295]: Log Baud Rate: 0 [14:16:41][C][logger:296]: Hardware UART: UART0 [14:16:41][C][uart.arduino_esp8266:102]: UART Bus: [14:16:41][C][uart.arduino_esp8266:103]: TX Pin: GPIO14 [14:16:41][C][uart.arduino_esp8266:104]: RX Pin: GPIO12 [14:16:41][C][uart.arduino_esp8266:106]: RX Buffer Size: 256 [14:16:41][C][uart.arduino_esp8266:108]: Baud Rate: 9600 baud [14:16:41][C][uart.arduino_esp8266:109]: Data Bits: 8 [14:16:41][C][uart.arduino_esp8266:110]: Parity: NONE [14:16:41][C][uart.arduino_esp8266:111]: Stop bits: 1 [14:16:41][C][uart.arduino_esp8266:115]: Using software serial [14:16:41][C][uptime.sensor:031]: Uptime Sensor 'Uptime' [14:16:41][C][uptime.sensor:031]: Device Class: 'duration' [14:16:41][C][uptime.sensor:031]: State Class: '' [14:16:41][C][uptime.sensor:031]: Unit of Measurement: 's' [14:16:41][C][uptime.sensor:031]: Accuracy Decimals: 0 [14:16:41][C][uptime.sensor:031]: Icon: 'mdi:timer-outline' [14:16:41][C][switch.gpio:076]: GPIO Switch 'Virtual Screen' [14:16:41][C][switch.gpio:098]: Restore Mode: always ON [14:16:41][C][switch.gpio:031]: Pin: GPIO4 [14:16:41][C][template.cover:071]: Template Cover 'Desk' [14:16:41][C][template.cover:071]: Assumed State: YES [14:16:41][C][uart.switch:076]: UART Switch 'Preset 1' [14:16:41][C][uart.switch:078]: Icon: 'mdi:numeric-1-box' [14:16:41][C][uart.switch:098]: Restore Mode: restore defaults to OFF [14:16:41][C][uart.switch:076]: UART Switch 'Preset 2' [14:16:41][C][uart.switch:078]: Icon: 'mdi:numeric-2-box' [14:16:41][C][uart.switch:098]: Restore Mode: restore defaults to OFF [14:16:41][C][uart.switch:076]: UART Switch 'Sit' [14:16:41][C][uart.switch:078]: Icon: 'mdi:chair-rolling' [14:16:41][C][uart.switch:098]: Restore Mode: restore defaults to OFF [14:16:41][C][uart.switch:076]: UART Switch 'Stand' [14:16:41][C][uart.switch:078]: Icon: 'mdi:human-handsup' [14:16:41][C][uart.switch:098]: Restore Mode: restore defaults to OFF [14:16:41][C][uart.switch:076]: UART Switch 'Up' [14:16:41][C][uart.switch:078]: Icon: 'mdi:arrow-up-bold' [14:16:41][C][uart.switch:098]: Restore Mode: restore defaults to OFF [14:16:41][C][uart.switch:076]: UART Switch 'Down' [14:16:41][C][uart.switch:078]: Icon: 'mdi:arrow-down-bold' [14:16:41][C][uart.switch:098]: Restore Mode: restore defaults to OFF [14:16:41][C][uart.switch:076]: UART Switch 'M' [14:16:41][C][uart.switch:078]: Icon: 'mdi:alpha-m-circle' [14:16:41][C][uart.switch:098]: Restore Mode: restore defaults to OFF [14:16:41][C][uart.switch:076]: UART Switch '(wake up)' [14:16:41][C][uart.switch:078]: Icon: 'mdi:gesture-tap-button' [14:16:41][C][uart.switch:098]: Restore Mode: restore defaults to OFF [14:16:41][C][captive_portal:088]: Captive Portal: [14:16:41][C][mdns:108]: mDNS: [14:16:41][C][mdns:109]: Hostname: flexispot7 [14:16:41][C][ota:093]: Over-The-Air Updates: [14:16:41][C][ota:094]: Address: flexispot7.iot.local:8266 [14:16:41][C][mqtt:065]: MQTT: [14:16:41][C][mqtt:066]: Server Address: XXX:1884 (XXX202) [14:16:41][C][mqtt:068]: Username: 'iot'[redacted] [14:16:41][C][mqtt:069]: Client ID: 'flexispot7-e8db84da8615'[redacted] [14:16:41][C][mqtt:074]: Topic Prefix: 'Flexispot' [14:16:41][C][mqtt:076]: Log Topic: 'Flexispot/debug' [14:16:41][C][mqtt:079]: Availability: 'Flexispot/status' [14:16:41][C][api:138]: API Server: [14:16:41][C][api:139]: Address: flexispot7.iot.local:6053 [14:16:41][C][api:143]: Using noise encryption: NO [14:16:41][C][wifi_signal.sensor:009]: WiFi Signal 'WiFi Signal' [14:16:41][C][wifi_signal.sensor:009]: Device Class: 'signal_strength' [14:16:41][C][wifi_signal.sensor:009]: State Class: 'measurement' [14:16:41][C][wifi_signal.sensor:009]: Unit of Measurement: 'dBm' [14:16:41][C][wifi_signal.sensor:009]: Accuracy Decimals: 0 [14:16:41][C][mqtt:609]: MQTT Message Trigger: [14:16:41][C][mqtt:610]: Topic: 'Flexispot/Sit/command' [14:16:41][C][mqtt:611]: QoS: 0 [14:16:41][C][mqtt.sensor:027]: MQTT Sensor 'WiFi Signal': [14:16:41][C][mqtt.sensor:031]: State Topic: 'Flexispot/sensor/wifi_signal/state' [14:16:41][C][mqtt.sensor:027]: MQTT Sensor 'Uptime': [14:16:41][C][mqtt.sensor:031]: State Topic: 'Flexispot/sensor/uptime/state' [14:16:41][C][mqtt.sensor:027]: MQTT Sensor 'Desk Height': [14:16:42][C][mqtt.sensor:031]: State Topic: 'Flexispot/sensor/desk_height/state' [14:16:42][C][mqtt.switch:041]: MQTT Switch 'Preset 1': [14:16:42][C][mqtt.switch:042]: State Topic: 'Flexispot/switch/preset_1/state' [14:16:42][C][mqtt.switch:042]: Command Topic: 'Flexispot/switch/preset_1/command' [14:16:42][C][mqtt.switch:041]: MQTT Switch 'Preset 2': [14:16:42][C][mqtt.switch:042]: State Topic: 'Flexispot/switch/preset_2/state' [14:16:42][C][mqtt.switch:042]: Command Topic: 'Flexispot/switch/preset_2/command' [14:16:42][C][mqtt.switch:041]: MQTT Switch 'Sit': [14:16:42][C][mqtt.switch:042]: State Topic: 'Flexispot/switch/sit/state' [14:16:42][C][mqtt.switch:042]: Command Topic: 'Flexispot/switch/sit/command' [14:16:42][C][mqtt.switch:041]: MQTT Switch 'Stand': [14:16:42][C][mqtt.switch:042]: State Topic: 'Flexispot/switch/stand/state' [14:16:42][C][mqtt.switch:042]: Command Topic: 'Flexispot/switch/stand/command' [14:16:42][C][mqtt.switch:041]: MQTT Switch 'M': [14:16:42][C][mqtt.switch:042]: State Topic: 'Flexispot/switch/m/state' [14:16:42][C][mqtt.switch:042]: Command Topic: 'Flexispot/switch/m/command' [14:16:42][C][mqtt.switch:041]: MQTT Switch '(wake up)': [14:16:42][C][mqtt.switch:042]: State Topic: 'Flexispot/switch/wake_up/state' [14:16:42][C][mqtt.switch:042]: Command Topic: 'Flexispot/switch/wake_up/command' [14:16:42][C][mqtt.cover:052]: MQTT cover 'Desk': [14:16:42][C][mqtt.cover:055]: State Topic: 'Flexispot/cover/desk/state' [14:16:42][C][mqtt.cover:055]: Command Topic: 'Flexispot/cover/desk/command' [14:16:42][C][mqtt:609]: MQTT Message Trigger: [14:16:42][C][mqtt:610]: Topic: 'Flexispot/Stand/command' [14:16:42][C][mqtt:611]: QoS: 0 [14:16:42][C][mqtt:609]: MQTT Message Trigger: [14:16:42][C][mqtt:610]: Topic: 'Flexispot/Preset1/command' [14:16:42][C][mqtt:611]: QoS: 0 [14:16:42][C][mqtt:609]: MQTT Message Trigger: [14:16:42][C][mqtt:610]: Topic: 'Flexispot/Preset2/command' [14:16:42][C][mqtt:611]: QoS: 0 [14:16:42][C][mqtt:609]: MQTT Message Trigger: [14:16:42][C][mqtt:610]: Topic: 'Flexispot/Wake/command' [14:16:42][C][mqtt:611]: QoS: 0 [14:16:42][C][mqtt:609]: MQTT Message Trigger: [14:16:42][C][mqtt:610]: Topic: 'Flexispot/Switch_M/command' [14:16:42][C][mqtt:611]: QoS: 0 [14:16:42][C][mqtt:609]: MQTT Message Trigger: [14:16:42][C][mqtt:610]: Topic: 'Flexispot/up/command' [14:16:42][C][mqtt:611]: QoS: 0 [14:16:42][C][mqtt:609]: MQTT Message Trigger: [14:16:42][C][mqtt:610]: Topic: 'Flexispot/down/command' [14:16:42][C][mqtt:611]: QoS: 0 [14:16:43][D][switch:013]: 'Sit' Turning ON. [14:16:43][D][switch:056]: 'Sit': Sending state ON [14:16:43][D][uart.switch:020]: 'Sit': Sending data... [14:16:43][D][switch:056]: 'Sit': Sending state OFF [14:16:43][D][switch:013]: '(wake up)' Turning ON. [14:16:43][D][switch:056]: '(wake up)': Sending state ON [14:16:43][D][uart.switch:020]: '(wake up)': Sending data... [14:16:43][D][switch:056]: '(wake up)': Sending state OFF [14:16:54][D][sensor:126]: 'WiFi Signal': Sending state -66.00000 dBm with 0 decimals of accuracy [14:16:54][D][switch:013]: '(wake up)' Turning ON. [14:16:55][D][switch:056]: '(wake up)': Sending state ON [14:16:55][D][uart.switch:020]: '(wake up)': Sending data... [14:16:55][D][switch:056]: '(wake up)': Sending state OFF [14:16:57][D][switch:013]: 'Stand' Turning ON. [14:16:58][D][switch:056]: 'Stand': Sending state ON [14:16:58][D][uart.switch:020]: 'Stand': Sending data... [14:16:58][D][switch:056]: 'Stand': Sending state OFF [14:16:58][D][switch:013]: '(wake up)' Turning ON. [14:16:58][D][switch:056]: '(wake up)': Sending state ON [14:16:58][D][uart.switch:020]: '(wake up)': Sending data... [14:16:58][D][switch:056]: '(wake up)': Sending state OFF [14:17:02][D][switch:013]: '(wake up)' Turning ON. [14:17:02][D][switch:056]: '(wake up)': Sending state ON [14:17:02][D][uart.switch:020]: '(wake up)': Sending data... [14:17:02][D][switch:056]: '(wake up)': Sending state OFF [14:17:05][D][switch:013]: 'Sit' Turning ON. [14:17:05][D][switch:056]: 'Sit': Sending state ON [14:17:05][D][uart.switch:020]: 'Sit': Sending data... [14:17:05][D][switch:056]: 'Sit': Sending state OFF [14:17:05][D][switch:013]: '(wake up)' Turning ON. [14:17:05][D][switch:056]: '(wake up)': Sending state ON [14:17:05][D][uart.switch:020]: '(wake up)': Sending data... [14:17:05][D][switch:056]: '(wake up)': Sending state OFF [14:17:15][D][sensor:126]: 'Desk Height': Sending state 119.00000 cm with 1 decimals of accuracy [14:17:16][D][sensor:126]: 'Desk Height': Sending state 118.00000 cm with 1 decimals of accuracy [14:17:16][D][sensor:126]: 'Desk Height': Sending state 117.00000 cm with 1 decimals of accuracy [14:17:16][D][sensor:126]: 'Desk Height': Sending state 116.00000 cm with 1 decimals of accuracy [14:17:16][D][sensor:126]: 'Desk Height': Sending state 115.00000 cm with 1 decimals of accuracy [14:17:17][D][sensor:126]: 'Desk Height': Sending state 114.00000 cm with 1 decimals of accuracy [14:17:17][D][sensor:126]: 'Desk Height': Sending state 113.00000 cm with 1 decimals of accuracy [14:17:17][D][sensor:126]: 'Desk Height': Sending state 112.00000 cm with 1 decimals of accuracy [14:17:17][D][sensor:126]: 'Desk Height': Sending state 111.00000 cm with 1 decimals of accuracy [14:17:18][D][switch:013]: 'Sit' Turning ON. [14:17:18][D][switch:056]: 'Sit': Sending state ON [14:17:18][D][uart.switch:020]: 'Sit': Sending data... [14:17:18][D][switch:056]: 'Sit': Sending state OFF [14:17:18][D][switch:013]: 'Preset 1' Turning ON. [14:17:18][D][switch:056]: 'Preset 1': Sending state ON [14:17:18][D][uart.switch:020]: 'Preset 1': Sending data... [14:17:18][D][switch:056]: 'Preset 1': Sending state OFF [14:17:18][D][switch:013]: 'Preset 2' Turning ON. [14:17:18][D][switch:056]: 'Preset 2': Sending state ON [14:17:18][D][uart.switch:020]: 'Preset 2': Sending data... [14:17:18][D][switch:056]: 'Preset 2': Sending state OFF [14:17:18][D][switch:013]: 'Sit' Turning ON. [14:17:18][D][switch:056]: 'Sit': Sending state ON [14:17:18][D][uart.switch:020]: 'Sit': Sending data... [14:17:18][D][switch:056]: 'Sit': Sending state OFF [14:17:18][D][switch:013]: 'Stand' Turning ON. [14:17:18][D][switch:056]: 'Stand': Sending state ON [14:17:18][D][uart.switch:020]: 'Stand': Sending data... [14:17:18][D][switch:056]: 'Stand': Sending state OFF [14:17:18][D][switch:013]: '(wake up)' Turning ON. [14:17:18][D][switch:056]: '(wake up)': Sending state ON [14:17:18][D][uart.switch:020]: '(wake up)': Sending data... [14:17:18][D][switch:056]: '(wake up)': Sending state OFF [14:17:18][D][cover:076]: 'Desk' - Setting [14:17:18][D][cover:086]: Command: OPEN [14:17:18][D][main:471]: Executing up command [14:17:18][D][switch:013]: 'Up' Turning ON. [14:17:18][D][switch:056]: 'Up': Sending state ON [14:17:18][D][uart.switch:020]: 'Up': Sending data... [14:17:18][D][switch:056]: 'Up': Sending state OFF [14:17:18][D][cover:170]: 'Desk' - Publishing: [14:17:18][D][cover:176]: State: OPEN [14:17:18][D][cover:186]: Current Operation: IDLE [14:17:18][W][mqtt.switch:032]: 'M': Received unknown status payload: [14:17:18][D][sensor:126]: 'Desk Height': Sending state 110.00000 cm with 1 decimals of accuracy [14:17:18][D][switch:013]: 'Preset 1' Turning ON. [14:17:18][D][switch:056]: 'Preset 1': Sending state ON [14:17:18][D][uart.switch:020]: 'Preset 1': Sending data... [14:17:18][D][switch:056]: 'Preset 1': Sending state OFF [14:17:18][D][switch:013]: 'Stand' Turning ON. [14:17:18][D][switch:056]: 'Stand': Sending state ON [14:17:18][D][uart.switch:020]: 'Stand': Sending data... [14:17:18][D][switch:056]: 'Stand': Sending state OFF [14:17:18][D][switch:013]: 'Preset 2' Turning ON. [14:17:18][D][switch:056]: 'Preset 2': Sending state ON [14:17:18][D][uart.switch:020]: 'Preset 2': Sending data... [14:17:18][D][switch:056]: 'Preset 2': Sending state OFF [14:17:18][D][switch:013]: 'M' Turning ON. [14:17:18][D][switch:056]: 'M': Sending state ON [14:17:18][D][uart.switch:020]: 'M': Sending data... [14:17:18][D][switch:056]: 'M': Sending state OFF ..... .... ...

FlexiSpot Q8 "Comhar Pro" w/ controller HCB215C-4

I just bought this desk and would like to implement some control / automation. This controller is a single unit with motor controls and display integrated.

IMG_0507

Internally the primary PCB is identified as HCB115C-1.

It does have a single RJ45 along with power in, two motors, and a DC-out for wireless charging and a board-edge connector which has a cover on it:

IMG_0510
IMG_0511
IMG_0512
IMG_0513

Any thoughts on this one? I have an oscilloscope w/ logic analyzer and can do some research and digging here on my own also. I did create a little breakout cable from the RJ45 and did identify ground and +5v, but everything else appears to be floating or ground with a little bit of switching / motor noise. I suspect I may need to do something to "wake up" this interface, e.g. the "pull a pin high" (pin 20 thing) and/or wake-up command I've seen referenced elsewhere - but hard to do that without some kind of pinout.

I would love some suggestions on how to get started here and will of course share all of my findings back with the community.

[bug] HS13A-1 stuck on "LOC"

Not sure this is a bug with this library, but I was playing around with connecting my arduino to the standing desk, and now I've noticed when plugging back in my original HS13A-1 keypad, it's stuck in the LOC state. Not 100% sure how to reproduce, but it will not get out of this setting regardless of how I press the buttons. I've tried:

  • hold down M for a long time
  • hold down up and down for a long time
  • powering on and off the control
  • powering on and off the control box itself

After all of these it still just says LOC and will not move the desk up and down. I'm not sure how to debug whether it's an issue with the keypad itself, or with the box it connects to. Is any state stored in this box? My box model is CB38M2B(IB)-1

Has anyone else run into this issue? Any ideas how to resolve? Perhaps there's a calibration issue it's experiencing where it thinks the desk is on uneven surface or otherwise has faulty state, and has shut down motor controls into the LOC state? cc @iMicknl @staxDB 🙏

Question about control box cb28m1j(ib)-1 and HS13A-1

Hey!
I have a HS13A-1 control panel with a cb28m1j(ib)-1 control box (according to a sticker on the side). I have tried getting this to work, but haven't had any success, none of the commands issues by home assistant resulted in any action (I used ESPHome).
I believe that the wiring might be incorrect, even though I connected the wires just as listed here: https://github.com/iMicknl/LoctekMotion_IoT/tree/main/packages/esphome

How can I find out what the correct wiring is for my combination of control box and panel?
Thanks!

Improvement: Still be able to use the control panels

It would be awesome if you could still use the control panel. The ESP8266 would have to read the incoming signals from the control panel and pass them on to the control unit. The same applies the other way round: Everything that is read from the control unit should also be written back to the control panel. Would such a setup be possible?

RJ45 PIN Original cable color Ethernet cable color Description ESP8266 GPIO > Control Unit ESP8266 GPIO > Control Panel Control Panel
1 brown white-orange RES RES
2 white orange SWIM SWIM
3 purple white-green N/C N/C
4 red blue Enable / Awake D2 ? Enable / Awake
5 green white-blue RX (of remote) D6 D1 TX (of remote)
6 black green TX (of remote) D5 D0 RX (of remote)
7 blue white-brown GND GND
8 yellow brown VDD (5V) VDD (5V)

The ESP8266 itself could be supplied with power via e.g. USB, so that the control panel could use the power supply from the control unit.

Improve current height section of README

Previously the README stated that the control box did sent the height as Binary Coded Decimal, but I wasn't 100% sure.

  • Find out which notation the control box is sending
  • Add relevant documentation on how to decode this notation

Commands dont execute unless i wake desk from control panel CB38M2L(IB)-1 and HS01B-1

i'm running this on an ESP8266 D1 mini and i'm running into an issue where the commands don't execute unless I wake the desk from a physical control button. After waking the desk from a physical button i get less then 10 seconds to execute a command from the ESP before it goes unresponsive

The ESP8266 is connected via the second RJ45 port, while the HS01B-1 panel is connected to the first port.

here is my config

substitutions:
  device_description: ESP8266 Custom
  friendly_name: desk
  name: desk
  min_height: "62.6" # Min height + 0.1
  max_height: "127.9" # Max height - 0.1

esphome:
  name: ${name}
  comment: ${device_description}
  platform: ESP8266 
  board: d1_mini
  includes:
    - desk_height_sensor.h
  on_boot:
    priority: -10
    then:
      - switch.turn_on: switch_m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_key

ota:
  safe_mode: true
  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: "${friendly_name} Fallback Hotspot"
    password: !secret fallback_password

captive_portal:

web_server:
  port: 80 

uart:
  - id: desk_uart
    baud_rate: 9600
    tx_pin: D5
    rx_pin: D6

sensor:
  - platform: wifi_signal
    name: "${friendly_name} WiFi Signal"
    update_interval: 60s

  - platform: uptime
    name: Uptime

  - platform: custom
    lambda: |-
      auto desk_height_sensor = new DeskHeightSensor(id(desk_uart));
      App.register_component(desk_height_sensor);
      return {desk_height_sensor};
    sensors:
      id: "desk_height"
      name: Desk Height
      unit_of_measurement: cm
      accuracy_decimals: 1
      icon: "mdi:counter"

button:
  - platform: restart
    name: "${friendly_name} Restart"   

switch:
  - platform: gpio
    name: "Virtual Screen"
    pin:
      number: D2
      mode: OUTPUT
    restore_mode: ALWAYS_ON
    internal: true

  - platform: uart
    name: "${friendly_name} Preset 1"
    id: switch_preset1
    icon: mdi:numeric-1-box
    data: [0x9b, 0x06, 0x02, 0x04, 0x00, 0xac, 0xa3, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "${friendly_name} Preset 2"
    id: switch_preset2
    icon: mdi:numeric-2-box
    data: [0x9b, 0x06, 0x02, 0x08, 0x00, 0xac, 0xa6, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "${friendly_name} Preset 3"
    id: switch_preset3
    icon: mdi:numeric-3-box
    data: [0x9b, 0x06, 0x02, 0x10, 0x00, 0xac, 0xac, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "${friendly_name} Up"
    id: switch_up
    icon: mdi:arrow-up-bold
    data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
    uart_id: desk_uart
    internal: true

  - platform: uart
    name: "${friendly_name} Down"
    id: switch_down
    icon: mdi:arrow-down-bold
    data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
    uart_id: desk_uart
    internal: true

  - platform: uart
    name: "${friendly_name} M"
    id: switch_m
    icon: mdi:alpha-m-circle
    data: [0x9b, 0x06, 0x02, 0x20, 0x00, 0xac, 0xb8, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "${friendly_name} (wake up)" # Not available on all control panels
    id: switch_wake_up
    icon: mdi:gesture-tap-button
    data: [0x9b, 0x06, 0x02, 0x00, 0x00, 0x6c, 0xa1, 0x9d]
    uart_id: desk_uart

cover:
  - platform: template
    # icon: mdi:table-chair
    # icon: mdi-human-male-height-variant
    name: "${friendly_name}"
    assumed_state: true

    # Move desk up
    open_action:
      - while:
          condition:
            sensor.in_range:
              id: desk_height
              below: ${max_height}
          then:
          - logger.log: "Executing up command"
          - switch.turn_on: switch_up
          - delay: 10ms
    
    # Move desk down
    close_action:
      - while:
          condition:
            sensor.in_range:
              id: desk_height
              above: ${min_height} 
          then:
          - logger.log: "Executing down command"
          - switch.turn_on: switch_down
          - delay: 10ms
    optimistic: true

log sample from the logs of executing a command and nothing happening

15:33:43 | [D] | [sensor:126] | 'desk WiFi Signal': Sending state -59.00000 dBm with 0 decimals of accuracy
15:33:46 | [D] | [switch:013] | 'desk Preset 3' Turning ON.
15:33:46 | [D] | [switch:056] | 'desk Preset 3': Sending state ON
15:33:46 | [D] | [uart.switch:020] | 'desk Preset 3': Sending data...
15:33:46 | [D] | [switch:056] | 'desk Preset 3': Sending state OFF
15:33:56 | [D] | [sensor:126] | 'Uptime': Sending state 423.09698 s with 0 decimals of accuracy
15:34:43 | [D] | [sensor:126] | 'desk WiFi Signal': Sending state -60.00000 dBm with 0 decimals of accuracy
15:34:56 | [D] | [sensor:126] | 'Uptime': Sending state 483.09698 s with 0 decimals of accuracy
15:35:43 | [D] | [sensor:126] | 'desk WiFi Signal': Sending state -59.00000 dBm with 0 decimals of accuracy
15:35:56 | [D] | [sensor:126] | 'Uptime': Sending state 543.09802 s with 0 decimals of accuracy
15:36:43 | [D] | [sensor:126] | 'desk WiFi Signal': Sending state -60.00000 dBm with 0 decimals of accuracy
15:36:56 | [D] | [sensor:126] | 'Uptime': Sending state 603.09698 s with 0 decimals of accuracy
15:37:43 | [D] | [sensor:126] | 'desk WiFi Signal': Sending state -60.00000 dBm with 0 decimals of accuracy
15:37:56 | [D] | [sensor:126] | 'Uptime': Sending state 663.09900 s with 0 decimals of accuracy
15:38:43 | [D] | [sensor:126] | 'desk WiFi Signal': Sending state -59.00000 dBm with 0 decimals of accuracy

[Testers wanted] New ESPHome configuration and documentation improvements

I am working on improving this repository. The main goal is to make it easier to get started, by providing only two configurations and a more updated README + configuration. In order to achieve this, all feedback and contributions are welcome.

Main goal:

  • Only provide 2 options and pin-outs (LoctekMotion Desk and LoctekMotion Desk with pass through)
  • Advise to use ESP32 due to 5V tolerance and hardware UART, add note about ESP8266 with voltage shifter (5V -> 3.3V).
  • Simplify the README and installation instructions (add a version for non technical people, 'plug and play')
  • Modernize YAML config with cover, buttons and number entity
  • Remove the need for desk_height_sensor.h (load from custom component)

Long term:

Changes

  • Switch will turn off automatically when min or max height is reached
  • New cover entity
  • New number entity (still buggy)
  • Presets are exposed as button entities
  • Experimental buttons for alarm / alarm off
image image

Pin-out

In the past we have discussed multiple pin-outs, but it seems that multiple pin-outs can be supported by the same desk.

RJ45 pin Name ESP32
8 +5V (VDD) VIN
7 GND GND
6 TX TX2 (GPIO17)
5 RX RX2 (GPIO16)
4 PIN 20 D23 (GPIO23)
3 (unknown)
2 SWIM
1 RES

You can change the ESP32 pin-out mapping, but don't forget to change the pin number in the YAML.

esp32-flexispot
My setup, no soldering required.

Configuration

office-desk.yaml
desk_height_sensor.h

The following secrets should be part of your ESPHome config: encryption_key, wifi_ssid and wifi_password.

Feedback

Any feedback and contributions are welcome! For example the work above adopted for pass through configurations.

Update ESPHome sample

  • Set PIN20 to high
  • Add preset commands as switch entity
  • Add up/down/stop command as cover entity
    • Make up/down continuous, with stop to stop movement
  • Add current height position to cover entity
  • Add current height as sensor entity

ESP won't boot up with keypad connected

Maybe someone already had this problem:
My device works really good, everything is supported. I power it from 5v cord of the table controller.
However, if i pull the table plug out and put it back in, ESP won't boot, if keypad was connected to RJ45 socket...
So i need to pull keypad out of the device, reset ESP and put it back again after 5-6 seconds. (And even then, sometimes ESP blinks and stops responding - today, for example, it took me 4 tries to put it back to work with keypad connected. Disregard that, looks like it was just bad power contact. Main problem still is there though.)

Is it something related to the power? I checked all connected pins, and they shouldn't prevent ESP from starting, according to docs... Also i tried to use different pins just in case - still same behaviour.

nonfunctional physical buttons + laggy physical display

Hi, we have setup a Wemos D1 Mini ESP8266 with a LAN splitter to a HS01B-1.
The height and the controls for the presets are working fine.

Unfortunately the controls on the pyhsical control panel aren’t working anymore, if D5 (TX) is connected.
If everything except D5 is connected the physical controls stay completely functional and the height gets transmitted correct to esphome.

Another issue is that the physical display becomes laggy when D5 is connected and the desk is controlled via the esp.

What could be the issue of this behavior?
Is there any fix to this problem?

Wiring ESP3286

Hello all,

I just want to solder the wiring together. Unfortunately, I have problems understanding the PINs for SWIN and PIN20. Also, I'm not sure if I need to use D5 and D6 for TX/RX or TX/RX on the esp.

Where do they belong on the ESP?

20230310_131546
20230310_121732
20230310_134352

ESP32 pin RJ45 pin RJ45 cable color (T568B)
+5V 8 brown
GND 7 white-brown
17 (TX) 6 green
16 (RX) 5 white-blue
23 ("Pin20") 4 blue
RJ45 pin Name Original Cable Color Ethernet cable color (T568B)
8 RESET Brown White-Orange
7 SWIM White Orange
6 EMPTY Purple White-Green
5 PIN 20 Red Blue
4 RX Green White-Blue
3 TX Black Green
2 GND Blue White-Brown
1 +5V (VDD) Yellow Brown

Working Setup for CB28M1B-1 (2 RJ45-ports) with HS13A-1 and ESP32dev

Disclaimer: I´m from germany and my englisch isn´t very good ... Sorry

Hello. With help from @iMicknl i was able to get my desk smart. Wanted to share my setup so that others may have an easy way to smart-up their desks :)

Hardware

Wiring
image

ESPHome

`substitutions:
device_name: Schreibtisch
name: esp-schreibtisch
min_height: "75.1" # Min height + 0.1
max_height: "109.1" # Max height - 0.1

esphome:
name: ${name}
comment: ${device_name}
platform: esp32
board: esp32dev
includes:
- desk_height_sensor.h

project:
name: "imicknl.loctekmotion_iot"
version: "1.0.0"

Wake Desk by sending the "M" command

This will pull the current height after boot

on_boot:
priority: -10
then:
- button.press: button_m

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

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: "Esp-Schreibtisch"
password: ""

captive_portal:

Enable logging

logger:
level: DEBUG

level: VERBOSE # Makes uart stream available in esphome logstream

baud_rate: 0 # Disable logging over uart

Enable Home Assistant API

api:

ota:
password: ""

uart:
id: desk_uart
baud_rate: 9600
tx_pin: GPIO17
rx_pin: GPIO16

sensor:

  • platform: wifi_signal
    name: "WiFi Signal"
    update_interval: 60s

  • platform: uptime
    name: Uptime

  • platform: custom
    lambda: |-
    auto desk_height_sensor = new DeskHeightSensor(id(desk_uart));
    App.register_component(desk_height_sensor);
    return {desk_height_sensor};
    sensors:
    id: "desk_height"
    name: Desk Height
    unit_of_measurement: cm
    accuracy_decimals: 1
    icon: "mdi:counter"
    state_class: "measurement"
    on_value:
    then:
    - cover.template.publish:
    id: desk_cover
    position: !lambda |-
    // The sensor outputs values from min_height (cm) to max_height (cm)
    // We need to translate this to 0 - 1 scale.
    float position = (float(x) - float(${min_height})) / (float(${max_height}) - float(${min_height}));
    ESP_LOGD("main", "X is %f", x);
    ESP_LOGD("main", "Current position is %f", position);
    return position;
    switch:

PIN20

  • platform: gpio
    name: "Virtual Screen"
    pin:
    number: GPIO23
    mode: OUTPUT
    restore_mode: ALWAYS_ON
    entity_category: "config"
    internal: true

  • platform: uart
    name: "Up"
    id: switch_up2
    icon: mdi:arrow-up-bold
    data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
    uart_id: desk_uart
    send_every: 108ms

  • platform: uart
    name: "Down"
    id: switch_down2
    icon: mdi:arrow-down-bold
    data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
    uart_id: desk_uart
    send_every: 108ms

button:

  • platform: template
    name: "Preset 1"
    icon: mdi:numeric-1-box
    on_press:

    • uart.write:
      id: desk_uart
      data: [0x9b, 0x06, 0x02, 0x04, 0x00, 0xac, 0xa3, 0x9d]
  • platform: template
    name: "Preset 2"
    icon: mdi:numeric-2-box
    on_press:

    • uart.write:
      id: desk_uart
      data: [0x9b, 0x06, 0x02, 0x08, 0x00, 0xac, 0xa6, 0x9d]
  • platform: template
    name: "Sit" # Preset 3 on some control panels
    icon: mdi:chair-rolling
    on_press:

    • uart.write:
      id: desk_uart
      data: [0x9b, 0x06, 0x02, 0x00, 0x01, 0xac, 0x60, 0x9d]
  • platform: template
    name: "Stand"
    icon: mdi:human-handsup
    on_press:

    • uart.write:
      id: desk_uart
      data: [0x9b, 0x06, 0x02, 0x10, 0x00, 0xac, 0xac, 0x9d]
  • platform: template
    name: "Memory"
    id: button_m
    icon: mdi:alpha-m-box
    entity_category: "config"
    on_press:

    • uart.write:
      id: desk_uart
      data: [0x9b, 0x06, 0x02, 0x20, 0x00, 0xac, 0xb8, 0x9d]
  • platform: template
    name: "Wake Screen"
    id: button_wake_screen
    icon: mdi:gesture-tap-button
    entity_category: "config"
    on_press:

    • uart.write:
      id: desk_uart
      data: [0x9b, 0x06, 0x02, 0x00, 0x00, 0x6c, 0xa1, 0x9d]
  • platform: template
    name: "Alarm"
    id: button_alarm
    icon: mdi:alarm
    on_press:

    • uart.write:
      id: desk_uart
      data: [0x9b, 0x06, 0x02, 0x40, 0x00, 0xAC, 0x90, 0x9d]
  • platform: restart
    name: "Restart"
    entity_category: "config"

cover:

  • platform: template
    id: "desk_cover"
    icon: mdi:desk # or mdi:human-male-height-variant
    name: "Desk"
    device_class: blind # makes it easier to integrate with Google/Alexa
    has_position: true
    position_action:

    • logger.log: "Requesting action change"

    Move desk up

    open_action:

    • while:
      condition:
      sensor.in_range:
      id: desk_height
      below: ${max_height}
      then:
      - logger.log: "Executing up command"
      - cover.template.publish:
      id: desk_cover
      current_operation: OPENING
      - uart.write:
      id: desk_uart
      data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
      - delay: 108ms

    Move desk down

    close_action:

    • while:
      condition:
      sensor.in_range:
      id: desk_height
      above: ${min_height}
      then:
      - logger.log: "Executing down command"
      - cover.template.publish:
      id: desk_cover
      current_operation: CLOSING
      - uart.write:
      id: desk_uart
      data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
      - delay: 108ms
      optimistic: true`

Raspberry Pi Pin20 confusion

Hi,

I'm trying to connect my Flexispot desk using a Raspberry Pi Zero W.
I'm confused about which GPIO port to use for PIN20:

The README says PIN20 shall be connected to GPIO18, which is physical pin 12.

The Python script, however, sets PIN_20 to 12, and also sets GPIO mode to BCM:


GPIO 12 would be Pin32 on the Raspberry.

Which is the correct one?

Note: I am able to control the desk using the script, but only if I activate the touch panel (HS13A-1) manually beforehand.
Once the touch panel goes to sleep, no commands are being issued, which tells me something is not working correctly with PIN20?
My control box is a CB38M2J(IB)-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.