My bad!…
I was missing the home assistant’s entity to enable desk movement.
All’s up&running! Big up for the awesome work.
Hey, how did you manage to make it work in the end?
I got to the point where I can send the signals to the desk and make it move up/down, but I’m not getting any data from the desk back (current height, M1-4 heights). Do you happen to have a photo of your setup?
Hey, my problem was with the connections to uart. I had them mixed up.
Hi. I’m about to dive into your solution.
Has there been any progress on the remaining todo list?
I have a hard time to get it running.
I have a nodemcu esp-c3-32s-kit a151, the 5V from the RJ Connector is enough to power it. (Still tried the USB power to make sure)
But I had trouble finding the correct TX and RX pins for the esphome config. Turns out, I could not use the uart0 pins (U0RX U0TX). Instead I had to use others.
Receiving data now works, I get the memory profiles and the current height.
Sending data does not work, except the “Desk test” to trigger re-receiving the data.
But all commands dont do anything. Changed to different pins made no difference.
I also redid the whole connection, first I had a really long cable. Also I can beep it through with my multimeter. So I find it a bit strange that receiving works, but sending (that’s just a plain connection) does not.
Any ideas?
Added: my working wiring (maybe you need 5V and GND from USB - esp32-c3-devkitm-1 got enough power over RJ14, esp32dev (wroom rev1) did not)
From top to bottom:
purple GND
green TX
blue 5V
white RX
I have a RJ14, that works too(same connector, but only 4 pins in use)
My bad!…
I was missing the home assistant’s entity to enable desk movement.
I finally found out what was the problem. This. I didn’t understood what HobbitBen ment. It took me very long to figure it out myself.
Also the documentation is very unclear about this “feature”.
I also expected, that when I manually turn on that switch, it should stay on.
For anyone else that stumbles over this problem:
There is a home assistant entitiy binary_sensor.presence
that is imported into ESPhome, and it only works if that is “on”.
- So either update the ESPhome config to reflect that binary sensor name, if you have any presence detection. (under t
ext_sensor:
) - Or create a dummy
binary_sensor.presence
that is always on. - Or disable the check in the ESPhome config:
switch:
- platform: template
name: "Desk Enable"
...
return true;
} else {
return true; # <--- instead of false
}
...
Can someone maybe post a picture of the final set up.
I have a MAIDeSITe T2 Pro desk which I understand is the same as what @Shades66 has.
My understanding is that to get the control of the desk to HomeAssistant one needs a ESP board connected via RJ12 to the second (free) port to the motor controller (see picture at the bottom) and a usb power cable to provide power to the ESP.
Then deskcontrol.yaml
and desk.h
are used with ESPHome and that should be all.
Am I wrong?
I suspect that this project will work for the Maidesite desks on the RJ12 port.
I’ve tested it and it works well on my Desky Desk.
The RJ12 dongle is also easier to make than the RJ45 dongle.
Probably you can even get a basic solution with yaml only like this:
Yaml only solution
# You probably won't need the stuff under platformio_options: and framework: , I'm just using a weird board.
esphome:
name: "jiecang-desk-controller-rj12-c3"
friendly_name: Desk Controller RJ12 C3
comment: Desk Controller for Jiecang Controllers via RJ12 port
platformio_options:
board_build.flash_mode: dio
on_boot:
priority: 0
then:
- button.press: cmdFetchHeightValue # Request height on boot.
esp32:
board: esp32-c3-devkitm-1
framework:
type: esp-idf
sdkconfig_options:
CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y
CONFIG_BT_BLE_50_FEATURES_SUPPORTED: y
CONFIG_ESP_TASK_WDT_TIMEOUT_S: "10"
variant: ESP32C3 # lolin c3 pico pinout | https://arduino-projekte.info/wp-content/uploads/2023/01/Wemos-Lolin-C3-Pico-Pinout.webp
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.XXX # I like to set static IPs.
gateway: 192.168.1.1
subnet: 255.255.255.0
api:
ota:
logger:
level: VERBOSE # Required for uart debug messages.
uart:
tx_pin: GPIO21
rx_pin: GPIO20
baud_rate: 9600
debug:
direction: BOTH
dummy_receiver: true
after:
delimiter: [0x7E]
# timeout: 5ms
sequence:
# Use mulcmu's method for reading uart without a custome component: https://community.home-assistant.io/t/how-to-uart-read-without-custom-component/491950?u=mahko_mahko
- lambda: |-
UARTDebug::log_int(direction, bytes, ','); // Log the message as int. Good for height message checks.
UARTDebug::log_hex(direction, bytes, ','); // Log the message in hex. Good for checking against protocol documentation.
ESP_LOGD("custom", "Bytes size: %d", bytes.size()); // Logs how many bytes in the message, useful for protocol and message identification.
if (direction == UART_DIRECTION_RX)
{
if (bytes.size() == 9) // Only parse messages with 9 bytes.
{
// Do some validation that it is a height message by checking some bytes.
if (bytes[0] == 0xF2 && bytes[1] == 0xF2 && bytes[2] == 0x01 && bytes[8] == 0x7E)
{
int height = (bytes[4] * 256) + bytes[5];
id(desk_height).publish_state(height);
}
}
}
sensor:
- platform: template
name: "Desk Height"
id: desk_height
update_interval: never
- platform: uptime
icon: mdi:sort-clock-descending
name: Uptime
id: uptime_sensor
update_interval: 5s
accuracy_decimals: 0
unit_of_measurement: s
number:
- platform: template
name: "Go To Height cm"
id: go_to_height_value
optimistic: true
min_value: 80.0
max_value: 250.0
step: 0.1
button:
- platform: uart
id: "cmdStop"
name: "Stop"
data: [0xF1, 0xF1, 0x2B, 0x00, 0x2B, 0x7E]
# Memory Presets
- platform: uart
id: "cmdGotoMemory1"
name: "Go To Memory 1"
data: [0xF1, 0xF1, 0x05, 0x00, 0x05, 0x7E]
- platform: uart
id: "cmdGotoMemory2"
name: "Go To Memory 2"
data: [0xF1, 0xF1, 0x06, 0x00, 0x06, 0x7E]
- platform: uart
id: "cmdGotoMemory3"
name: "Go To Memory 3"
data: [0xF1, 0xF1, 0x27, 0x00, 0x27, 0x7E]
- platform: template
name: "Go to specific height X"
on_press:
then:
- uart.write:
data: !lambda |-
float height_cm = id(go_to_height_value).state;
int height_mm = static_cast<int>(height_cm * 10); // Convert cm to mm
std::vector<uint8_t> bArr(8);
bArr[0] = 0xF1;
bArr[1] = 0xF1;
bArr[2] = 0x1B;
bArr[3] = 0x02;
bArr[4] = static_cast<uint8_t>(height_mm / 256);
bArr[5] = static_cast<uint8_t>(height_mm % 256);
bArr[6] = static_cast<uint8_t>((bArr[2] + bArr[3] + bArr[4] + bArr[5]) % 256); // Calculate checksum
bArr[7] = 0x7E;
return bArr;
- platform: uart
id: "cmdDown"
name: "Nudge Down"
data: [0xF1, 0xF1, 0x02, 0x00, 0x02, 0x7E]
- platform: uart
id: "cmdUp"
name: "Nudge Up"
data: [0xF1, 0xF1, 0x01, 0x00, 0x01, 0x7E]
- platform: uart
id: "cmdMemory1"
name: "Set Memory 1"
data: [0xF1, 0xF1, 0x03, 0x00, 0x03, 0x7E]
- platform: uart
id: "cmdMemory2"
name: "Set Memory 2"
data: [0xF1, 0xF1, 0x04, 0x00, 0x04, 0x7E]
- platform: uart
id: "cmdMemory3"
name: "Set Memory 3"
data: [0xF1, 0xF1, 0x25, 0x00, 0x25, 0x7E]
- platform: uart
id: "cmdFetchHeightValue"
name: "Fetch Height Value"
data: [0xF1, 0xF1, 0x07, 0x00, 0x07, 0x7E]
# If you need anything more than the above you should probably move across to another method / project.
# - platform: uart
# id: "cmdFetchAllTime"
# name: "Fetch All Time"
# data: [0xF1, 0xF1, 0xAA, 0x00, 0xAA, 0x7E]
# - platform: uart
# id: "cmdFetchHeightRange"
# name: "Fetch Height Range"
# data: [0xF1, 0xF1, 0x0C, 0x00, 0x0C, 0x7E]
# - platform: uart
# id: "cmdFetchHeightValue"
# name: "Fetch Height Value"
# data: [0xF1, 0xF1, 0x07, 0x00, 0x07, 0x7E]
# - platform: uart
# id: "cmdFetchHighestLowestLimit"
# name: "Fetch Highest Lowest Limit"
# data: [0xF1, 0xF1, 0x20, 0x00, 0x20, 0x7E]
# - platform: uart
# id: "cmdFetchStandTime"
# name: "Fetch Stand Time"
# data: [0xF1, 0xF1, 0xA6, 0x01, 0xA7, 0x7E]
# - platform: uart
# id: "cmdPatch"
# name: "Patch"
# data: [0xF1, 0xF1, 0xA0, 0x00, 0xA0, 0x7E]
I have tried creating this manual with my Maidesite T2 Pro Plus desk, but I can’t raise or lower it from Home Assistant, although I can read the data.
Has anyone managed to do it with this desk?
Thank you very much for everything.
Hi @tomino,
Great job getting your desk automation to work! I’m also working on automating my Maidesite Desk with an ESP32, but I’m having trouble getting it to communicate properly with the desk.
Could you share more details on how you managed to fix the issue with the desk not sending data back to the ESP32? Did you have to change anything in the wiring, code, or configuration?
Any advice would be greatly appreciated. Thanks for your help!
Hey, I have the same desk, but have the opposite problem.
I can move the desk up and down, but can’t read any of the data.
Maybe we can both help each other out here.
Here’s how I have it connected, but changing the height from Home Assistant works with just connecting to pin 2 and 5 of the RJ12 to GND and TX of the ESP32. (I’m using an ESP32-S3-Zero)
EDIT: I messed up the resistors in the image, the 1K should be 5K and the 5K should be 10K, that’s how I have it at the moment, but it’s not working.
Here’s my yaml: esphome: name: deskcontrol friendly_name: DeskControl includes: - - Pastebin.com
Note that I removed the deskenable switch, as I don’t have a need to disable or enable the desk controls based on presence. I suspect that maybe this is holding you back.
(also, ignore the tx_pin and rx_pin in the yaml, it works the same with leaving it at TX and RX, I was just testing other pins on the ESP)
Could you show me how you have yours wired up, maybe that’ll help me fix my problem too.
Good afternoon!
Thank you so much for your response. Thanks to your guidance, I can now say that I have it configured and working perfectly.
I’m sharing the wiring diagram I used to connect the pins, along with the YAML configuration I implemented. It’s important to note that I used an ESP32 WROOM, which corresponds to an ESP32Dev in ESPHome. Therefore, you’ll need to adjust the board model and pin configuration if you’re using a different ESP device.
If you need any additional information about how I connected it or anything else, feel free to let me know, and I’ll gladly help however I can.
Thank you very much for everything, and best regards!
YAML
esphome:
name: deskcontrol
friendly_name: DeskControl
includes:
- desk.h
on_boot:
priority: 800
then:
- uart.write: [0xf1, 0xf1, 0x07,0x00,0x07,0x7e,0xf1, 0xf1, 0x08,0x00,0x08,0x7e,0xf1, 0xf1, 0x09,0x00,0x09,0x7e,0xf1, 0xf1, 0x0c,0x00,0x0c,0x7e,0xf1, 0xf1, 0x0e,0x00,0x0e,0x7e]
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
platform: esphome
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Deskcontrol Fallback Hotspot"
password: !secret ap_password2
captive_portal:
uart:
- id: desk_uart
tx_pin: 17
rx_pin: 16
baud_rate: 9600
debug:
direction: BOTH
after:
bytes: 9
sequence:
- lambda: UARTDebug::log_int(direction, bytes, ',');
custom_component:
- lambda: |-
auto my_custom = new MyCustomComponent(id(desk_uart));
return {my_custom};
sensor:
- platform: template
name: "Desk M1 Height"
id: "deskm1"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
- platform: template
name: "Desk M2 Height"
id: "deskm2"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
- platform: template
name: "Desk M3 Height"
id: "deskm3"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
- platform: template
name: "Desk M4 Height"
id: "deskm4"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
text_sensor:
- platform: homeassistant
id: movement_status
entity_id: binary_sensor.presence
switch:
- platform: template
name: "Desk Enable"
id: deskenable
lambda: |-
if (id(movement_status).state == "on") {
return true;
} else {
return true;
}
turn_on_action:
- logger.log: Desk Enabled
on_turn_on:
- logger.log: Desk Enabled
on_turn_off:
- logger.log: Desk Disabled
- delay: 100s
- if:
condition:
text_sensor.state:
id: movement_status
state: "off"
then:
- logger.log: Reset Desk to lowest setting.
- uart.write: [0xf1, 0xf1, 0x05,0x00,0x05,0x7e]
button:
- platform: template
name: Desk UP
id: my_deskup
on_press:
if:
condition:
# Same syntax for is_off
switch.is_on: deskenable
then:
- logger.log: UP Pressed
- uart.write: [0xf1, 0xf1, 0x01,0x00,0x01,0x7e]
- platform: template
name: Desk Down
id: my_deskdown
on_press:
if:
condition:
# Same syntax for is_off
switch.is_on: deskenable
then:
- logger.log: DOWN Pressed
- uart.write: [0xf1, 0xf1, 0x02,0x00,0x02,0x7e]
- platform: template
name: Desk Sit
id: my_desksit
on_press:
if:
condition:
# Same syntax for is_off
switch.is_on: deskenable
then:
- logger.log: SIT Pressed
- uart.write: [0xf1, 0xf1, 0x05,0x00,0x05,0x7e]
- platform: template
name: Desk Stand
id: my_deskstamd
on_press:
if:
condition:
# Same syntax for is_off
switch.is_on: deskenable
then:
- logger.log: STAND Pressed
- uart.write: [0xf1, 0xf1, 0x06,0x00,0x06,0x7e]
- platform: template
name: Desk FULLUP
id: my_deskfullup
on_press:
if:
condition:
# Same syntax for is_off
switch.is_on: deskenable
then:
- logger.log: FULLUP Pressed
- uart.write: [0xf1, 0xf1, 0x28,0x00,0x28,0x7e]
- platform: template
name: Desk test
id: my_desktest
on_press:
then:
- logger.log: TEST Pressed
- uart.write: [0xf1, 0xf1, 0x07,0x00,0x07,0x7e,0xf1, 0xf1, 0x08,0x00,0x08,0x7e,0xf1, 0xf1, 0x09,0x00,0x09,0x7e,0xf1, 0xf1, 0x0c,0x00,0x0c,0x7e,0xf1, 0xf1, 0x0e,0x00,0x0e,0x7e]
number:
- platform: template
name: "Desk Height Control"
id: "deskSlider"
step: 1
min_value: 677
max_value: 1241
mode: slider
set_action:
if:
condition:
# Same syntax for is_off
switch.is_on: deskenable
then:
- uart.write: !lambda |-
int a= (int(x) & 0xff);
int b= ((int(x) >> 8) & 0xff);
int c= (a+b+0x80+0x02) & 0xff;
return {0xf1, 0xf1, 0x80, 2, b,a,c,0x7e,0xf1, 0xf1, 0x1b, 0x00, 0x1b,0x7e};
Hey, thanks for the update!
I changed my setup according to your image, now everything works!
After some experimentation, I simplified the whole thing a bit. I tested it both with and without the resistors, and it seems to be just fine without them, this is what it looks like now:
RJ12 | COLOR | ESP32 PIN |
---|---|---|
PIN 1 | white | |
PIN 2 | brown | GND |
PIN 3 | green | RX (GPIO3) |
PIN 4 | yellow | 5V |
PIN 5 | purple | TX (GPIO1) |
PIN 6 | red |
(using the numbering like in our previous pictures, colours might be different depending on your cable used)
Turns out the RJ12 port supplies enough power for the ESP32-S3-Zero that I’m using, making the whole thing even cleaner.
Here’s a photo after soldering:
And here’s the yaml once again, configured for my model of ESP32, without the deskenable and presence features.
deskcontrol.yaml
esphome:
name: deskcontrol
friendly_name: DeskControl
includes:
- desk.h
on_boot:
priority: 800
then:
- uart.write: [0xf1, 0xf1, 0x07,0x00,0x07,0x7e,0xf1, 0xf1, 0x08,0x00,0x08,0x7e,0xf1, 0xf1, 0x09,0x00,0x09,0x7e,0xf1, 0xf1, 0x0c,0x00,0x0c,0x7e,0xf1, 0xf1, 0x0e,0x00,0x0e,0x7e]
esp32:
board: esp32-s3-devkitc-1
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
platform: esphome
password: !secret ota_pass
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pass
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Deskcontrol Fallback Hotspot"
password: "fopfxEuvlxy3"
captive_portal:
uart:
- id: desk_uart
tx_pin: TX
rx_pin: RX
baud_rate: 9600
debug:
direction: BOTH
after:
bytes: 9
sequence:
- lambda: UARTDebug::log_int(direction, bytes, ',');
custom_component:
- lambda: |-
auto my_custom = new MyCustomComponent(id(desk_uart));
return {my_custom};
sensor:
- platform: template
name: "Desk M1 Height"
id: "deskm1"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
- platform: template
name: "Desk M2 Height"
id: "deskm2"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
- platform: template
name: "Desk M3 Height"
id: "deskm3"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
- platform: template
name: "Desk M4 Height"
id: "deskm4"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
button:
- platform: template
name: Desk UP
id: my_deskup
on_press:
- logger.log: UP Pressed
- uart.write: [0xf1, 0xf1, 0x01,0x00,0x01,0x7e]
- platform: template
name: Desk DOWN
id: my_deskdown
on_press:
- logger.log: DOWN Pressed
- uart.write: [0xf1, 0xf1, 0x02,0x00,0x02,0x7e]
- platform: template
name: Desk SIT
id: my_desksit
on_press:
- logger.log: SIT Pressed
- uart.write: [0xf1, 0xf1, 0x05,0x00,0x05,0x7e]
- platform: template
name: Desk STAND
id: my_deskstand
on_press:
- logger.log: STAND Pressed
- uart.write: [0xf1, 0xf1, 0x06,0x00,0x06,0x7e]
- platform: template
name: Desk FULLUP
id: my_deskfullup
on_press:
- logger.log: FULLUP Pressed
- uart.write: [0xf1, 0xf1, 0x28,0x00,0x28,0x7e]
- platform: template
name: Desk test
id: my_desktest
on_press:
- logger.log: TEST Pressed
- uart.write: [0xf1, 0xf1, 0x07,0x00,0x07,0x7e,0xf1, 0xf1, 0x08,0x00,0x08,0x7e,0xf1, 0xf1, 0x09,0x00,0x09,0x7e,0xf1, 0xf1, 0x0c,0x00,0x0c,0x7e,0xf1, 0xf1, 0x0e,0x00,0x0e,0x7e]
number:
- platform: template
name: "Desk Height Control"
id: "deskSlider"
step: 1
min_value: 677
max_value: 1241
mode: slider
set_action:
- uart.write: !lambda |-
int a= (int(x) & 0xff);
int b= ((int(x) >> 8) & 0xff);
int c= (a+b+0x80+0x02) & 0xff;
return {0xf1, 0xf1, 0x80, 2, b,a,c,0x7e,0xf1, 0xf1, 0x1b, 0x00, 0x1b,0x7e};
Hope this can help others with a Maidesite T2 Pro Plus, too.
Has anyone else got this working with a Maidesite S1 Pro desk? I’ve tried it, but all I’m able to do is produce an undocumented error code on the desk’s control panel.
Thanks @lukas-berger i did the same as you and works perfectly.
My Desk is a Maidesite TH2 Plus Art
This is what I did in case it helps anyone.
Used the same files unchanged as Lukas above, other than changing the name of the device.
Some of my pins were a different colour
RJ12 | COLOR | ESP32 PIN |
---|---|---|
PIN 1 | white | |
PIN 2 | Brown | GND |
PIN 3 | Red | RX GPIO3 |
PIN 4 | Green | 5V |
PIN5 | Yellow | TX GPIO1 |
PIN6 | Blue |
One thing I got stumped on was where to upload the desk.h file, turns out it’s to home assistant’s /config/esphome folder after you’ve setup the esp32. Then overwrite the yaml file with the contents from deskcontrol.yaml
Bought these:
RJ12 cable
ESP32-S3 Zero/Mini
The RJ12 on the desk powers it, no need to use the USB-C.
Following on from my post yesterday I’ve actually changed the GPIO3 pin to be GPIO4 because 3 was throwing up a warning in the logs and I don’t like warnings.
So in my pic the red wire has moved down one pin.
Just needed to update the RX line in the yaml file to be:
rx_pin: GPIO4
I also added the missing M3 button and renamed the buttons to match closer the memory preset sensors so Desk M1 etc
Updated yaml:
esphome:
name: office-desk-controller
friendly_name: Office Desk Controller
includes:
- include/desk.h
on_boot:
priority: 800
then:
- uart.write: [0xf1, 0xf1, 0x07,0x00,0x07,0x7e,0xf1, 0xf1, 0x08,0x00,0x08,0x7e,0xf1, 0xf1, 0x09,0x00,0x09,0x7e,0xf1, 0xf1, 0x0c,0x00,0x0c,0x7e,0xf1, 0xf1, 0x0e,0x00,0x0e,0x7e]
esp32:
board: esp32-s3-devkitc-1
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "your key here"
ota:
- platform: esphome
password: "your password here"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Office-Desk-Controller"
password: "zNu29TwKlkI7"
captive_portal:
uart:
- id: desk_uart
tx_pin: TX
rx_pin: GPIO4
baud_rate: 9600
debug:
direction: BOTH
after:
bytes: 9
sequence:
- lambda: UARTDebug::log_int(direction, bytes, ',');
custom_component:
- lambda: |-
auto my_custom = new MyCustomComponent(id(desk_uart));
return {my_custom};
sensor:
- platform: template
name: "Desk M1 Height"
id: "deskm1"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
- platform: template
name: "Desk M2 Height"
id: "deskm2"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
- platform: template
name: "Desk M3 Height"
id: "deskm3"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
- platform: template
name: "Desk M4 Height"
id: "deskm4"
filters:
- lambda: !lambda |-
if (x <1 ) return {};
return x/10;
button:
- platform: template
name: Desk UP
id: my_deskup
on_press:
- logger.log: UP Pressed
- uart.write: [0xf1, 0xf1, 0x01,0x00,0x01,0x7e]
- platform: template
name: Desk DOWN
id: my_deskdown
on_press:
- logger.log: DOWN Pressed
- uart.write: [0xf1, 0xf1, 0x02,0x00,0x02,0x7e]
- platform: template
name: Desk M1
id: my_desk_m1
on_press:
- logger.log: M1 Pressed
- uart.write: [0xf1, 0xf1, 0x05,0x00,0x05,0x7e]
- platform: template
name: Desk M2
id: my_desk_m2
on_press:
- logger.log: M2 Pressed
- uart.write: [0xf1, 0xf1, 0x06,0x00,0x06,0x7e]
- platform: template
name: Desk M3
id: my_desk_m3
on_press:
- logger.log: M3 Pressed
- uart.write: [0xF1, 0xF1, 0x27, 0x00, 0x27, 0x7E]
- platform: template
name: Desk M4
id: my_desk_m4
on_press:
- logger.log: M4 Pressed
- uart.write: [0xf1, 0xf1, 0x28,0x00,0x28,0x7e]
- platform: template
name: Desk Test
id: my_desktest
on_press:
- logger.log: TEST Pressed
- uart.write: [0xf1, 0xf1, 0x07,0x00,0x07,0x7e,0xf1, 0xf1, 0x08,0x00,0x08,0x7e,0xf1, 0xf1, 0x09,0x00,0x09,0x7e,0xf1, 0xf1, 0x0c,0x00,0x0c,0x7e,0xf1, 0xf1, 0x0e,0x00,0x0e,0x7e]
number:
- platform: template
name: "Desk Height Control"
id: "deskSlider"
step: 1
min_value: 677
max_value: 1241
mode: slider
set_action:
- uart.write: !lambda |-
int a= (int(x) & 0xff);
int b= ((int(x) >> 8) & 0xff);
int c= (a+b+0x80+0x02) & 0xff;
return {0xf1, 0xf1, 0x80, 2, b,a,c,0x7e,0xf1, 0xf1, 0x1b, 0x00, 0x1b,0x7e};
Hi Lukas,
this looks really promising and I am already impressed and motivated to also make my “MAIDeSITe T2 Pro Plus” being smart.
I just try to flash my ESP32 S3 Zero and running in a compiling error while downloading the install-file within the ESPHome Builder (renamed script to Schreibtisch-Control) (used your code for my yaml and just adopted wifi credentials but have not updated HA OS to 14.2 or HA Core to 2025.1.2):
INFO ESPHome 2024.12.4
INFO Reading configuration /config/esphome/schreibtisch-control.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing schreibtisch-control (board: esp32dev; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
- toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.1.4
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.2.2
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.6
Compiling .pioenvs/schreibtisch-control/src/main.cpp.o
Compiling .pioenvs/schreibtisch-control/libc58/ESPAsyncWebServer-esphome/WebHandlers.cpp.o
Compiling .pioenvs/schreibtisch-control/libc58/ESPAsyncWebServer-esphome/WebRequest.cpp.o
Compiling .pioenvs/schreibtisch-control/libc58/ESPAsyncWebServer-esphome/WebResponses.cpp.o
/config/esphome/schreibtisch-control.yaml: In lambda function:
/config/esphome/schreibtisch-control.yaml:47:28: error: expected type-specifier before 'MyCustomComponent'
auto my_custom = new MyCustomComponent(id(desk_uart));
^~~~~~~~~~~~~~~~~
/config/esphome/schreibtisch-control.yaml:48:24: error: could not convert '{my_custom}' from '<brace-enclosed initializer list>' to 'std::vector<esphome::Component*>'
return {my_custom};
^
/config/esphome/schreibtisch-control.yaml: In lambda function:
/config/esphome/schreibtisch-control.yaml:131:80: warning: narrowing conversion of 'b' from 'int' to 'unsigned char' inside { } [-Wnarrowing]
return {0xf1, 0xf1, 0x80, 2, b,a,c,0x7e,0xf1, 0xf1, 0x1b, 0x00, 0x1b,0x7e};
^
/config/esphome/schreibtisch-control.yaml:131:80: warning: narrowing conversion of 'b' from 'int' to 'unsigned char' inside { } [-Wnarrowing]
/config/esphome/schreibtisch-control.yaml:131:80: warning: narrowing conversion of 'a' from 'int' to 'unsigned char' inside { } [-Wnarrowing]
/config/esphome/schreibtisch-control.yaml:131:80: warning: narrowing conversion of 'a' from 'int' to 'unsigned char' inside { } [-Wnarrowing]
/config/esphome/schreibtisch-control.yaml:131:80: warning: narrowing conversion of 'c' from 'int' to 'unsigned char' inside { } [-Wnarrowing]
/config/esphome/schreibtisch-control.yaml:131:80: warning: narrowing conversion of 'c' from 'int' to 'unsigned char' inside { } [-Wnarrowing]
*** [.pioenvs/schreibtisch-control/src/main.cpp.o] Error 1
========================== [FAILED] Took 6.00 seconds ==========================
Any ideas? Thank you for your efforts.
I figured out what was wrong. I had a typo in the desk.h (I guess due to auto translation).
With a fresh copy of desk.h everything went smooth.
Thank you for this helpful explanation and discussion for building a small device to make the MaidSaite T2 Pro Plus Desk smart and visible/usable in Home Assistant.
Maybe this helps others also willing to automate their Desk:
Used items:
- MaideSite T2 Pro Plus Desk (store at your convenience)
- RJ12:
- ESP32 S3 Zero
- Jumper wires
- A small box from a local warehouse (as I don’t have 3D printer at hand):
Spelsberg Q 4-L Junctionbox (40 mm x 56mm x 23 mm; grey) (<2€) - Soldering iron and solder tin, shrinking tubes (look for random offers online or in warehouses)
Needed steps for programming (~15min):
- Connect ESP32-device to PC and flash with ESPHome Builder with Home Assistant (3min)
- Flash ESP32 with provided yaml (see above; adjust to your convenenience) (~5min)
- Copy or write a new file “desk.h” to ~/esphome/include/ (i used this file from GitHub; 2min)
Needed steps for wiring (~30min):
- Cut jumper wires and RJ12 cable (1min)
- Separate all cable ends to be able to work on the individual ends (2min)
- Strip the isolations and twist all cables (8min)
- Put small shrinking tubes over the single wires and a bigger one over the wiring harness (7min)
- Twist the 6 cable-pairs (2 min)
- Solder the twisted ends for a proper cable connection (3min)
- Note the cable color-combination of the 6 connected wires if not identical on the used cables (1min)
- Slide the shrinking tubes over the soldered cable pairs and slide the big tube over all cables (2min)
- Shrink the tubes with hot airstream (I used a hairdryer not melt the tiny isolation - worked pretty good; 2min)
- Wire the ESP32 (see above) and put all into the box and connect to the desk (2min)
I’ve got everything working on my desk. If you are well prepared and having all you need at hand you should be able to make the desk tunable via Home Assistant within approx. 45-60min.
All used items cost below 15 Euros (if counting package prices you’ll might spending a bit more).
Considering improvements: Advancing this tool (maybe somebody has an idea):
- Fetching the current height in a separate entity. I am not sure, if this could be achived conveniently. My idea is, having an own entity/sensor showing the current height which gets updated every time the desk height had been changed.
→ EDIT: solved, see pictures below.
- Also the height unit could be switched: cm/ft, … but this could also be recalculated with helpers in Home Assistant and might to be part of the ESP itself.
see Pictures below
01: Complete device
2: Wired ESP32 (detail)
3: Closed Box (detail)
4: Finally: connected box @ MaideSite T2 Pro Plus (this is what this is about )
I will rewire the box beyond the support and the table top to not cover the box with the metal guard covering the technic to avoid impacting signal strength. Therefore: consider cable length!
5: HA Device Details
→ EDIT:
Added “Desk Current Height” and icons:
Desk Current Height:
### Desk Current Height ###
# add to sensors-section: #
- platform: template
name: "Desk Current Height"
id: "desk_current_height"
icon: "mdi:format-vertical-align-center"
lambda: |-
float desk_current_height = id(deskSlider).state / 10.0;
return desk_current_height;
### /Desk Current Height ###
used following icons:
### ICONS (enter below respective "id:"-entry/see 'Desk Current Height' example)
* icon: "mdi:arrow-expand-vertical" ##(M 1-4)
* icon: "mdi:arrow-expand-up" ##(Desk UP)
* icon: "mdi:arrow-expand-down" ##(Desk DOWN)
* icon: "mdi:reload" ##(Desk Test)
* icon: "mdi:format-vertical-align-center" ##(Current Height)