$ show iMicknl/LoctekMotion_IoT
This repository provides ESPHome firmware configurations and custom components to control LoctekMotion/FlexiSpot standing desks via Home Assistant. The core functionality is implemented as two custom ESPHome sensor components: `loctekmotion_desk_height` for reading desk height from a 7-segment display protocol over UART, and `loctekmotion_desk_command` for detecting keypad button presses. The primary entry points are the YAML package files (`packages/office-desk-esp32.yaml` and `packages/office-desk-esp32-passthrough.yaml`) which wire up UART communication, GPIO control for the screen wake pin (PIN20), and expose cover, button, switch, and number entities to Home Assistant. The architecture is a typical ESPHome device: a single microcontroller (ESP32/ESP8266) running the ESPHome firmware, communicating with the desk controller via a 9600 baud UART serial link. The repo also contains archived Arduino and Raspberry Pi implementations, but the active development is focused on the ESPHome components. It is a well-structured IoT integration project with CI/CD, linting, and test compilation for multiple board variants.
The LLM identified 2 files worth highlighting for reuse:
Implements a custom ESPHome sensor component that decodes desk height from a 7-segment display protocol over UART. It parses packets starting with 0x9b, extracts three BCD-encoded digits from message type 0x12, converts them using a bitmask-based digit decoder, and publishes the height in cm. The component is self-contained, inherits from Sensor, Component, and UARTDevice, and demonstrates a clean pattern for integrating non-standard serial protocols into ESPHome. It is reusable as a template for any UART-based sensor with similar packet framing.
Implements a custom ESPHome sensor component that detects keypad button presses from the desk controller's UART stream. It parses packets of type 0x02 and extracts the command payload (up, down, presets, M, alarm) by computing log2 of the payload byte. The component publishes a numeric value (1-8) representing the pressed button. It is a clean, self-contained example of reading and interpreting command packets from a serial device, reusable for any UART-based keypad or command protocol.