Advertisement
Guest User

Untitled

a guest
Nov 8th, 2022
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. esphome:
  2. name: idasen
  3. platform: esp32
  4. board: esp32dev # Replace with your board
  5. # Starting with ESPHome 2021.10, libraries need to be included manually
  6. libraries:
  7. - "ESP32 BLE Arduino"
  8.  
  9. # Enable logging
  10. logger:
  11.  
  12. # Enable Home Assistant API
  13. api:
  14.  
  15. ota:
  16.  
  17. wifi:
  18. ssid: !secret IoT_ssid
  19. password: !secret IoT_password
  20.  
  21. # Enable fallback hotspot (captive portal) in case wifi connection fails
  22. ap:
  23. ssid: "Idasen Fallback Hotspot"
  24. password: aaaaaaaa
  25.  
  26. captive_portal:
  27.  
  28. ## Begin van Ikea-specifieke dingen
  29. external_components:
  30. - source: github://j5lien/esphome-idasen-desk-controller@v4.0.0
  31.  
  32. cover:
  33. - platform: idasen_desk_controller
  34. name: "Desk"
  35.  
  36. idasen_desk_controller:
  37. # Reference to the ble client component id
  38. # -----------
  39. # Required
  40. ble_client_id: idasen_desk
  41. # Fallback to use only up and down commands (less precise)
  42. # -----------
  43. # Optional
  44. only_up_down_command: false
  45.  
  46. esp32_ble_tracker:
  47.  
  48. globals:
  49. # To store the Desk Connection Status
  50. - id: ble_client_connected
  51. type: bool
  52. initial_value: 'false'
  53.  
  54. ble_client:
  55. - mac_address: "DC:AC:28:84:21:E5"
  56. id: idasen_desk
  57. on_connect:
  58. then:
  59. # Update the Desk Connection Status
  60. - lambda: |-
  61. id(ble_client_connected) = true;
  62. - delay: 5s
  63. # Update desk height and speed sensors after bluetooth is connected
  64. - lambda: |-
  65. id(desk_height).update();
  66. id(desk_speed).update();
  67. on_disconnect:
  68. then:
  69. # Update the Desk Connection Status
  70. - lambda: |-
  71. id(ble_client_connected) = false;
  72.  
  73. sensor:
  74. # Desk Height Sensor
  75. - platform: ble_client
  76. type: characteristic
  77. ble_client_id: idasen_desk
  78. id: desk_height
  79. name: 'Desk Height'
  80. service_uuid: '99fa0020-338a-1024-8a49-009c0215f78a'
  81. characteristic_uuid: '99fa0021-338a-1024-8a49-009c0215f78a'
  82. icon: 'mdi:arrow-up-down'
  83. unit_of_measurement: 'cm'
  84. accuracy_decimals: 1
  85. update_interval: never
  86. notify: true
  87. lambda: |-
  88. uint16_t raw_height = ((uint16_t)x[1] << 8) | x[0];
  89. unsigned short height_mm = raw_height / 10;
  90.  
  91. return (float) height_mm / 10;
  92.  
  93. # Desk Speed Sensor
  94. - platform: ble_client
  95. type: characteristic
  96. ble_client_id: idasen_desk
  97. id: desk_speed
  98. name: 'Desk Speed'
  99. service_uuid: '99fa0020-338a-1024-8a49-009c0215f78a'
  100. characteristic_uuid: '99fa0021-338a-1024-8a49-009c0215f78a'
  101. icon: 'mdi:speedometer'
  102. unit_of_measurement: 'cm/min' # I'm not sure this unit is correct
  103. accuracy_decimals: 0
  104. update_interval: never
  105. notify: true
  106. lambda: |-
  107. uint16_t raw_speed = ((uint16_t)x[3] << 8) | x[2];
  108. return raw_speed / 100;
  109.  
  110. binary_sensor:
  111. # Desk Bluetooth Connection Status
  112. - platform: template
  113. name: 'Desk Connection'
  114. id: desk_connection
  115. lambda: 'return id(ble_client_connected);'
  116.  
  117. # Desk Moving Status
  118. - platform: template
  119. name: 'Desk Moving'
  120. id: desk_moving
  121. lambda: 'return id(desk_speed).state > 0;'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement