Guest User

Untitled

a guest
Dec 28th, 2024
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. esphome:
  2. name: deskcontrol
  3. friendly_name: DeskControl
  4. includes:
  5. - desk.h
  6. on_boot:
  7. priority: 800
  8. then:
  9. - 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]
  10.  
  11. esp32:
  12. board: esp32-s3-devkitc-1
  13. framework:
  14. type: arduino
  15.  
  16. # Enable logging
  17. logger:
  18.  
  19. # Enable Home Assistant API
  20. api:
  21.  
  22. ota:
  23. platform: esphome
  24. password: !secret ota_pass
  25.  
  26. wifi:
  27. ssid: !secret wifi_ssid
  28. password: !secret wifi_pass
  29.  
  30. # Enable fallback hotspot (captive portal) in case wifi connection fails
  31. ap:
  32. ssid: "Deskcontrol Fallback Hotspot"
  33. password: "FALLBACK_PASSWORD"
  34.  
  35. captive_portal:
  36.  
  37.  
  38. uart:
  39. - id: desk_uart
  40. tx_pin: 11
  41. rx_pin: 10
  42. baud_rate: 9600
  43. debug:
  44. direction: BOTH
  45. after:
  46. bytes: 9
  47. sequence:
  48. - lambda: UARTDebug::log_int(direction, bytes, ',');
  49.  
  50. custom_component:
  51. - lambda: |-
  52. auto my_custom = new MyCustomComponent(id(desk_uart));
  53. return {my_custom};
  54.  
  55.  
  56. sensor:
  57. - platform: template
  58. name: "Desk M1 Height"
  59. id: "deskm1"
  60. filters:
  61. - lambda: !lambda |-
  62. if (x <1 ) return {};
  63. return x/10;
  64. - platform: template
  65. name: "Desk M2 Height"
  66. id: "deskm2"
  67. filters:
  68. - lambda: !lambda |-
  69. if (x <1 ) return {};
  70. return x/10;
  71. - platform: template
  72. name: "Desk M3 Height"
  73. id: "deskm3"
  74. filters:
  75. - lambda: !lambda |-
  76. if (x <1 ) return {};
  77. return x/10;
  78. - platform: template
  79. name: "Desk M4 Height"
  80. id: "deskm4"
  81. filters:
  82. - lambda: !lambda |-
  83. if (x <1 ) return {};
  84. return x/10;
  85.  
  86.  
  87.  
  88. button:
  89. - platform: template
  90. name: Desk UP
  91. id: my_deskup
  92. on_press:
  93. - logger.log: UP Pressed
  94. - uart.write: [0xf1, 0xf1, 0x01,0x00,0x01,0x7e]
  95. - platform: template
  96. name: Desk DOWN
  97. id: my_deskdown
  98. on_press:
  99. - logger.log: DOWN Pressed
  100. - uart.write: [0xf1, 0xf1, 0x02,0x00,0x02,0x7e]
  101. - platform: template
  102. name: Desk Sit
  103. id: my_desksit
  104. on_press:
  105. - logger.log: SIT Pressed
  106. - uart.write: [0xf1, 0xf1, 0x05,0x00,0x05,0x7e]
  107. - platform: template
  108. name: Desk Stand
  109. id: my_deskstand
  110. on_press:
  111. - logger.log: STAND Pressed
  112. - uart.write: [0xf1, 0xf1, 0x06,0x00,0x06,0x7e]
  113. - platform: template
  114. name: Desk FULLUP
  115. id: my_deskfullup
  116. on_press:
  117. - logger.log: FULLUP Pressed
  118. - uart.write: [0xf1, 0xf1, 0x28,0x00,0x28,0x7e]
  119. - platform: template
  120. name: Desk TEST
  121. id: my_desktest
  122. on_press:
  123. - logger.log: TEST Pressed
  124. - 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]
  125.  
  126.  
  127. number:
  128. - platform: template
  129. name: "Desk Height Control"
  130. id: "deskSlider"
  131. step: 1
  132. min_value: 677
  133. max_value: 1241
  134. mode: slider
  135. set_action:
  136. - uart.write: !lambda |-
  137. int a= (int(x) & 0xff);
  138. int b= ((int(x) >> 8) & 0xff);
  139. int c= (a+b+0x80+0x02) & 0xff;
  140. return {0xf1, 0xf1, 0x80, 2, b,a,c,0x7e,0xf1, 0xf1, 0x1b, 0x00, 0x1b,0x7e};
Advertisement
Add Comment
Please, Sign In to add comment