Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added files and comments for using ESP32 with Flexispot E7 #56

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/esphome/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
| D5 | TX | Black | Green |
| D2 | PIN 20 | Red | Blue |

| ESP32 | Loctek Controller (E7) | Loctek Motion Cable Color (HS13B-1)|
| ------- | ----------------------- | ---------------------------------- |
| GND | GND | Blue |
| GPIO16 | RX | Green |
| GPIO17 | TX | Black |
| GPIO23 | PIN 20 | Red |

## HS13A-1

Expand Down Expand Up @@ -62,7 +68,7 @@ See [README](../../README.md#control-panels) for more details. If your board sup

Please refer to the [ESPHome documentation](https://esphome.io/guides/getting_started_command_line.html).

You can use `flexispot_ek5.yaml` *(HS13A-1, HS13B-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.
You can use `flexispot_ek5.yaml` *(HS13A-1, HS13B-1)*/ `flexispot_e7.yaml` *(HS13B-1) ESP32* 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

Expand All @@ -71,7 +77,7 @@ You can use `flexispot_ek5.yaml` *(HS13A-1, HS13B-1)* or `flexispot_e5b.yaml` *(
- Current height via sensor entity
- M button via switch entity
- Wake up button via switch entity (currently just used for testing, doesn't seem functional yet)
- Support for ESP32 (E5b only)
- Support for ESP32 (E5b & E7)
- Support for keypad (E5b only)

## Screenshots
Expand Down
217 changes: 217 additions & 0 deletions packages/esphome/flexispot_e7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
substitutions:
device_name: Flexispot E7
name: flexispote7
min_height: "73.6" # Min height + 0.1
max_height: "122.9" # Max height - 0.1

esphome:
name: ${name}
comment: ${device_name}
platform: ESP32 # TODO Change to your platform
board: nodemcu-32s # 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: GPIO17
rx_pin: GPIO16

script:
- id: screen_timer
mode: restart
then:
# on_start
- logger.log: "Executing screen timer command"
- switch.turn_on: virtual_screen
- delay: 12s # timer length (keypad screen timeout is 10s + 2s buffer)
- switch.turn_off: virtual_screen
# on_end

- id: script_start_command
mode: restart
then:
- logger.log: "Executing Empty command"
- if:
condition:
switch.is_off : virtual_screen
then:
- script.execute: screen_timer
- delay: 480ms
else:
- script.execute: screen_timer

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"
on_value:
then:
- script.execute: screen_timer

switch:
- platform: template
name: "Preset 1"
id: switch_preset1
icon: mdi:numeric-1-box
turn_on_action:
- logger.log: "Executing Preset 1 command"
- script.execute: script_start_command
- script.wait: script_start_command
- uart.write:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x04, 0x00, 0xac, 0xa3, 0x9d]
internal: false

- platform: template
name: "Preset 2"
id: switch_preset2
icon: mdi:numeric-2-box
turn_on_action:
- logger.log: "Executing Preset 2 command"
- script.execute: script_start_command
- script.wait: script_start_command
- uart.write:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x08, 0x00, 0xac, 0xa6, 0x9d]
internal: false

- platform: template
name: "Stand"
id: switch_preset3
icon: mdi:numeric-3-box
turn_on_action:
- logger.log: "Executing Preset 3 command"
- script.execute: script_start_command
- script.wait: script_start_command
- uart.write:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x10, 0x00, 0xac, 0xac, 0x9d]
internal: false

- platform: template
name: "Sit"
id: switch_preset4
icon: mdi:numeric-4-box
turn_on_action:
- logger.log: "Executing Preset 4 command"
- script.execute: script_start_command
- script.wait: script_start_command
- uart.write:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x00, 0x01, 0xac, 0x60, 0x9d]
internal: false

- platform: template
name: "M"
id: switch_m
icon: mdi:alpha-m-circle
turn_on_action:
- logger.log: "Executing M command"
- script.execute: script_start_command
- script.wait: script_start_command
- uart.write:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x20, 0x00, 0xac, 0xb8, 0x9d]
internal: false

- platform: gpio # Does not seem to wake the screen as i would expect since its assigned to pin 20 that should give the singnal needed to wake the screen however the other actions already wake the screen as is so maybe not a big deal
name: "Virtual Screen"
id: "virtual_screen"
pin:
number: 23
restore_mode: ALWAYS_OFF
internal: false

- 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: false

- 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: false

# - 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: #Up Arrow does not work for some reason but still leaving in for others
# - platform: template
# 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