Open guevara777 opened 2 years ago
Hi @guevara777 , in the image you connect GPIO 18 and 19, but in the code you define the tx and rx for 16 and 17. Is that just a typo? I'm using the exact same devices but I can't get this setup to work...
The Image is wrong. In the code it´s right. I use the GPIO-Pins 16 and 17 like this:
uart:
id: desk_uart
baud_rate: 9600
tx_pin: GPIO17
rx_pin: GPIO16
Here is the correct wirering:
I also added a position-action since i posted it here. You can populate the cover to Alexa and use voice commands like "set the desk to 70%".
for this you have to add this to the yaml-file:
# Move desk to desired position
position_action:
#Check if we need to move desk up or down from current position
if:
condition:
#Current height is more than target height, then move desk down
lambda: |-
float position = (float(id(desk_height).state) - float(${min_height})) / (float(${max_height}) - float(${min_height}));
return pos < position;
then:
- logger.log: "Schreibtisch muss runter gefahren werden"
- while:
condition:
# Move down till the current height is smaller then the target height
lambda: |-
float position = (float(id(desk_height).state) - float(${min_height})) / (float(${max_height}) - float(${min_height}));
return pos < position;
then:
- logger.log: "Executing down command"
- cover.template.publish:
id: desk_cover
current_operation: CLOSING
- uart.write:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
- delay: 108ms
else:
- logger.log: "Schreibtisch muss hoch gefahren werden"
- while:
condition:
# Move up till the current height is bigger then the target height
lambda: |-
float position = (float(id(desk_height).state) - float(${min_height})) / (float(${max_height}) - float(${min_height}));
return pos > position;
then:
- logger.log: "Executing up command"
- cover.template.publish:
id: desk_cover
current_operation: OPENING
- uart.write:
id: desk_uart
data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
- delay: 108ms
Hi guys. If I add the second part (Move desk to desired position) i get a double definition error from position_action.
I‘m a noob in coding and do need help there. Can anyone help me?
Thank you to @iMicknl for helping me out with this! I´d like to share my working setup with others :)
Hardware
Disclaimer: I power my ESP32 with USB. I did not test to power it via V5-Pin. Please check the Documentation of your Board!
Wiring![image](https://user-images.githubusercontent.com/29648553/185910714-2b07601b-437f-413b-8f4a-a5a99c395c71.png)
ESPHome
_Don`t forget to put this file -> https://github.com/iMicknl/LoctekMotion_IoT/blob/main/packages/esphome/desk_height_sensor.h in the same folder as your .yaml-file for esphome!_
Please add the following code at the botton of the yaml-file if you want to have a position control in Home Assistant. The Position-range is from 0% to 100% and you can use it with alexa like "set desk to 70%" if you populate the cover-entity to alexa (i did it with Nabu-Casa).
Picture of my setup![image](https://user-images.githubusercontent.com/29648553/159672687-3bc9d15a-cb98-435c-868f-7896630fe56b.png)
Voice-Control with Alexa You can control your desk via Alexa now. To do so, expose the button.sit and button.stand to alexa (i use Naba Casa for this). In the Alexa App i createt 2 routines that trigger the "Sit" and "Stand"-Scenes with a Voice command like "Alexa, im stehen arbeiten" (Alexa, work standing).