ESPHome  2023.5.5
subscribe_state.cpp
Go to the documentation of this file.
1 #include "subscribe_state.h"
2 #include "api_connection.h"
3 #include "esphome/core/log.h"
4 
5 namespace esphome {
6 namespace api {
7 
8 #ifdef USE_BINARY_SENSOR
10  return this->client_->send_binary_sensor_state(binary_sensor, binary_sensor->state);
11 }
12 #endif
13 #ifdef USE_COVER
15 #endif
16 #ifdef USE_FAN
17 bool InitialStateIterator::on_fan(fan::Fan *fan) { return this->client_->send_fan_state(fan); }
18 #endif
19 #ifdef USE_LIGHT
21 #endif
22 #ifdef USE_SENSOR
24  return this->client_->send_sensor_state(sensor, sensor->state);
25 }
26 #endif
27 #ifdef USE_SWITCH
29  return this->client_->send_switch_state(a_switch, a_switch->state);
30 }
31 #endif
32 #ifdef USE_TEXT_SENSOR
34  return this->client_->send_text_sensor_state(text_sensor, text_sensor->state);
35 }
36 #endif
37 #ifdef USE_CLIMATE
39 #endif
40 #ifdef USE_NUMBER
42  return this->client_->send_number_state(number, number->state);
43 }
44 #endif
45 #ifdef USE_SELECT
47  return this->client_->send_select_state(select, select->state);
48 }
49 #endif
50 #ifdef USE_LOCK
51 bool InitialStateIterator::on_lock(lock::Lock *a_lock) { return this->client_->send_lock_state(a_lock, a_lock->state); }
52 #endif
53 #ifdef USE_MEDIA_PLAYER
55  return this->client_->send_media_player_state(media_player);
56 }
57 #endif
59 
60 } // namespace api
61 } // namespace esphome
Base class for all switches.
Definition: switch.h:32
bool send_text_sensor_state(text_sensor::TextSensor *text_sensor, std::string state)
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition: light_state.h:34
Base class for all cover devices.
Definition: cover.h:111
bool on_light(light::LightState *light) override
bool send_switch_state(switch_::Switch *a_switch, bool state)
LockState state
The current reported state of the lock.
Definition: lock.h:122
bool send_fan_state(fan::Fan *fan)
bool send_climate_state(climate::Climate *climate)
bool send_lock_state(lock::Lock *a_lock, lock::LockState state)
bool on_text_sensor(text_sensor::TextSensor *text_sensor) override
bool on_number(number::Number *number) override
InitialStateIterator(APIConnection *client)
bool on_lock(lock::Lock *a_lock) override
float state
This member variable stores the last state that has passed through all filters.
Definition: sensor.h:131
bool send_sensor_state(sensor::Sensor *sensor, float state)
bool on_sensor(sensor::Sensor *sensor) override
bool send_select_state(select::Select *select, std::string state)
Base-class for all numbers.
Definition: number.h:39
bool on_media_player(media_player::MediaPlayer *media_player) override
bool send_binary_sensor_state(binary_sensor::BinarySensor *binary_sensor, bool state)
bool state
The current reported state of the binary sensor.
Definition: binary_sensor.h:61
bool on_select(select::Select *select) override
bool send_cover_state(cover::Cover *cover)
bool on_climate(climate::Climate *climate) override
std::string state
Definition: select.h:26
bool on_cover(cover::Cover *cover) override
Base-class for all selects.
Definition: select.h:24
bool send_light_state(light::LightState *light)
Definition: a4988.cpp:4
bool send_media_player_state(media_player::MediaPlayer *media_player)
Base class for all binary_sensor-type classes.
Definition: binary_sensor.h:37
bool on_binary_sensor(binary_sensor::BinarySensor *binary_sensor) override
Base-class for all sensors.
Definition: sensor.h:57
bool on_fan(fan::Fan *fan) override
bool send_number_state(number::Number *number, float state)
bool state
The current reported state of the binary sensor.
Definition: switch.h:46
Base class for all locks.
Definition: lock.h:103
bool on_switch(switch_::Switch *a_switch) override
ClimateDevice - This is the base class for all climate integrations.
Definition: climate.h:161