| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- # 1. SUBSTITUTIONS (Names to be used in sensor IDs)
- substitutions:
- name: "slzb-06-zigbee_bluetooth"
- # 2. GENERAL ESPHOME CONFIGURATION SETTINGS
- ## Project information
- esphome:
- name: "${name}"
- name_add_mac_suffix: true
- project:
- name: SMLIGHT.SLZB-06*(Zigbee+Bluetooth)
- version: "1.51"
- on_boot:
- priority: 600
- then:
- - switch.turn_on: zRST_gpio
- - delay: 15ms
- - switch.turn_off: zRST_gpio
- ## Board information
- esp32:
- board: esp32dev
- flash_size: 16MB
- framework:
- type: arduino
- ## Connection to Home Assistant through API is enabled
- api:
- ## Logger is enabled
- #logger:
- ## OTA firmware updates are available
- ota:
- - platform: esphome
- ## Accessible portal with control buttons is available
- #web_server:
- # port: 80
- # local: True
- ## WiFi settings
- #wifi:
- # ssid: !secret wifi_ssid
- # password: !secret wifi_password
- #
- # # Enable fallback hotspot (captive portal) in case wifi connection fails
- # ap:
- # ssid: "slzb-06 Hotspot"
- # password: "slzb06"
- ## Enabling captive portal
- # captive_portal:
- # 3. EXTERNAL COMPONENTS USED
- dashboard_import:
- package_import_url: github://smlight-dev/slzb-06-fw-esphome/configs/zb-bt.yaml
- # 4. COMMUNICATION SETTINGS
- ## Ethernet Connection
- ethernet:
- type: LAN8720
- mdc_pin: GPIO23
- mdio_pin: GPIO18
- clk:
- pin:
- number: GPIO0
- ignore_strapping_warning: true
- mode: CLK_EXT_IN
- phy_addr: 1
- power_pin: GPIO16
- ## UART Settings
- uart:
- id: uart_bus
- rx_pin:
- number: GPIO5
- ignore_strapping_warning: true
- tx_pin: GPIO17
- baud_rate: 115200
- ## Stream Server
- uart_tcp:
- - id: streamServer
- uart_id: uart_bus
- role: server
- port: 6638
- ## MDNS service settings
- mdns:
- services:
- - service: "_slzb-06"
- protocol: "_tcp"
- port: 6638
- txt:
- version: 1.0
- name: SMLIGHT SLZB-06
- radio_type: znp
- baud_rate: 115200
- data_flow_control: software
- # 5. BLLUETOOTH PROXY COMPONENTS
- esp32_ble_tracker:
- scan_parameters:
- interval: 1100ms
- window: 1100ms
- active: true
- bluetooth_proxy:
- active: true
- #button:
- #- platform: safe_mode
- # name: Safe Mode Boot
- # entity_category: diagnostic
- # 6. SENSORS
- ## Upteime information as sensor
- text_sensor:
- - platform: template
- name: "SLZB-06 Uptime"
- lambda: |-
- uint32_t dur = id(uptime_s).state;
- int dys = 0;
- int hrs = 0;
- int mnts = 0;
- if (dur > 86399) {
- dys = trunc(dur / 86400);
- dur = dur - (dys * 86400);
- }
- if (dur > 3599) {
- hrs = trunc(dur / 3600);
- dur = dur - (hrs * 3600);
- }
- if (dur > 59) {
- mnts = trunc(dur / 60);
- dur = dur - (mnts * 60);
- }
- char buffer[17];
- sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
- return {buffer};
- icon: mdi:clock-start
- update_interval: 60s
- ## Uptime generic sensor
- sensor:
- - platform: uptime
- id: uptime_s
- update_interval: 60s
- ## Status of physical button - sensor
- binary_sensor:
- - platform: gpio
- name: "Physical button status"
- icon: mdi:toggle-switch
- id: gpio35btn1
- pin:
- number: GPIO35
- mode:
- input: true
- inverted: yes
- on_press:
- then:
- - switch.toggle: modeSwitchTemplate
- - platform: uart_tcp
- uart_tcp_id: streamServer
- connected:
- name: "SLZB-06* Serial Connected"
- # 7. SWITCHES
- ## ESP32 Restart
- switch:
- - platform: restart
- id: coreRestart
- name: "Core only restart"
- ## Zigbee Restart
- - platform: gpio
- pin: 33
- id: zRST_gpio
- inverted: yes
- restore_mode: ALWAYS_OFF
- - platform: template
- name: "Zigbee Restart"
- icon: mdi:toggle-switch
- id: zRST
- turn_on_action:
- - switch.turn_on: zRST_gpio
- - delay: 15ms
- - switch.turn_off: zRST_gpio
- ## Full Restart
- - platform: template
- name: "Full (Core+Zigbee) Restart"
- icon: mdi:toggle-switch
- id: fullRST
- turn_on_action:
- - switch.turn_on: zRST_gpio
- - delay: 15ms
- - switch.turn_off: zRST_gpio
- - delay: 15ms
- - switch.turn_on: coreRestart
- ## Zigbee to flash mode switch
- - platform: gpio
- pin: 32
- name: "Zigbee flash Mode internal"
- icon: mdi:toggle-switch
- id: zBSL
- inverted: yes
- restore_mode: ALWAYS_OFF
- internal: true
-
- - platform: template
- name: "Zigbee flash Mode"
- icon: mdi:cellphone-arrow-down
- turn_on_action:
- - script.execute: fw_update_mode
- turn_off_action:
- - switch.toggle: zRST
- ## Mode LAN/USB switch
- - platform: template
- name: "DEVICE MODE SWITCH (LAN|OFF - USB|ON)"
- id: modeSwitchTemplate
- turn_on_action:
- - switch.turn_on: gpio12LED1
- - switch.turn_on: gpio4Select
- - switch.template.publish:
- id: modeSwitchTemplate
- state: ON
- turn_off_action:
- - switch.turn_off: gpio12LED1
- - switch.turn_off: gpio4Select
- - switch.template.publish:
- id: modeSwitchTemplate
- state: OFF
- - platform: gpio
- name: "DEVICE MODE SWITCH (LAN|OFF - USB|ON)"
- restore_mode: ALWAYS_OFF
- icon: mdi:toggle-switch
- internal: true
- id: gpio4Select
- pin:
- number: GPIO4
- ### LEDs swithces
- - platform: gpio
- name: "LED - device mode (Blue)"
- restore_mode: ALWAYS_OFF
- icon: mdi:toggle-switch
- id: gpio12LED1
- pin:
- number: GPIO12
- ignore_strapping_warning: true
- - platform: gpio
- name: "LED - power (Yellow)"
- restore_mode: ALWAYS_ON
- icon: mdi:toggle-switch
- id: gpio14LED2
- pin:
- number: GPIO14
- # 8. SCRIPTS
- script:
- - id: fw_update_mode
- then:
- - switch.turn_on: zBSL
- - delay: 1s
- - switch.turn_on: zRST_gpio
- - delay: 1s
- - switch.turn_off: zRST_gpio
- # - logger.log: "Wait 1 seconds for Zigbee chip to be ready"
- - delay: 1s
- - switch.turn_off: zBSL
- # - logger.log: "Update Zigbee with your Z-Stack firmware now!"
|