diff --git a/waveshare-esp32-s3-zero-btproxy.yaml b/waveshare-esp32-s3-zero-btproxy.yaml new file mode 100644 index 0000000..7007dba --- /dev/null +++ b/waveshare-esp32-s3-zero-btproxy.yaml @@ -0,0 +1,254 @@ +# Board: Waveshare ESP32-S3-Zero +# Chip: ESP32-S3FH4R2 +# CPU speed: 240MHz +# Flash: 4MB +# PSRAM: 2MB, Quad, 80MHz + +substitutions: + name: "esp32-s3-zero-btproxy" + friendly_name: "Bluetooth Proxy" + room: "" + device_description: "Waveshare ESP32-S3-Zero configured as Bluetooth proxy" + project_name: "dlitz.waveshare-esp32-s3-zero-btproxy" + project_version: "v0.0.1" + sensor_update_interval: "10s" + wifi_fast_connect: "false" + ibeacon_minor_id: 0 + +dashboard_import: + package_import_url: github://dlitz/esphome-configs-dlitz/waveshare-esp32-s3-zero-btproxy.yaml@${git_branch} + +packages: + - !include common/factory-reset.yaml + - !include common/git-branch.yaml + # - !include common/ota-update-password.yaml + - !include common/restart.yaml + - !include common/safe-mode.yaml + - !include common/time.yaml + - !include common/uptime-info.yaml + - !include common/wifi-info.yaml + +esphome: + name: "${name}" + friendly_name: "${friendly_name}" + comment: "${device_description}" + area: "${room}" + name_add_mac_suffix: true + project: + name: "${project_name}" + version: "${project_version}" + +esp32: + variant: esp32s3 + flash_size: 4MB + cpu_frequency: 240MHz + framework: + type: esp-idf + sdkconfig_options: + CONFIG_MBEDTLS_SSL_PROTO_TLS1_3: "y" # TLS1.3 support still isn't enabled by default in IDF 5.5.2 + CONFIG_MBEDTLS_DEFAULT_CERTIFICATE_BUNDLE: CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN + # CONFIG_LWIP_NETIF_LOOPBACK: "n" # Apparently there's a bug causing the ICMPv6 Router Solicitation to go out over the loopback interface rather than wifi + +psram: + mode: quad + speed: 80MHz + +# Enable logging +logger: + level: DEBUG + +# Enable Home Assistant API with dynamic key +api: + encryption: + +ota: + - platform: esphome + id: ota_id + password: !secret fallback_ota_password + +wifi: + # ssid: !secret wifi_ssid + # password: !secret wifi_password + # fast_connect: true + fast_connect: "${wifi_fast_connect}" + enable_btm: true + enable_rrm: true + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + password: !secret fallback_ap_password + +captive_portal: + +network: + enable_ipv6: true + # min_ipv6_addr_count: 2 + +# esp32_ble_tracker: +# scan_parameters: +# active: false +# +# bluetooth_proxy: +# active: true +# +# esp32_ble_beacon: +# type: iBeacon +# uuid: 'c3c4fcfa-de20-44d5-98e3-686f2dc47875' +# major: 10159 +# minor: ${ibeacon_minor_id} +# #measured_power: -51 + +binary_sensor: + - platform: gpio + name: "BOOT button" + entity_category: diagnostic + pin: + number: GPIO0 + mode: + input: true + pullup: true + inverted: true + ignore_strapping_warning: true + filters: + - settle: 10ms + on_multi_click: + - timing: + - ON for 5s to 10s + then: + - button.press: button_safe_mode + - timing: + - ON for at least 10s + then: + - button.press: button_factory_reset + +light: + - platform: esp32_rmt_led_strip + id: rgb_led + name: RGB LED + #entity_category: config + pin: GPIO21 + rgb_order: RGB + chipset: WS2812 + num_leds: 1 + restore_mode: ALWAYS_ON + initial_state: # XXX This doesn't seem to work for some rason + state: true + red: 0% + green: 100% + blue: 0% + brightness: 30% + effects: + - strobe: + - strobe: + name: Identify + colors: + - state: true + brightness: 30% + red: 0% + green: 0% + blue: 100% + duration: 250ms + - state: true + brightness: 100% + red: 0% + green: 0% + blue: 100% + duration: 250ms + - state: true + brightness: 100% + red: 0% + green: 100% + blue: 100% + duration: 250ms + - state: true + brightness: 30% + red: 0% + green: 100% + blue: 100% + duration: 250ms + + - platform: status_led + internal: true + id: status_led_id + output: status_led_output + +output: + - platform: template + id: status_led_output + type: binary + write_action: + - lambda: |- + static int prev_state = -1; + //ESP_LOGD("my_status", "prev_state: %d, state: %d, state size: %d", prev_state, (int)state, sizeof(state)); + if (prev_state <= 0 && state > 0) { + prev_state = state; + auto call = id(rgb_led).turn_on(); + call.set_brightness(0.30); + call.set_rgb(1.0, 0.0, 0.0); // red + call.set_transition_length(0); + call.set_publish(false); // Don't spam the logs + call.perform(); + } else if (prev_state > 0 && state == 0) { + prev_state = state; + auto call = id(rgb_led).make_call(); + call.from_light_color_values(id(rgb_led).remote_values); + call.set_transition_length(0); + call.set_publish(false); // Don't spam the logs + call.perform(); + } + +switch: + - platform: template + name: Identify + entity_category: config + optimistic: true + turn_on_action: + - light.turn_on: + id: rgb_led + effect: Identify + - logger.log: + format: "identify ON" + level: INFO + turn_off_action: + - light.turn_off: + id: rgb_led + - logger.log: + format: "identify OFF" + level: INFO + + - platform: template + id: trig_warning + name: Trigger warning + entity_category: diagnostic + disabled_by_default: true + optimistic: true + turn_on_action: + - lambda: |- + id(trig_warning).status_set_warning("foo"); + turn_off_action: + - lambda: |- + id(trig_warning).status_clear_warning(); + + - platform: template + id: trig_error + name: Trigger error + entity_category: diagnostic + disabled_by_default: true + optimistic: true + turn_on_action: + - lambda: |- + id(trig_error).status_set_error("foo"); + turn_off_action: + - lambda: |- + id(trig_error).status_clear_error(); + +sensor: + - platform: internal_temperature + id: cpu_temperature + name: "CPU Temperature" + + #- platform: template + # name: App state (uint8) + # lambda: |- + # return App.get_app_state(); + # update_interval: 1s