2019-04-17 12:06:00 +02:00
|
|
|
#include "esphome/core/util.h"
|
|
|
|
#include "esphome/core/defines.h"
|
|
|
|
#include "esphome/core/application.h"
|
2019-06-03 16:07:15 +02:00
|
|
|
#include "esphome/core/version.h"
|
2019-10-18 14:46:44 +02:00
|
|
|
#include "esphome/core/log.h"
|
2019-04-17 12:06:00 +02:00
|
|
|
|
|
|
|
#ifdef USE_API
|
|
|
|
#include "esphome/components/api/api_server.h"
|
|
|
|
#endif
|
|
|
|
|
2021-06-02 10:31:56 +01:00
|
|
|
#ifdef USE_MQTT
|
|
|
|
#include "esphome/components/mqtt/mqtt_client.h"
|
|
|
|
#endif
|
|
|
|
|
2019-04-17 12:06:00 +02:00
|
|
|
namespace esphome {
|
|
|
|
|
2021-06-02 10:31:56 +01:00
|
|
|
bool api_is_connected() {
|
|
|
|
#ifdef USE_API
|
|
|
|
if (api::global_api_server != nullptr) {
|
|
|
|
return api::global_api_server->is_connected();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mqtt_is_connected() {
|
|
|
|
#ifdef USE_MQTT
|
|
|
|
if (mqtt::global_mqtt_client != nullptr) {
|
|
|
|
return mqtt::global_mqtt_client->is_connected();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool remote_is_connected() { return api_is_connected() || mqtt_is_connected(); }
|
|
|
|
|
2019-04-17 12:06:00 +02:00
|
|
|
} // namespace esphome
|