bt.yaml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. # 1. SUBSTITUTIONS (Names to be used in sensor IDs)
  2. substitutions:
  3. name: "slzb-06-bluetooth"
  4. # 2. GENERAL ESPHOME CONFIGURATION SETTINGS
  5. ## Project information
  6. esphome:
  7. name: "${name}"
  8. name_add_mac_suffix: true
  9. project:
  10. name: SMLIGHT.SLZB-06(Bluetooth-only)
  11. version: "1.31"
  12. ## Board information
  13. esp32:
  14. board: esp32dev
  15. flash_size: 16MB
  16. framework:
  17. type: arduino
  18. ## Connection to Home Assistant through API is enabled
  19. api:
  20. ## Logger is enabled
  21. #logger:
  22. ## OTA firmware updates are available
  23. ota:
  24. - platform: esphome
  25. ## Accessible portal with control buttons is available
  26. #web_server:
  27. # port: 80
  28. # local: True
  29. ## WiFi settings
  30. #wifi:
  31. # ssid: !secret wifi_ssid
  32. # password: !secret wifi_password
  33. #
  34. # # Enable fallback hotspot (captive portal) in case wifi connection fails
  35. # ap:
  36. # ssid: "slzb-06 Hotspot"
  37. # password: "slzb06"
  38. ## Enabling captive portal
  39. # captive_portal:
  40. # 3. EXTERNAL COMPONENTS USED
  41. dashboard_import:
  42. package_import_url: github://smlight-dev/slzb-06-fw-esphome/configs/bt.yaml
  43. # 4. COMMUNICATION SETTINGS
  44. ## Ethernet Connection
  45. ethernet:
  46. type: LAN8720
  47. mdc_pin: GPIO23
  48. mdio_pin: GPIO18
  49. clk:
  50. pin:
  51. number: GPIO0
  52. ignore_strapping_warning: true
  53. mode: CLK_EXT_IN
  54. phy_addr: 1
  55. power_pin: GPIO16
  56. ## MDNS service settings
  57. mdns:
  58. services:
  59. - service: "_slzb-06-bluetooth"
  60. protocol: "_tcp"
  61. port: 6638
  62. txt:
  63. version: 1.0
  64. name: SMLIGHT SLZB-06
  65. radio_type: znp
  66. baud_rate: 115200
  67. data_flow_control: software
  68. # 5. BLLUETOOTH PROXY COMPONENTS
  69. esp32_ble_tracker:
  70. scan_parameters:
  71. interval: 1100ms
  72. window: 1100ms
  73. active: true
  74. bluetooth_proxy:
  75. active: true
  76. #button:
  77. #- platform: safe_mode
  78. # name: Safe Mode Boot
  79. # entity_category: diagnostic
  80. # 6. SENSORS
  81. ## Upteime information as sensor
  82. text_sensor:
  83. - platform: template
  84. name: "SLZB-06 Uptime"
  85. lambda: |-
  86. uint32_t dur = id(uptime_s).state;
  87. int dys = 0;
  88. int hrs = 0;
  89. int mnts = 0;
  90. if (dur > 86399) {
  91. dys = trunc(dur / 86400);
  92. dur = dur - (dys * 86400);
  93. }
  94. if (dur > 3599) {
  95. hrs = trunc(dur / 3600);
  96. dur = dur - (hrs * 3600);
  97. }
  98. if (dur > 59) {
  99. mnts = trunc(dur / 60);
  100. dur = dur - (mnts * 60);
  101. }
  102. char buffer[17];
  103. sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
  104. return {buffer};
  105. icon: mdi:clock-start
  106. update_interval: 60s
  107. ## Uptime generic sensor
  108. sensor:
  109. - platform: uptime
  110. id: uptime_s
  111. update_interval: 60s
  112. # 7. SWITCHES
  113. ## ESP32 Restart
  114. switch:
  115. - platform: restart
  116. id: coreRestart
  117. name: "Core restart"
  118. ## Mode LAN/USB switch
  119. - platform: gpio
  120. name: "DEVICE MODE SWITCH (LAN|OFF - USB|ON)"
  121. restore_mode: ALWAYS_OFF
  122. icon: mdi:toggle-switch
  123. internal: true
  124. id: gpio4Select
  125. pin:
  126. number: GPIO4
  127. ### LEDs swithces
  128. - platform: gpio
  129. name: "LED - device mode (Blue)"
  130. restore_mode: ALWAYS_OFF
  131. internal: true
  132. icon: mdi:toggle-switch
  133. id: gpio12LED1
  134. pin:
  135. number: GPIO12
  136. ignore_strapping_warning: true
  137. - platform: gpio
  138. name: "LED - power (Yellow)"
  139. restore_mode: ALWAYS_ON
  140. icon: mdi:toggle-switch
  141. id: gpio14LED2
  142. pin:
  143. number: GPIO14