Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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: "FALLBACK_PASSWORD"
- captive_portal:
- uart:
- - id: desk_uart
- tx_pin: 11
- rx_pin: 10
- 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};
Advertisement
Add Comment
Please, Sign In to add comment