devWaves / SwitchBot-MQTT-BLE-ESP32

Allows for multiple SwitchBot bots and curtains to be controlled via MQTT sent to ESP32. ESP32 will send BLE commands to switchbots and return MQTT responses to the broker. Also supports Temperature, Motion, Contact sensors
MIT License
549 stars 68 forks source link

Add MQTT channel/attribute for wifi rssi #25

Closed gdolfen closed 3 years ago

gdolfen commented 3 years ago

Can you please add a MQTT channel or an attribute to an existing channel for wifi rssi.

Here is a code snipped:

String rssi = String(WiFi.RSSI()); client.publish("switchbot/esp32/rssi", rssi);

devWaves commented 3 years ago

ya sure no problem. I'm looking at adding some updates for low battery, I will add it in that release

before I get to it, you can try adding your code snippet in this method that gets called every 30 sec

void publishLastwillOnline() {
  if ((millis() - lastOnlinePublished) > 30000) {
    if (client.isConnected()) {
      client.publish(lastWill, "online", true);
      lastOnlinePublished = millis();
    }
  }
}
devWaves commented 3 years ago

v6.0 adds an esp32 device to HA with rssi value