list_entities.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "list_entities.h"
  2. #include "esphome/core/util.h"
  3. #include "esphome/core/log.h"
  4. #include "esphome/core/application.h"
  5. #include "api_connection.h"
  6. namespace esphome {
  7. namespace api {
  8. #ifdef USE_BINARY_SENSOR
  9. bool ListEntitiesIterator::on_binary_sensor(binary_sensor::BinarySensor *binary_sensor) {
  10. return this->client_->send_binary_sensor_info(binary_sensor);
  11. }
  12. #endif
  13. #ifdef USE_COVER
  14. bool ListEntitiesIterator::on_cover(cover::Cover *cover) { return this->client_->send_cover_info(cover); }
  15. #endif
  16. #ifdef USE_FAN
  17. bool ListEntitiesIterator::on_fan(fan::FanState *fan) { return this->client_->send_fan_info(fan); }
  18. #endif
  19. #ifdef USE_LIGHT
  20. bool ListEntitiesIterator::on_light(light::LightState *light) { return this->client_->send_light_info(light); }
  21. #endif
  22. #ifdef USE_SENSOR
  23. bool ListEntitiesIterator::on_sensor(sensor::Sensor *sensor) { return this->client_->send_sensor_info(sensor); }
  24. #endif
  25. #ifdef USE_SWITCH
  26. bool ListEntitiesIterator::on_switch(switch_::Switch *a_switch) { return this->client_->send_switch_info(a_switch); }
  27. #endif
  28. #ifdef USE_TEXT_SENSOR
  29. bool ListEntitiesIterator::on_text_sensor(text_sensor::TextSensor *text_sensor) {
  30. return this->client_->send_text_sensor_info(text_sensor);
  31. }
  32. #endif
  33. bool ListEntitiesIterator::on_end() { return this->client_->send_list_info_done(); }
  34. ListEntitiesIterator::ListEntitiesIterator(APIServer *server, APIConnection *client)
  35. : ComponentIterator(server), client_(client) {}
  36. bool ListEntitiesIterator::on_service(UserServiceDescriptor *service) {
  37. auto resp = service->encode_list_service_response();
  38. return this->client_->send_list_entities_services_response(resp);
  39. }
  40. #ifdef USE_ESP32_CAMERA
  41. bool ListEntitiesIterator::on_camera(esp32_camera::ESP32Camera *camera) {
  42. return this->client_->send_camera_info(camera);
  43. }
  44. #endif
  45. #ifdef USE_CLIMATE
  46. bool ListEntitiesIterator::on_climate(climate::Climate *climate) { return this->client_->send_climate_info(climate); }
  47. #endif
  48. } // namespace api
  49. } // namespace esphome