From 8cebf6df62227036c84c97b00dd05f07f2adc0b5 Mon Sep 17 00:00:00 2001 From: David Born Date: Mon, 5 Apr 2021 12:28:59 +0200 Subject: [PATCH] Add example for HS01B-1 and updated README files. --- README.md | 41 ++++---- packages/esphome/README.md | 37 +++++-- packages/esphome/flexispot_e5b.yaml | 154 ++++++++++++++++++++++++++++ 3 files changed, 202 insertions(+), 30 deletions(-) create mode 100644 packages/esphome/flexispot_e5b.yaml diff --git a/README.md b/README.md index 48409d1..21be7d0 100644 --- a/README.md +++ b/README.md @@ -56,16 +56,16 @@ If your control panel is missing, feel free to [create an issue](https://github. - **Tested with control box**: CB38M2B(IB)-1 - **Source**: Printed on the PCB of the control box. -| RJ45 pin | Name | Cable Color | -| -------- | ---------- | ----------- | -| 8 | RESET SWIM | Brown | -| 7 | PIN 20 | White | -| 6 | RX | Purple | -| 5 | TX | Red | -| 4 | GND1 | Green | -| 3 | +5V (VDD) | Black | -| 2 | 29V+ | Blue | -| 1 | 29V- | Yellow | +| RJ45 pin | Name | Original Cable Color | Ethernet cable color (T568B) | +| -------- | ---------- | -------------------- | ---------------------------- | +| 8 | RESET SWIM | Brown | White-Orange | +| 7 | PIN 20 | White | Orange | +| 6 | RX | Purple | White-Green | +| 5 | TX | Red | Blue | +| 4 | GND1 | Green | White-Blue | +| 3 | +5V (VDD) | Black | Green | +| 2 | 29V+ | Blue | White-Brown | +| 1 | 29V- | Yellow | Brown | #### [HS01B-1](https://www.loctekmotion.com/shop/control-panel/hs05a-1/) @@ -73,17 +73,16 @@ If your control panel is missing, feel free to [create an issue](https://github. - **Tested with control box**: unknown - **Source**: [nv1t/standing-desk-interceptor](https://github.com/nv1t/standing-desk-interceptor) -| RJ45 pin | Name | Cable Color | -| -------- | --------- | ----------- | -| 8 | +5V (VDD) | Yellow | -| 7 | GND | Blue | -| 6 | TX | Black | -| 5 | RX | Green | -| 4 | PIN 20 | Red | -| 3 | (unknown) | Purple | -| 2 | SWIM | White | -| 1 | RES | Brown | - +| RJ45 pin | Name | Original Cable Color | Ethernet cable color (T568B) | +| -------- | --------- | --------------------- | ---------------------------- | +| 8 | +5V (VDD) | Yellow | Brown | +| 7 | GND | Blue | White-Brown | +| 6 | TX | Black | Green | +| 5 | RX | Green | White-Blue | +| 4 | PIN 20 | Red | Blue | +| 3 | (unknown) | Purple | White-Green | +| 2 | SWIM | White | Orange | +| 1 | RES | Brown | White-Orange | Other control panels / control boxes could be supported in the same way, but you would need to figure the RJ45 pinout mapping. Most control boxes have an extra RJ45 port for serial communication, but otherwise you would need to place your device in between the control panel and the control box. diff --git a/packages/esphome/README.md b/packages/esphome/README.md index dc4da24..dd1be87 100644 --- a/packages/esphome/README.md +++ b/packages/esphome/README.md @@ -2,20 +2,39 @@ >ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems. -| ESP8266 | Loctek Motion | -| ------- | ------------- | -| GND | GND | -| D6 | RX | -| D5 | TX | -| D2 | PIN 20 | - -See [README](../../README.md#control-panels) for more details. If your board supports a 5V input, you could use the 5V provided by the control box to power your controller as well. +## [HS13A-1](https://www.loctekmotion.com/shop/control-panel/hs13a-1/) + +| ESP8266 | Loctek Motion (HS13A-1) | Loctek Motion Cable Color (HS13A-1)| +| ------- | ----------------------- | ---------------------------------- | +| GND | GND | Green | +| D6 | RX | Purple | +| D5 | TX | Red | +| D2 | PIN 20 | White | + +## [HS01B-1](https://www.loctekmotion.com/shop/control-panel/hs05a-1/) + +| ESP8266 | Loctek Motion (HS01B-1) | Loctek Motion Cable Color (HS01B-1)| +| ------- | ----------------------- | ---------------------------------- | +| GND | GND | Blue | +| D6 | RX | Green | +| D5 | TX | Black | +| D2 | PIN 20 | Red | + +See [README](../../README.md#control-panels) for more details. If your board supports a 5V input, you could use the 5V provided by the control box to power your controller as well: + +| ESP8266 | Loctek Motion (HS13A-1) | Loctek Motion (HS01B-1) | +| ------- | ----------------------- | ----------------------- | +| GND | GND | GND | +| D6 | RX | RX | +| D5 | TX | TX | +| D2 | PIN 20 | PIN 20 | +| VIN | +5V (VDD) | +5V (VDD) | ## Installation Please refer to the [ESPHome documentation](https://esphome.io/guides/getting_started_command_line.html). -You can use `flexispot_ek5.yaml` as a boilerplate for your own implementation. This implementation has been created for the ESP8266 nodemcu, but can easily be adopted for other platforms and boards. +You can use `flexispot_ek5.yaml` *(HS13A-1)* or `flexispot_e5b.yaml` *(HS01B-1)* as a boilerplate for your own implementation. This implementation has been created for the ESP8266 nodemcu, but can easily be adopted for other platforms and boards. ## Features diff --git a/packages/esphome/flexispot_e5b.yaml b/packages/esphome/flexispot_e5b.yaml new file mode 100644 index 0000000..a114c8b --- /dev/null +++ b/packages/esphome/flexispot_e5b.yaml @@ -0,0 +1,154 @@ +substitutions: + device_name: Flexispot E5B + name: flexispot_e5b + min_height: "73.6" # Min height + 0.1 + max_height: "122.9" # Max height - 0.1 + +esphome: + name: ${name} + comment: ${device_name} + platform: ESP8266 # TODO Change to your platform + board: nodemcuv2 # TODO Change to your board + 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 ha_api_password + +ota: + password: !secret ha_api_password + +uart: + - id: desk_uart + baud_rate: 9600 + tx_pin: D5 + rx_pin: D6 + +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: D2 + mode: OUTPUT + restore_mode: ALWAYS_ON + 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: "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: "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, 0x00, 0xac, 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 \ No newline at end of file