2019-04-17 12:06:00 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "esphome/core/component.h"
|
|
|
|
#include "esphome/core/controller.h"
|
2022-03-23 09:45:05 +13:00
|
|
|
#include "esphome/core/helpers.h"
|
|
|
|
|
2019-04-17 12:06:00 +02:00
|
|
|
#ifdef USE_ESP32_CAMERA
|
|
|
|
#include "esphome/components/esp32_camera/esp32_camera.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace esphome {
|
|
|
|
|
2022-03-23 09:45:05 +13:00
|
|
|
#ifdef USE_API
|
|
|
|
namespace api {
|
2019-04-17 12:06:00 +02:00
|
|
|
class UserServiceDescriptor;
|
2022-03-23 09:45:05 +13:00
|
|
|
} // namespace api
|
|
|
|
#endif
|
2019-04-17 12:06:00 +02:00
|
|
|
|
|
|
|
class ComponentIterator {
|
|
|
|
public:
|
2022-03-23 09:45:05 +13:00
|
|
|
void begin(bool include_internal = false);
|
2019-04-17 12:06:00 +02:00
|
|
|
void advance();
|
|
|
|
virtual bool on_begin();
|
|
|
|
#ifdef USE_BINARY_SENSOR
|
|
|
|
virtual bool on_binary_sensor(binary_sensor::BinarySensor *binary_sensor) = 0;
|
|
|
|
#endif
|
|
|
|
#ifdef USE_COVER
|
|
|
|
virtual bool on_cover(cover::Cover *cover) = 0;
|
|
|
|
#endif
|
|
|
|
#ifdef USE_FAN
|
2022-01-23 10:21:54 +01:00
|
|
|
virtual bool on_fan(fan::Fan *fan) = 0;
|
2019-04-17 12:06:00 +02:00
|
|
|
#endif
|
|
|
|
#ifdef USE_LIGHT
|
|
|
|
virtual bool on_light(light::LightState *light) = 0;
|
|
|
|
#endif
|
|
|
|
#ifdef USE_SENSOR
|
|
|
|
virtual bool on_sensor(sensor::Sensor *sensor) = 0;
|
|
|
|
#endif
|
|
|
|
#ifdef USE_SWITCH
|
|
|
|
virtual bool on_switch(switch_::Switch *a_switch) = 0;
|
|
|
|
#endif
|
2021-11-30 08:00:51 +13:00
|
|
|
#ifdef USE_BUTTON
|
|
|
|
virtual bool on_button(button::Button *button) = 0;
|
|
|
|
#endif
|
2019-04-17 12:06:00 +02:00
|
|
|
#ifdef USE_TEXT_SENSOR
|
|
|
|
virtual bool on_text_sensor(text_sensor::TextSensor *text_sensor) = 0;
|
|
|
|
#endif
|
2022-03-23 09:45:05 +13:00
|
|
|
#ifdef USE_API
|
|
|
|
virtual bool on_service(api::UserServiceDescriptor *service);
|
|
|
|
#endif
|
2019-04-17 12:06:00 +02:00
|
|
|
#ifdef USE_ESP32_CAMERA
|
|
|
|
virtual bool on_camera(esp32_camera::ESP32Camera *camera);
|
|
|
|
#endif
|
|
|
|
#ifdef USE_CLIMATE
|
|
|
|
virtual bool on_climate(climate::Climate *climate) = 0;
|
2021-07-13 07:20:12 +12:00
|
|
|
#endif
|
|
|
|
#ifdef USE_NUMBER
|
|
|
|
virtual bool on_number(number::Number *number) = 0;
|
2021-08-02 20:00:51 +12:00
|
|
|
#endif
|
|
|
|
#ifdef USE_SELECT
|
|
|
|
virtual bool on_select(select::Select *select) = 0;
|
2022-02-03 13:24:31 -05:00
|
|
|
#endif
|
|
|
|
#ifdef USE_LOCK
|
|
|
|
virtual bool on_lock(lock::Lock *a_lock) = 0;
|
2019-04-17 12:06:00 +02:00
|
|
|
#endif
|
|
|
|
virtual bool on_end();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
enum class IteratorState {
|
|
|
|
NONE = 0,
|
|
|
|
BEGIN,
|
|
|
|
#ifdef USE_BINARY_SENSOR
|
|
|
|
BINARY_SENSOR,
|
|
|
|
#endif
|
|
|
|
#ifdef USE_COVER
|
|
|
|
COVER,
|
|
|
|
#endif
|
|
|
|
#ifdef USE_FAN
|
|
|
|
FAN,
|
|
|
|
#endif
|
|
|
|
#ifdef USE_LIGHT
|
|
|
|
LIGHT,
|
|
|
|
#endif
|
|
|
|
#ifdef USE_SENSOR
|
|
|
|
SENSOR,
|
|
|
|
#endif
|
|
|
|
#ifdef USE_SWITCH
|
|
|
|
SWITCH,
|
|
|
|
#endif
|
2021-11-30 08:00:51 +13:00
|
|
|
#ifdef USE_BUTTON
|
|
|
|
BUTTON,
|
|
|
|
#endif
|
2019-04-17 12:06:00 +02:00
|
|
|
#ifdef USE_TEXT_SENSOR
|
|
|
|
TEXT_SENSOR,
|
|
|
|
#endif
|
2022-03-23 09:45:05 +13:00
|
|
|
#ifdef USE_API
|
2019-04-17 12:06:00 +02:00
|
|
|
SERVICE,
|
2022-03-23 09:45:05 +13:00
|
|
|
#endif
|
2019-04-17 12:06:00 +02:00
|
|
|
#ifdef USE_ESP32_CAMERA
|
|
|
|
CAMERA,
|
|
|
|
#endif
|
|
|
|
#ifdef USE_CLIMATE
|
|
|
|
CLIMATE,
|
2021-07-13 07:20:12 +12:00
|
|
|
#endif
|
|
|
|
#ifdef USE_NUMBER
|
|
|
|
NUMBER,
|
2021-08-02 20:00:51 +12:00
|
|
|
#endif
|
|
|
|
#ifdef USE_SELECT
|
|
|
|
SELECT,
|
2022-02-03 13:24:31 -05:00
|
|
|
#endif
|
|
|
|
#ifdef USE_LOCK
|
|
|
|
LOCK,
|
2019-04-17 12:06:00 +02:00
|
|
|
#endif
|
|
|
|
MAX,
|
|
|
|
} state_{IteratorState::NONE};
|
|
|
|
size_t at_{0};
|
2022-03-23 09:45:05 +13:00
|
|
|
bool include_internal_{false};
|
2019-04-17 12:06:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace esphome
|