mirror of
https://github.com/tjhorner/upsy-desky.git
synced 2026-01-10 15:58:02 -05:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0567307595 | ||
|
|
7a881dc1ee | ||
|
|
148b9cd379 | ||
|
|
655cb303d3 | ||
|
|
f4d61cdb36 | ||
|
|
1986a79782 | ||
|
|
a0602c1201 | ||
|
|
4f3b5acf58 | ||
|
|
b238eb40c3 | ||
|
|
eb54c2c405 | ||
|
|
c09fa97c77 | ||
|
|
273dd62d9a | ||
|
|
16792d6954 |
2
.github/workflows/build.yaml
vendored
2
.github/workflows/build.yaml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
- name: Compile Release Firmware
|
||||
working-directory: firmware
|
||||
run: |
|
||||
esphome compile config.yaml
|
||||
esphome compile stock.yaml
|
||||
mkdir -p bin
|
||||
cp .esphome/build/upsy-desky/.pioenvs/upsy-desky/firmware-factory.bin bin/firmware-factory.bin
|
||||
cp .esphome/build/upsy-desky/.pioenvs/upsy-desky/firmware.bin bin/firmware.bin
|
||||
|
||||
18
firmware/README.md
Normal file
18
firmware/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Firmware Configs
|
||||
|
||||
This directory contains [ESPHome](https://esphome.io) config files for the Upsy Desky.
|
||||
|
||||
It is organized like so:
|
||||
|
||||
- `base.yaml`: The base essential configuration, which contains components for reading the desk height, preset buttons, etc.
|
||||
- `stock.yaml`: Inherits everything from `base.yaml` and adds components which are useful on stock firmware, such as the WiFi hotspot, web server, and Improv Serial
|
||||
- `debug.yaml`: Inherits everything from `stock.yaml` and adds components which are useful for debugging
|
||||
|
||||
## Addons
|
||||
|
||||
Major parts of the config are separated into "addons" so they can be easily included or excluded. The following addons are available:
|
||||
|
||||
- `presets.yaml`: Adds support for recalling and setting presets on the desk control box
|
||||
- `runtime-config.yaml`: Adds support for runtime configuration options (you might want to remove this if you are configuring everything via ESPHome yaml)
|
||||
- `bluetooth-proxy.yaml`: Contains the necessary configuration to use the Upsy Desky as a [Bluetooth Proxy](https://esphome.io/components/bluetooth_proxy.html)
|
||||
- `stable-ids.yaml`: Contains configuration necessary to keep some entity IDs stable via the HTTP API
|
||||
4
firmware/addons/bluetooth-proxy.yaml
Normal file
4
firmware/addons/bluetooth-proxy.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
esp32_ble_tracker:
|
||||
|
||||
bluetooth_proxy:
|
||||
active: true
|
||||
105
firmware/addons/presets.yaml
Normal file
105
firmware/addons/presets.yaml
Normal file
@@ -0,0 +1,105 @@
|
||||
output:
|
||||
- platform: gpio
|
||||
inverted: true
|
||||
id: button_bit1
|
||||
pin: ${button_bit1_pin}
|
||||
|
||||
- platform: gpio
|
||||
inverted: true
|
||||
id: button_bit2
|
||||
pin: ${button_bit2_pin}
|
||||
|
||||
- platform: gpio
|
||||
inverted: true
|
||||
id: button_bit4
|
||||
pin: ${button_bit4_pin}
|
||||
|
||||
- platform: gpio
|
||||
inverted: true
|
||||
id: button_m
|
||||
pin: ${button_m_pin}
|
||||
|
||||
button:
|
||||
# Recall Presets
|
||||
- platform: template
|
||||
id: recall_preset_1
|
||||
name: "Preset 1"
|
||||
icon: "mdi:numeric-1-box"
|
||||
on_press:
|
||||
- output.turn_on: button_bit1
|
||||
- output.turn_on: button_bit2
|
||||
- delay: 1s
|
||||
- output.turn_off: button_bit2
|
||||
- output.turn_off: button_bit1
|
||||
|
||||
- platform: template
|
||||
id: recall_preset_2
|
||||
name: "Preset 2"
|
||||
icon: "mdi:numeric-2-box"
|
||||
on_press:
|
||||
- output.turn_on: button_bit4
|
||||
- delay: 100ms
|
||||
- output.turn_off: button_bit4
|
||||
|
||||
- platform: template
|
||||
id: recall_preset_3
|
||||
name: "Preset 3"
|
||||
icon: "mdi:numeric-3-box"
|
||||
on_press:
|
||||
- output.turn_on: button_bit2
|
||||
- output.turn_on: button_bit4
|
||||
- delay: 100ms
|
||||
- output.turn_off: button_bit4
|
||||
- output.turn_off: button_bit2
|
||||
|
||||
- platform: template
|
||||
id: recall_preset_4
|
||||
name: "Preset 4"
|
||||
icon: "mdi:numeric-4-box"
|
||||
on_press:
|
||||
- output.turn_on: button_bit4
|
||||
- output.turn_on: button_bit1
|
||||
- delay: 100ms
|
||||
- output.turn_off: button_bit1
|
||||
- output.turn_off: button_bit4
|
||||
|
||||
# Set Presets
|
||||
- platform: template
|
||||
name: "Set Preset 1"
|
||||
entity_category: "config"
|
||||
icon: "mdi:numeric-1-box-multiple"
|
||||
on_press:
|
||||
- output.turn_on: button_m
|
||||
- delay: 100ms
|
||||
- output.turn_off: button_m
|
||||
- button.press: recall_preset_1
|
||||
|
||||
- platform: template
|
||||
name: "Set Preset 2"
|
||||
entity_category: "config"
|
||||
icon: "mdi:numeric-2-box-multiple"
|
||||
on_press:
|
||||
- output.turn_on: button_m
|
||||
- delay: 100ms
|
||||
- output.turn_off: button_m
|
||||
- button.press: recall_preset_2
|
||||
|
||||
- platform: template
|
||||
name: "Set Preset 3"
|
||||
entity_category: "config"
|
||||
icon: "mdi:numeric-3-box-multiple"
|
||||
on_press:
|
||||
- output.turn_on: button_m
|
||||
- delay: 100ms
|
||||
- output.turn_off: button_m
|
||||
- button.press: recall_preset_3
|
||||
|
||||
- platform: template
|
||||
name: "Set Preset 4"
|
||||
entity_category: "config"
|
||||
icon: "mdi:numeric-4-box-multiple"
|
||||
on_press:
|
||||
- output.turn_on: button_m
|
||||
- delay: 100ms
|
||||
- output.turn_off: button_m
|
||||
- button.press: recall_preset_4
|
||||
54
firmware/addons/runtime-config.yaml
Normal file
54
firmware/addons/runtime-config.yaml
Normal file
@@ -0,0 +1,54 @@
|
||||
select:
|
||||
- platform: template
|
||||
name: "Height Units"
|
||||
entity_category: "config"
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
options:
|
||||
- in
|
||||
- cm
|
||||
initial_option: ${default_height_units}
|
||||
on_value:
|
||||
then:
|
||||
lambda: |
|
||||
id(desk_height)->set_unit_of_measurement(x);
|
||||
id(target_desk_height)->traits.set_unit_of_measurement(x);
|
||||
|
||||
button:
|
||||
- platform: template
|
||||
name: "Re-Detect Decoder"
|
||||
entity_category: "config"
|
||||
icon: "mdi:cog-refresh"
|
||||
on_press:
|
||||
- uart.write:
|
||||
id: handset_tx
|
||||
data: [ 0x0 ]
|
||||
- standing_desk_height.detect_decoder: desk_height
|
||||
|
||||
number:
|
||||
- platform: template
|
||||
name: "Min Target Height"
|
||||
entity_category: "config"
|
||||
min_value: 0
|
||||
max_value: 150
|
||||
step: 0.1
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
initial_value: ${standing_desk_min_height}
|
||||
on_value:
|
||||
then:
|
||||
lambda: |
|
||||
id(target_desk_height)->traits.set_min_value(x);
|
||||
- platform: template
|
||||
name: "Max Target Height"
|
||||
entity_category: "config"
|
||||
min_value: 0
|
||||
max_value: 150
|
||||
step: 0.1
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
initial_value: ${standing_desk_max_height}
|
||||
on_value:
|
||||
then:
|
||||
lambda: |
|
||||
id(target_desk_height)->traits.set_max_value(x);
|
||||
35
firmware/addons/stable-ids.yaml
Normal file
35
firmware/addons/stable-ids.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
# This file provides stable entity IDs for various components, in order to be used in the HTTP API.
|
||||
|
||||
# ESPHome derives entity IDs (internally called "object IDs") from the component name, which is
|
||||
# used as the ID in the HTTP API endpoints. Unfortunately there is no way to control them so they
|
||||
# are set independently of the name, so this is a weird workaround for that.
|
||||
|
||||
sensor:
|
||||
- platform: copy
|
||||
source_id: desk_height
|
||||
internal: true
|
||||
name: "desk_height"
|
||||
|
||||
number:
|
||||
- platform: copy
|
||||
source_id: target_desk_height
|
||||
internal: true
|
||||
name: "target_desk_height"
|
||||
|
||||
button:
|
||||
- platform: copy
|
||||
source_id: recall_preset_1
|
||||
internal: true
|
||||
name: "desk_preset_1"
|
||||
- platform: copy
|
||||
source_id: recall_preset_2
|
||||
internal: true
|
||||
name: "desk_preset_2"
|
||||
- platform: copy
|
||||
source_id: recall_preset_3
|
||||
internal: true
|
||||
name: "desk_preset_3"
|
||||
- platform: copy
|
||||
source_id: recall_preset_4
|
||||
internal: true
|
||||
name: "desk_preset_4"
|
||||
63
firmware/base.yaml
Normal file
63
firmware/base.yaml
Normal file
@@ -0,0 +1,63 @@
|
||||
# Essential ESPHome config options
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
name_add_mac_suffix: true
|
||||
on_boot:
|
||||
then:
|
||||
# Wakes up the desk and reports height
|
||||
- uart.write:
|
||||
id: handset_tx
|
||||
data: [ 0x0 ]
|
||||
project:
|
||||
name: tj_horner.upsy_desky
|
||||
version: "1.0.0"
|
||||
|
||||
uart:
|
||||
id: handset_tx
|
||||
tx_pin: 16
|
||||
baud_rate: 9600
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
|
||||
# Configurable options
|
||||
substitutions:
|
||||
name: "upsy-desky"
|
||||
friendly_name: "Upsy Desky"
|
||||
desk_height_name: "Desk Height"
|
||||
target_desk_height_name: "Target Desk Height"
|
||||
|
||||
# Standing Desk Component Config
|
||||
standing_desk_uart_rx_pin: "17"
|
||||
standing_desk_up_pin: "21"
|
||||
standing_desk_down_pin: "22"
|
||||
standing_desk_min_height: "25.2"
|
||||
standing_desk_max_height: "50.8"
|
||||
|
||||
# Presets Addon Config
|
||||
button_bit1_pin: "21"
|
||||
button_bit2_pin: "22"
|
||||
button_bit4_pin: "19"
|
||||
button_m_pin: "18"
|
||||
|
||||
# Runtime Config Defaults
|
||||
default_height_units: "in" # Must be "in" or "cm"
|
||||
|
||||
packages:
|
||||
standing_desk: github://tjhorner/esphome-standing-desk/configs/template.yaml
|
||||
addon_presets: !include addons/presets.yaml
|
||||
addon_stable_ids: !include addons/stable-ids.yaml
|
||||
addon_runtime_config: !include addons/runtime-config.yaml
|
||||
addon_bluetooth_proxy: !include addons/bluetooth-proxy.yaml
|
||||
|
||||
button:
|
||||
- platform: restart
|
||||
name: "Restart"
|
||||
|
||||
light:
|
||||
- platform: status_led
|
||||
id: upsy_desky_status_led
|
||||
name: "Status LED"
|
||||
pin: GPIO23
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
@@ -1,133 +1,8 @@
|
||||
substitutions:
|
||||
name: "upsy-desky"
|
||||
friendly_name: "Upsy Desky"
|
||||
# This file is here for reverse compatibility. Older versions of the firmware
|
||||
# pointed to `config.yaml` instead of `base.yaml`. That file also included the
|
||||
# config found in `stock.yaml`, which is why it's being included here.
|
||||
|
||||
# Defaults
|
||||
standing_desk_uart_rx_pin: "17"
|
||||
standing_desk_up_pin: "21"
|
||||
standing_desk_down_pin: "22"
|
||||
standing_desk_variant: "uplift"
|
||||
standing_desk_min_height: "25.2"
|
||||
standing_desk_max_height: "50.8"
|
||||
|
||||
# Presets
|
||||
button_bit1_pin: "21"
|
||||
button_bit2_pin: "22"
|
||||
button_bit4_pin: "19"
|
||||
button_m_pin: "18"
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
name_add_mac_suffix: true
|
||||
on_boot:
|
||||
then:
|
||||
# Wakes up the desk and reports height
|
||||
- uart.write:
|
||||
id: handset_tx
|
||||
data: [ 0x0 ]
|
||||
project:
|
||||
name: tj_horner.upsy_desky
|
||||
version: "0.2.1"
|
||||
|
||||
dashboard_import:
|
||||
package_import_url: github://tjhorner/upsy-desky/firmware/config.yaml
|
||||
|
||||
uart:
|
||||
id: handset_tx
|
||||
tx_pin: 16
|
||||
baud_rate: 9600
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
|
||||
logger:
|
||||
level: INFO
|
||||
|
||||
wifi:
|
||||
ap:
|
||||
password: "hunter2hunter2"
|
||||
|
||||
captive_portal:
|
||||
|
||||
improv_serial:
|
||||
|
||||
api:
|
||||
password: ""
|
||||
reboot_timeout: 0s
|
||||
|
||||
web_server:
|
||||
port: 80
|
||||
|
||||
ota:
|
||||
password: ""
|
||||
# Please use `base.yaml` for new configurations and customizations.
|
||||
|
||||
packages:
|
||||
standing_desk: github://tjhorner/esphome-standing-desk/configs/template.yaml@master
|
||||
presets_addon: github://tjhorner/esphome-standing-desk/configs/addons/presets.yaml@master
|
||||
|
||||
select:
|
||||
- platform: template
|
||||
name: "${friendly_name} Height Decoder Variant"
|
||||
entity_category: "config"
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
options:
|
||||
- uplift
|
||||
- jarvis
|
||||
- omnidesk
|
||||
initial_option: ${standing_desk_variant}
|
||||
on_value:
|
||||
then:
|
||||
lambda: "id(desk_height)->set_decoder_variant(x);"
|
||||
- platform: template
|
||||
name: "${friendly_name} Height Units"
|
||||
entity_category: "config"
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
options:
|
||||
- in
|
||||
- cm
|
||||
initial_option: in
|
||||
on_value:
|
||||
then:
|
||||
lambda: |
|
||||
id(desk_height)->set_unit_of_measurement(x);
|
||||
id(target_desk_height)->traits.set_unit_of_measurement(x);
|
||||
|
||||
number:
|
||||
- platform: template
|
||||
name: "${friendly_name} Min Target Height"
|
||||
entity_category: "config"
|
||||
min_value: 0
|
||||
max_value: 150
|
||||
step: 0.1
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
initial_value: ${standing_desk_min_height}
|
||||
on_value:
|
||||
then:
|
||||
lambda: |
|
||||
id(target_desk_height)->traits.set_min_value(x);
|
||||
- platform: template
|
||||
name: "${friendly_name} Max Target Height"
|
||||
entity_category: "config"
|
||||
min_value: 0
|
||||
max_value: 150
|
||||
step: 0.1
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
initial_value: ${standing_desk_max_height}
|
||||
on_value:
|
||||
then:
|
||||
lambda: |
|
||||
id(target_desk_height)->traits.set_max_value(x);
|
||||
|
||||
button:
|
||||
- platform: restart
|
||||
name: "${friendly_name} Restart"
|
||||
|
||||
light:
|
||||
- platform: status_led
|
||||
id: upsy_desky_status_led
|
||||
pin: GPIO23
|
||||
restore_mode: ALWAYS_ON
|
||||
stock: !include stock.yaml
|
||||
@@ -1,5 +1,5 @@
|
||||
packages:
|
||||
base: !include config.yaml
|
||||
stock: !include stock.yaml
|
||||
|
||||
logger:
|
||||
level: DEBUG
|
||||
@@ -10,4 +10,4 @@ debug:
|
||||
text_sensor:
|
||||
- platform: debug
|
||||
device:
|
||||
name: "${friendly_name} Device Info"
|
||||
name: "Device Info"
|
||||
26
firmware/stock.yaml
Normal file
26
firmware/stock.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
packages:
|
||||
base: !include base.yaml
|
||||
|
||||
logger:
|
||||
level: INFO
|
||||
|
||||
wifi:
|
||||
ap:
|
||||
password: "hunter2hunter2"
|
||||
|
||||
captive_portal:
|
||||
|
||||
improv_serial:
|
||||
|
||||
api:
|
||||
password: ""
|
||||
reboot_timeout: 0s
|
||||
|
||||
web_server:
|
||||
port: 80
|
||||
|
||||
ota:
|
||||
password: ""
|
||||
|
||||
dashboard_import:
|
||||
package_import_url: github://tjhorner/upsy-desky/firmware/stock.yaml@v1.0.0
|
||||
@@ -425,7 +425,7 @@
|
||||
"workbook_filename": ""
|
||||
},
|
||||
"page_layout_descr_file": "",
|
||||
"plot_directory": "",
|
||||
"plot_directory": "./",
|
||||
"spice_adjust_passive_values": false,
|
||||
"spice_external_command": "spice \"%I\"",
|
||||
"subpart_first_id": 65,
|
||||
|
||||
9
tools/README.md
Normal file
9
tools/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Tools
|
||||
|
||||
## `oem-flash.sh`
|
||||
|
||||
This script is used before shipment to flash the Upsy Desky with the stock firmware, and to reprogram the CP2102 USB-to-serial chip with the correct name and serial (based on MAC address).
|
||||
|
||||
## `test-flash.sh`
|
||||
|
||||
Flashes the test firmware with PlatformIO (see `../test-firmware`).
|
||||
12
tools/oem-flash.sh
Executable file
12
tools/oem-flash.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
MAC_ADDR=$(esptool.py --chip esp32 read_mac | sed -En "s/MAC: (.*)/\1/p" | uniq | sed 's/://g')
|
||||
esphome upload --device /dev/cu.usbserial* ../firmware/stock.yaml
|
||||
|
||||
if ! command -v cp210x-cfg &> /dev/null
|
||||
then
|
||||
# Get cp210x-cfg from https://github.com/DiUS/cp210x-cfg
|
||||
echo "cp210x-cfg was not found; CP2102 will not be serialized or renamed"
|
||||
else
|
||||
cp210x-cfg -N "Upsy Desky" -S $MAC_ADDR
|
||||
fi
|
||||
2
tools/test-flash.sh
Executable file
2
tools/test-flash.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
platformio run -d ../test-firmware --target upload --environment test_target
|
||||
Reference in New Issue
Block a user