Hi,
I have two AM43 motors connected on Bluetooth to a ESP32
this is my code
# esp32 blinds #
# Substitutions
substitutions:
# Device Names
device_name: "esp32_blinds"
friendly_name: "ESP32-BLINDS"
esphome:
name: esp32-blinds
platform: ESP32
board: nodemcu-32s
wifi:
ssid: ""
password: ""
manual_ip:
static_ip: 192.168.0.141
gateway: 192.168.0.2
subnet: 255.255.255.0
dns1: 192.168.0.2
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32-Blinds Fallback Hotspot"
password: "ZID1ELiDRHfM"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
# Enable OTA #
ota:
# Enable Web server #
web_server:
port: 80
time:
- platform: homeassistant
id: my_time
# Device Status #
binary_sensor:
- platform: status
name: "${friendly_name} Device Status"
id: connected_status
text_sensor:
# ESP Version #
- platform: version
name: "${friendly_name} ESPHome Version"
- platform: template
name: Uptime Human Readable
id: uptime_human
icon: mdi:clock-start
# WiFi info #
- platform: wifi_info
ip_address:
name: ESP IP Address ${friendly_name}
id: IP_Address_${device_name}
ssid:
name: ESP Connected SSID ${friendly_name}
id: SSID_${device_name}
bssid:
name: ESP Connected BSSID ${friendly_name}
id: BSSID_${device_name}
# Bluetooth #
esp32_ble_tracker:
# Bluetooth Blinds #
ble_client:
- mac_address: 02:83:2A:C0:3E:26
id: am43_lounge_left
- mac_address: 02:5A:72:F2:2A:65
id: am43_lounge_right
sensor:
- platform: am43
ble_client_id: am43_lounge_left
battery_level:
name: "Lounge Blind Left Battery"
illuminance:
name: "Lounge Blind Left light"
- platform: am43
ble_client_id: am43_lounge_right
battery_level:
name: "Lounge Blind Right Battery"
illuminance:
name: "Lounge Blind Right light"
# Device Sensors #
- platform: uptime
name: Uptime Sensor
id: uptime_sensor
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m " : "") +
(to_string(seconds) + "s")
).c_str();
# WiFi Signal Sensor
- platform: wifi_signal
name: "${friendly_name} WiFi Status"
id: ${device_name}wifi_signal_strength
update_interval: 60s
# Uptime #
- platform: uptime
name: "${friendly_name} Uptime"
id: ${device_name}uptime
cover:
- platform: am43
name: "Lounge Blinds Left"
ble_client_id: am43_lounge_left
invert_position: false
pin: 8888
- platform: am43
name: "Lounge Blinds Right"
ble_client_id: am43_lounge_right
invert_position: false
pin: 8888
switch:
- platform: restart
name: "${friendly_name} Restart"
status_led:
pin:
number: GPIO2
inverted: TRUE
My issue is that from time to time it appears as if the ESP loses connection Bluetooth to the AM43.
To reestablish the connection I toggle the restart switch.
I would like to automate this say for example is it possible for the ESP to “ping” the Bluetooth mac address say every 30 minutes, and say if it does not get a response to toggle the restart?
The Wi-Fi to the ESP32 is fine and never loses connection, so that is why I am suspecting it is the Bluetooth part of the connection.
Has anyone else had this issue?
Regards,