Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No Issue] My config; more Buttons/Features/ "wakeup" #35

Open
KrX3D opened this issue Sep 21, 2022 · 0 comments
Open

[No Issue] My config; more Buttons/Features/ "wakeup" #35

KrX3D opened this issue Sep 21, 2022 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@KrX3D
Copy link

KrX3D commented Sep 21, 2022

Hello,
i wanted to share my config with you for Esphome:

1
2

Features:

  • Pull Height on boot

  • Set wifi static ip

  • ESP Status

  • ESP restart

  • ESP Home version

  • ESP IP Address

  • ESP SSID

  • On Sit/Stand button get height (after 7.5 seconds, which my table needs to get up/down) set the delay to your need

  • Button Anti Collision for setting up sensitivity (0/1/2/3)

  • Button Child Lock

  • Button 1+2; Does nothing for my E7 so i use it as wakeup which works to get an update of the height (Display goes on)

  • Button M + sitting which shows some letter and numbers at my display. i dont know what it means

  • Button Factory reset to reset the table; for more info see the comment

The only thing i would like to add would be to get the height when manually driving up/down via display. but im not sure how to do that

i also changed line 9 in desk_height_sensor.h
from float value = NULL;
to float value = 0.0;

to solve the warning in ESPHOME when compiling

substitutions:
  device_name: Flexispot E7
  name: flexispot_e7
  min_height: "60.5" # Min height + 0.1
  max_height: "126" # Max height - 0.1

esphome:
  name: ${name}
  comment: ${device_name}
  includes:
    - desk_height_sensor.h
  on_boot:
    priority: -10
    then:
      - switch.turn_on: switch_1_2

esp8266:
  board: d1_mini

logger:
  esp8266_store_log_strings_in_flash: false
  #level: DEBUG
  baud_rate: 0

#Enable Home Assistant API
api:
  encryption:
    key: XXXXXXXXXXXXXXXXXXXXXXX

ota:
  password: XXXXXXXXXXXXXXXXXXXXX

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  reboot_timeout: 60min
  manual_ip:
    static_ip: 192.168.0.24
    gateway: XXXXXX
    subnet: XXXXXXX
  fast_connect: true

  #Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Flexispot-Wemos Fallback Hotspot"
    password: XXXXXXX

captive_portal:
    
uart:
  id: desk_uart
  baud_rate: 9600
  tx_pin: D5
  rx_pin: D6
  
binary_sensor:
  - platform: status
    name: "${device_name} Status"
  
sensor:
  - platform: wifi_signal
    name: "${device_name} WiFi Signal"
    update_interval: 60s
    accuracy_decimals: 0

  - platform: uptime
    name: "${device_name} Uptime"
    unit_of_measurement: minutes
    update_interval: 60s
    accuracy_decimals: 0
    filters:
      - lambda: return x / 60.0;

  - platform: custom
    lambda: |-
      auto desk_height_sensor = new DeskHeightSensor(id(desk_uart));
      App.register_component(desk_height_sensor);
      return {desk_height_sensor};
    sensors:
      id: "desk_height"
      name: "${device_name} Tischhöhe"
      unit_of_measurement: cm
      accuracy_decimals: 1
      icon: "mdi:counter"

