esphome:
  name: maidsite-desk-controller
  friendly_name: Maidsite Desk Controller

external_components:
  - source:
      type: local
      path: esphome_components/components/
      # type: git
      # url: https://github.com/ElVit/esphome_components/
    components: [ maidsite_desk ]

uart:
  - id: uart_bus
    tx_pin: $pin_tx
    rx_pin: $pin_rx
    baud_rate: 9600

maidsite_desk_controller:
  id: my_desk
  uart_id: uart_bus

sensor:
  - platform: maidsite_desk
    height_abs:
      name: "Height absolut"
    height_pct:
      name: "Height percent"
    height_min:
      name: "Height Min"
    height_max:
      name: "Height Max"
    position_m1:
      name: "Position M1"
    position_m2:
      name: "Position M2"
    position_m3:
      name: "Position M3"
    position_m4:
      name: "Position M4"

button:
  - platform: maidsite_desk
    stop:
      name: "Stop"
    step_up:
      name: "Step up"
    step_down:
      name: "Step down"
    goto_max:
      name: "Move to MAX"
    goto_min:
      name: "Move to MIN"
    goto_m1:
      name: "Move to M1"
    goto_m2:
      name: "Move to M2"
    goto_m3:
      name: "Move to M3"
    goto_m4:
      name: "Move to M4"
    save_m1:
      name: "Save M1"
    save_m2:
      name: "Save M2"
    save_m3:
      name: "Save M3"
    save_m4:
      name: "Save M4"

number:
  - platform: maidsite_desk
    height_abs:
      name: "Height absolut"
      mode: SLIDER
    height_pct:
      name: "Height percent"
      mode: SLIDER

## lambda usage
# button:
#   - platform: template
#     name: "Step up"
#     on_press:
#       lambda: "id(my_desk).step_up();"
#   - platform: template
#     name: "Step down"
#     on_press:
#       lambda: "id(my_desk).step_down();"
#   - platform: template
#     name: "Stop"
#     on_press:
#       lambda: "id(my_desk).stop();"
#   - platform: template
#     name: "Position 2"
#     on_press:
#       lambda: "id(my_desk).goto_mem_position(2);"
#   - platform: template
#     name: "Save Position 4"
#     on_press:
#       lambda: "id(my_desk).save_mem_position(4);"
#   - platform: template
#     name: "Go to 100cm"
#     on_press:
#       lambda: "id(my_desk).goto_height(100);"

# the usual stuff

esp32:
  board: esp32-c3-devkitm-1
  variant: ESP32C3
  framework:
    type: esp-idf

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: "esphome-desk"
    password: "9ebc6eac0b4e0e26b8d3b955ec660557"

captive_portal:
api:
  encryption:
    key: !secret encryption_key
ota:

logger:
