zb-bt.yaml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. # 1. SUBSTITUTIONS (Names to be used in sensor IDs)
  2. substitutions:
  3. name: "slzb-06-zigbee_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*(Zigbee+Bluetooth)
  11. version: "1.51"
  12. on_boot:
  13. priority: 600
  14. then:
  15. - switch.turn_on: zRST_gpio
  16. - delay: 15ms
  17. - switch.turn_off: zRST_gpio
  18. ## Board information
  19. esp32:
  20. board: esp32dev
  21. flash_size: 16MB
  22. framework:
  23. type: arduino
  24. ## Connection to Home Assistant through API is enabled
  25. api:
  26. ## Logger is enabled
  27. #logger:
  28. ## OTA firmware updates are available
  29. ota:
  30. - platform: esphome
  31. ## Accessible portal with control buttons is available
  32. #web_server:
  33. # port: 80
  34. # local: True
  35. ## WiFi settings
  36. #wifi:
  37. # ssid: !secret wifi_ssid
  38. # password: !secret wifi_password
  39. #
  40. # # Enable fallback hotspot (captive portal) in case wifi connection fails
  41. # ap:
  42. # ssid: "slzb-06 Hotspot"
  43. # password: "slzb06"
  44. ## Enabling captive portal
  45. # captive_portal:
  46. # 3. EXTERNAL COMPONENTS USED
  47. dashboard_import:
  48. package_import_url: github://smlight-dev/slzb-06-fw-esphome/configs/zb-bt.yaml
  49. # 4. COMMUNICATION SETTINGS
  50. ## Ethernet Connection
  51. ethernet:
  52. type: LAN8720
  53. mdc_pin: GPIO23
  54. mdio_pin: GPIO18
  55. clk:
  56. pin:
  57. number: GPIO0
  58. ignore_strapping_warning: true
  59. mode: CLK_EXT_IN
  60. phy_addr: 1
  61. power_pin: GPIO16
  62. ## UART Settings
  63. uart:
  64. id: uart_bus
  65. rx_pin:
  66. number: GPIO5
  67. ignore_strapping_warning: true
  68. tx_pin: GPIO17
  69. baud_rate: 115200
  70. ## Stream Server
  71. uart_tcp:
  72. - id: streamServer
  73. uart_id: uart_bus
  74. role: server
  75. port: 6638
  76. ## MDNS service settings
  77. mdns:
  78. services:
  79. - service: "_slzb-06"
  80. protocol: "_tcp"
  81. port: 6638
  82. txt:
  83. version: 1.0
  84. name: SMLIGHT SLZB-06
  85. radio_type: znp
  86. baud_rate: 115200
  87. data_flow_control: software
  88. # 5. BLLUETOOTH PROXY COMPONENTS
  89. esp32_ble_tracker:
  90. scan_parameters:
  91. interval: 1100ms
  92. window: 1100ms
  93. active: true
  94. bluetooth_proxy:
  95. active: true
  96. #button:
  97. #- platform: safe_mode
  98. # name: Safe Mode Boot
  99. # entity_category: diagnostic
  100. # 6. SENSORS
  101. ## Upteime information as sensor
  102. text_sensor:
  103. - platform: template
  104. name: "SLZB-06 Uptime"
  105. lambda: |-
  106. uint32_t dur = id(uptime_s).state;
  107. int dys = 0;
  108. int hrs = 0;
  109. int mnts = 0;
  110. if (dur > 86399) {
  111. dys = trunc(dur / 86400);
  112. dur = dur - (dys * 86400);
  113. }
  114. if (dur > 3599) {
  115. hrs = trunc(dur / 3600);
  116. dur = dur - (hrs * 3600);
  117. }
  118. if (dur > 59) {
  119. mnts = trunc(dur / 60);
  120. dur = dur - (mnts * 60);
  121. }
  122. char buffer[17];
  123. sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
  124. return {buffer};
  125. icon: mdi:clock-start
  126. update_interval: 60s
  127. ## Uptime generic sensor
  128. sensor:
  129. - platform: uptime
  130. id: uptime_s
  131. update_interval: 60s
  132. ## Status of physical button - sensor
  133. binary_sensor:
  134. - platform: gpio
  135. name: "Physical button status"
  136. icon: mdi:toggle-switch
  137. id: gpio35btn1
  138. pin:
  139. number: GPIO35
  140. mode:
  141. input: true
  142. inverted: yes
  143. on_press:
  144. then:
  145. - switch.toggle: modeSwitchTemplate
  146. - platform: uart_tcp
  147. uart_tcp_id: streamServer
  148. connected:
  149. name: "SLZB-06* Serial Connected"
  150. # 7. SWITCHES
  151. ## ESP32 Restart
  152. switch:
  153. - platform: restart
  154. id: coreRestart
  155. name: "Core only restart"
  156. ## Zigbee Restart
  157. - platform: gpio
  158. pin: 33
  159. id: zRST_gpio
  160. inverted: yes
  161. restore_mode: ALWAYS_OFF
  162. - platform: template
  163. name: "Zigbee Restart"
  164. icon: mdi:toggle-switch
  165. id: zRST
  166. turn_on_action:
  167. - switch.turn_on: zRST_gpio
  168. - delay: 15ms
  169. - switch.turn_off: zRST_gpio
  170. ## Full Restart
  171. - platform: template
  172. name: "Full (Core+Zigbee) Restart"
  173. icon: mdi:toggle-switch
  174. id: fullRST
  175. turn_on_action:
  176. - switch.turn_on: zRST_gpio
  177. - delay: 15ms
  178. - switch.turn_off: zRST_gpio
  179. - delay: 15ms
  180. - switch.turn_on: coreRestart
  181. ## Zigbee to flash mode switch
  182. - platform: gpio
  183. pin: 32
  184. name: "Zigbee flash Mode internal"
  185. icon: mdi:toggle-switch
  186. id: zBSL
  187. inverted: yes
  188. restore_mode: ALWAYS_OFF
  189. internal: true
  190. - platform: template
  191. name: "Zigbee flash Mode"
  192. icon: mdi:cellphone-arrow-down
  193. turn_on_action:
  194. - script.execute: fw_update_mode
  195. turn_off_action:
  196. - switch.toggle: zRST
  197. ## Mode LAN/USB switch
  198. - platform: template
  199. name: "DEVICE MODE SWITCH (LAN|OFF - USB|ON)"
  200. id: modeSwitchTemplate
  201. turn_on_action:
  202. - switch.turn_on: gpio12LED1
  203. - switch.turn_on: gpio4Select
  204. - switch.template.publish:
  205. id: modeSwitchTemplate
  206. state: ON
  207. turn_off_action:
  208. - switch.turn_off: gpio12LED1
  209. - switch.turn_off: gpio4Select
  210. - switch.template.publish:
  211. id: modeSwitchTemplate
  212. state: OFF
  213. - platform: gpio
  214. name: "DEVICE MODE SWITCH (LAN|OFF - USB|ON)"
  215. restore_mode: ALWAYS_OFF
  216. icon: mdi:toggle-switch
  217. internal: true
  218. id: gpio4Select
  219. pin:
  220. number: GPIO4
  221. ### LEDs swithces
  222. - platform: gpio
  223. name: "LED - device mode (Blue)"
  224. restore_mode: ALWAYS_OFF
  225. icon: mdi:toggle-switch
  226. id: gpio12LED1
  227. pin:
  228. number: GPIO12
  229. ignore_strapping_warning: true
  230. - platform: gpio
  231. name: "LED - power (Yellow)"
  232. restore_mode: ALWAYS_ON
  233. icon: mdi:toggle-switch
  234. id: gpio14LED2
  235. pin:
  236. number: GPIO14
  237. # 8. SCRIPTS
  238. script:
  239. - id: fw_update_mode
  240. then:
  241. - switch.turn_on: zBSL
  242. - delay: 1s
  243. - switch.turn_on: zRST_gpio
  244. - delay: 1s
  245. - switch.turn_off: zRST_gpio
  246. # - logger.log: "Wait 1 seconds for Zigbee chip to be ready"
  247. - delay: 1s
  248. - switch.turn_off: zBSL
  249. # - logger.log: "Update Zigbee with your Z-Stack firmware now!"