|
| 1 | +--- |
| 2 | +title: ESP-FBot Battery Integration |
| 3 | +date-published: 2025-12-07 |
| 4 | +type: sensor |
| 5 | +standard: global |
| 6 | +board: esp32 |
| 7 | +project-url: https://github.com/Ylianst/ESP-FBot |
| 8 | +difficulty: 2 |
| 9 | +--- |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +## Description |
| 14 | + |
| 15 | +ESP-FBot is an ESPHome custom component for locally monitoring and controlling portable power stations via Bluetooth. |
| 16 | +It provides fast local management without cloud services, making it ideal for outage situations. |
| 17 | + |
| 18 | +Compatible with battery systems that use the "BrightEMS" application, including: |
| 19 | + |
| 20 | +- **FOSSiBOT**: F3600 Pro, F2400 |
| 21 | +- **SYDPOWER**: N052, N066 |
| 22 | +- **AFERIY**: P210 (2400W/2048Wh), P310 (3300W/3840Wh) |
| 23 | + |
| 24 | +The ESP32 device communicates with the battery using Bluetooth and relays data locally via WiFi to Home Assistant. |
| 25 | + |
| 26 | +## Features |
| 27 | + |
| 28 | +- **Battery Monitoring**: Real-time battery state of charge (%), remaining capacity (kWh), and time remaining |
| 29 | +- **Power Monitoring**: Track input power, output power, system consumption, and total power flow |
| 30 | +- **Output Control**: Switch USB ports, DC outputs, AC inverter, and light on/off |
| 31 | +- **Home Assistant Integration**: All sensors and controls automatically discovered in Home Assistant |
| 32 | +- **Auto-reconnect**: Handles BLE disconnections and automatically reconnects |
| 33 | + |
| 34 | +## Requirements |
| 35 | + |
| 36 | +- A compatible battery that uses the "BrightEMS" application (no cloud pairing needed) |
| 37 | +- [Home Assistant](https://www.home-assistant.io/) with [ESPHome](https://esphome.io/) |
| 38 | +- ESP32 device (M5Stack ATOM Light, M5StickC PLUS2, ESP32-WROOM, ESP32-DevKit, etc.) |
| 39 | +- The ESP32 device must be within Bluetooth range of the battery (typically 10-30 feet) |
| 40 | + |
| 41 | +## Getting Started |
| 42 | + |
| 43 | +### 1. Get the Battery's MAC Address |
| 44 | + |
| 45 | +Find the Bluetooth LE MAC address of your battery by searching for a device that starts with "FOSSIBOT" or "POWER". |
| 46 | + |
| 47 | +**On Windows**: Use [BluetoothLEView](https://www.nirsoft.net/utils/bluetooth_low_energy_scanner.html) |
| 48 | + |
| 49 | +The MAC address will look like `A1:B2:C3:D4:E5:F6`. |
| 50 | + |
| 51 | +### 2. Installation |
| 52 | + |
| 53 | +1. Use the example configuration below as a starting point |
| 54 | +2. Update WiFi credentials, API encryption key, and Battery MAC address |
| 55 | +3. Flash to your ESP32 device |
| 56 | + |
| 57 | +## Configuration |
| 58 | + |
| 59 | +```yaml |
| 60 | +esphome: |
| 61 | + name: bigbattery |
| 62 | + friendly_name: Big Battery |
| 63 | + comment: "AFERIY 3840Wh Portable Power Station" |
| 64 | + |
| 65 | +esp32: |
| 66 | + board: esp32dev |
| 67 | + framework: |
| 68 | + type: esp-idf |
| 69 | + |
| 70 | +# Enable Home Assistant API |
| 71 | +api: |
| 72 | + encryption: |
| 73 | + # key: "your_api_encryption_key_here" # Generate your own key using ESPHome dashboard |
| 74 | + |
| 75 | +wifi: |
| 76 | + ssid: !secret wifi_ssid |
| 77 | + password: !secret wifi_password |
| 78 | + |
| 79 | +# Enable logging |
| 80 | +logger: |
| 81 | + level: WARN |
| 82 | + |
| 83 | +# Load external component from GitHub |
| 84 | +external_components: |
| 85 | + - source: github://ylianst/esp-fbot |
| 86 | + refresh: 10s |
| 87 | + |
| 88 | +# BLE Client configuration |
| 89 | +ble_client: |
| 90 | + - mac_address: "AA:BB:CC:DD:EE:FF" # Replace with your battery's MAC address |
| 91 | + |
| 92 | +# Configure the FBot component |
| 93 | +fbot: |
| 94 | + id: my_fbot |
| 95 | + polling_interval: 5s # How often to poll for updates (default: 2s) |
| 96 | + |
| 97 | +# Binary sensors for connection and output states |
| 98 | +binary_sensor: |
| 99 | + - platform: fbot |
| 100 | + fbot_id: my_fbot |
| 101 | + connected: |
| 102 | + name: "Connected" |
| 103 | + battery_connected_s1: |
| 104 | + name: "Connected S1" |
| 105 | + battery_connected_s2: |
| 106 | + name: "Connected S2" |
| 107 | + usb_active: |
| 108 | + name: "USB Active" |
| 109 | + dc_active: |
| 110 | + name: "DC Active" |
| 111 | + ac_active: |
| 112 | + name: "AC Inverter Active" |
| 113 | + light_active: |
| 114 | + name: "Light Active" |
| 115 | + |
| 116 | +# Sensors for battery and power readings |
| 117 | +sensor: |
| 118 | + - platform: fbot |
| 119 | + fbot_id: my_fbot |
| 120 | + battery_level: |
| 121 | + name: "Battery" |
| 122 | + id: battery_percent |
| 123 | + battery_s1_level: |
| 124 | + name: "Battery S1" |
| 125 | + id: battery_percent_s1 |
| 126 | + battery_s2_level: |
| 127 | + name: "Battery S2" |
| 128 | + id: battery_percent_s2 |
| 129 | + input_power: |
| 130 | + name: "Input Power" |
| 131 | + id: input_watts |
| 132 | + output_power: |
| 133 | + name: "Output Power" |
| 134 | + id: output_watts |
| 135 | + system_power: |
| 136 | + name: "System Power" |
| 137 | + id: system_watts |
| 138 | + total_power: |
| 139 | + name: "Total Power" |
| 140 | + id: total_watts |
| 141 | + remaining_time: |
| 142 | + name: "Remaining Minutes" |
| 143 | + id: remaining_minutes |
| 144 | + # Convert remaining time from minutes to hours |
| 145 | + - platform: template |
| 146 | + name: "Remaining Hours" |
| 147 | + lambda: |- |
| 148 | + if (id(remaining_minutes).has_state()) { |
| 149 | + return id(remaining_minutes).state / 60.0; |
| 150 | + } |
| 151 | + return 0.0; |
| 152 | + unit_of_measurement: "h" |
| 153 | + accuracy_decimals: 1 |
| 154 | + device_class: duration |
| 155 | + state_class: measurement |
| 156 | + update_interval: 5s |
| 157 | + # Net power (positive = charging, negative = discharging) |
| 158 | + - platform: template |
| 159 | + name: "Net Power" |
| 160 | + lambda: |- |
| 161 | + if (id(input_watts).has_state() && id(output_watts).has_state()) { |
| 162 | + return id(input_watts).state - id(output_watts).state; |
| 163 | + } |
| 164 | + return 0.0; |
| 165 | + unit_of_measurement: "W" |
| 166 | + accuracy_decimals: 0 |
| 167 | + device_class: power |
| 168 | + state_class: measurement |
| 169 | + update_interval: 5s |
| 170 | + |
| 171 | +# Switches to control outputs |
| 172 | +switch: |
| 173 | + - platform: fbot |
| 174 | + fbot_id: my_fbot |
| 175 | + usb: |
| 176 | + name: "USB Output" |
| 177 | + id: usb_switch |
| 178 | + dc: |
| 179 | + name: "DC Output" |
| 180 | + id: dc_switch |
| 181 | + ac: |
| 182 | + name: "AC Inverter" |
| 183 | + id: ac_switch |
| 184 | + light: |
| 185 | + name: "Light" |
| 186 | + id: light_switch |
| 187 | +``` |
| 188 | +
|
| 189 | +## Battery Factory Reset |
| 190 | +
|
| 191 | +To remove your battery's WiFi connection to the cloud, you can perform a factory reset. |
| 192 | +Press and hold the **DC button**, **light button**, and **USB button** simultaneously for |
| 193 | +about 5 seconds until you hear a beep. |
| 194 | +
|
| 195 | +## Links |
| 196 | +
|
| 197 | +- [GitHub Repository](https://github.com/Ylianst/ESP-FBot) |
| 198 | +- [M5 ATOM Extras](https://github.com/Ylianst/ESP-FBot/blob/main/docs/m5atom-extras.md) - Additional features |
0 commit comments