switch:
  - platform: gpio
    name: "Virtual Screen"
    pin:
      number: D2
      mode: OUTPUT
    restore_mode: ALWAYS_OFF
    internal: true
    
  - platform: restart
    name: "${device_name} Restart"
    id: reset

  - platform: uart
    name: "${device_name} Preset 1"
    id: switch_preset1
    icon: mdi:numeric-1-box
    data: [0x9b, 0x06, 0x02, 0x04, 0x00, 0xac, 0xa3, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "${device_name} Preset 2"
    id: switch_preset2
    icon: mdi:numeric-2-box
    data: [0x9b, 0x06, 0x02, 0x08, 0x00, 0xac, 0xa6, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "${device_name} Sitzen" # Preset 3 on some control panels
    id: switch_sit
    icon: mdi:chair-rolling
    data: [0x9b, 0x06, 0x02, 0x00, 0x01, 0xac, 0x60, 0x9d]
    uart_id: desk_uart
    on_turn_off:
      - delay: 7500ms
      - switch.turn_on: switch_1_2

  - platform: uart
    name: "${device_name} Stehen" # Not available for all control panels
    id: switch_stand
    icon: mdi:human-handsup
    data: [0x9b, 0x06, 0x02, 0x10, 0x00, 0xac, 0xac, 0x9d]
    uart_id: desk_uart
    on_turn_off:
      - delay: 7500ms
      - switch.turn_on: switch_1_2

  - platform: uart
    name: "${device_name} Hoch"
    id: switch_up
    icon: mdi:arrow-up-bold
    data: [0x9b, 0x06, 0x02, 0x01, 0x00, 0xfc, 0xa0, 0x9d]
    uart_id: desk_uart
    internal: true

  - platform: uart
    name: "${device_name} Runter"
    id: switch_down
    icon: mdi:arrow-down-bold
    data: [0x9b, 0x06, 0x02, 0x02, 0x00, 0x0c, 0xa0, 0x9d]
    uart_id: desk_uart
    internal: true

  - platform: uart
    name: "${device_name} M"
    id: switch_m
    icon: mdi:alpha-m-circle
    data: [0x9b, 0x06, 0x02, 0x20, 0x00, 0xac, 0xb8, 0x9d]
    uart_id: desk_uart

  - platform: uart
    name: "${device_name} (wake up)" # Not available on all control panels
    id: switch_wake_up
    icon: mdi:gesture-tap-button
    data: [0x9b, 0x06, 0x02, 0x00, 0x00, 0x6c, 0xa1, 0x9d]
    uart_id: desk_uart
    
    #https://github.com/Dude88/loctek_IOT_box/blob/main/code_send_by_controllbox
  - platform: uart
    name: "${device_name} Anti Collision"
    id: switch_anti_kollision
    icon: mdi:card-remove
    data: [0x9b, 0x06, 0x02, 0x03, 0x00, 0x9C, 0xa1, 0x9d]
    uart_id: desk_uart
    send_every: 1ms
    on_turn_on:
      - delay: 6000ms
      - switch.turn_off: switch_anti_kollision
    
  - platform: uart
    name: "${device_name} Child Lock"
    id: switch_lock
    icon: mdi:account-lock
    data: [0x9b, 0x06, 0x02, 0x20, 0x00, 0xac, 0xb8, 0x9d]
    uart_id: desk_uart
    send_every: 1ms
    on_turn_on:
      - delay: 5000ms
      - switch.turn_off: switch_lock
    
  - platform: uart
    name: "${device_name} 1 + 2" # Not available for all control panels // Could be used as wake up ?
    id: switch_1_2
    icon: mdi:counter
    data: [0x9b, 0x06, 0x02, 0x0c, 0x01, 0xac, 0x65, 0x9d]
    uart_id: desk_uart
    send_every: 1ms
    on_turn_on:
      - delay: 5000ms
      - switch.turn_off: switch_1_2
    
  - platform: uart
    name: "${device_name} M + sitting" # While holding it shows some numbers / M+sitting
    id: switch_m_sitting
    icon: mdi:script
    data: [0x9b, 0x06, 0x02, 0x20, 0x01, 0x6c, 0x79, 0x9d]
    uart_id: desk_uart
    send_every: 1ms
    on_turn_on:
      - delay: 15500ms
      - switch.turn_off: switch_m_sitting
    
    #RESET TO FACTORY SETTINGS
    #AFTER DISPLAY SHOWS RST, PRESS THE DOWN BUTTON UNTIL THE TABLE REACHES THELOWEST
    #POINT AND REBOUNDS. THAT MEANS RESET IS FINISHED
    #IF DISPLAY SHOED E01 OR E02, RETRY 18 MINUTES LATER
  - platform: uart
    name: "${device_name} Factory Reset" # M+standing 3sec
    id: switch_factory_reset
    icon: mdi:factory
    data: [0x9b, 0x06, 0x02, 0x30, 0x00, 0x6c, 0xb5, 0x9d]
    uart_id: desk_uart
    send_every: 1ms
    on_turn_on:
      - delay: 5000ms
      - switch.turn_off: switch_factory_reset
      
cover:
  - platform: template
    #icon: mdi:table-chair
    #icon: mdi-human-male-height-variant
    name: "${device_name} Tisch"
    assumed_state: true

    #Move desk up
    open_action:
      - while:
          condition:
            sensor.in_range:
              id: desk_height
              below: ${max_height}
          then:
          - logger.log: "Executing up command"
          - switch.turn_on: switch_up
          - delay: 10ms
    
    #Move desk down
    close_action:
      - while:
          condition:
            sensor.in_range:
              id: desk_height
              above: ${min_height} 
          then:
          - logger.log: "Executing down command"
          - switch.turn_on: switch_down
          - delay: 10ms
          
    # Stop Button
    stop_action:
      - logger.log: "Executing stop command"
      - switch.turn_on: switch_up
      - switch.turn_on: switch_down
      
    optimistic: true
    
#Sensors for ESP version and WIFI information
text_sensor:
  - platform: version
    name: "${device_name} ESPHome Version"
    
  - platform: wifi_info
    ip_address:
      name: "${device_name} ip"
    ssid:
      name: "${device_name} ssid"

EDIT:
i changed the code for the cover, so the STOP button will work

thanks to guevara777 for his mushroom card here:
#59

since i needed to make some changes because of the cover i use, this is the card:

image

type: custom:button-card
entity: cover.flexispot_e7_tisch
show_name: false
show_state: false
show_icon: false
styles:
  card:
    - overflow: unset
    - padding: 3px
  grid:
    - grid-template-areas: '"mushroom colors"'
    - grid-template-columns: auto 15rem
custom_fields:
  mushroom:
    card:
      type: custom:mushroom-template-card
      entity: '[[[ return entity.entity_id ]]]'
      tap_action:
        action: more-info
      icon_color: blue
      primary: '{{ state_attr(entity,"friendly_name") }}'
      secondary: >-
        {{ states("sensor.flexispot_e7_tischhohe") }} {{
        state_attr("sensor.flexispot_e7_tischhohe","unit_of_measurement") }}
      icon: '{{ state_attr(entity,"icon") }}'
      card_mod:
        style: |
          ha-card {
            padding: 3px 3px 3px 3px !important; #comment this line out if you want the bigger paddings around the card
            text-align: left !important;
            border: none !important;
            box-shadow: none !important;
          }
  colors:
    card:
      type: grid
      columns: 5
      square: false
      cards:
        - type: custom:button-card
          tap_action:
            action: call-service
            service: cover.close_cover
            service_data:
              entity_id: cover.flexispot_e7_tisch
          size: 70%
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:arrow-down
          styles:
            card:
              - padding: 3px
              - height: 40px
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
        - type: custom:button-card
          tap_action:
            action: call-service
            service: cover.stop_cover
            service_data:
              entity_id: cover.flexispot_e7_tisch
          size: 70%
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:pause
          styles:
            card:
              - padding: 3px
              - height: 40px
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
        - type: custom:button-card
          tap_action:
            action: call-service
            service: cover.open_cover
            service_data:
              entity_id: cover.flexispot_e7_tisch
          size: 70%
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:arrow-up
          styles:
            card:
              - padding: 3px
              - height: 40px
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
        - type: custom:button-card
          tap_action:
            action: call-service
            service: switch.turn_on
            service_data:
              entity_id: switch.flexispot_e7_sitzen
          size: 70%
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:chair-rolling
          styles:
            card:
              - padding: 0px
              - height: 40px
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
        - type: custom:button-card
          tap_action:
            action: call-service
            service: switch.turn_on
            service_data:
              entity_id: switch.flexispot_e7_stehen
          show_state: false
          show_name: false
          show_icon: true
          icon: mdi:human-handsup
          size: 70%
          styles:
            card:
              - padding: 0px
              - height: 100%
              - width: 2.5rem
              - box-shadow: none
              - border: none
              - background: var(--secondary-background-color)
@KrX3D KrX3D mentioned this issue Sep 25, 2022
@iMicknl iMicknl added the documentation Improvements or additions to documentation label Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants