6 namespace binary_sensor {
8 static const char *
const TAG =
"binary_sensor";
34 ESP_LOGD(TAG,
"'%s': Sending initial state %s", this->
get_name().c_str(), ONOFF(state));
36 ESP_LOGD(TAG,
"'%s': Sending state %s", this->
get_name().c_str(), ONOFF(state));
50 #pragma GCC diagnostic push 51 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 53 #pragma GCC diagnostic pop 61 while (last_filter->
next_ !=
nullptr)
62 last_filter = last_filter->
next_;
63 last_filter->
next_ = filter;
67 for (
Filter *filter : filters) {
void add_filter(Filter *filter)
void publish_initial_state(bool state)
Publish the initial state, this will not make the callback manager send callbacks and is meant only f...
bool next(T value)
Feeds the next item in the series to the deduplicator and returns whether this is a duplicate...
virtual bool is_status_binary_sensor() const
const std::string & get_name() const
virtual std::string device_class()
Override this to set the default device class.
virtual bool has_state() const
Return whether this binary sensor has outputted a state.
void send_state_internal(bool state, bool is_initial)
void input(bool value, bool is_initial)
bool state
The current reported state of the binary sensor.
Deduplicator< bool > publish_dedup_
void publish_state(bool state)
Publish a new state to the front-end.
void set_device_class(const std::string &device_class)
Manually set the Home Assistant device class (see binary_sensor::device_class)
void add_filters(const std::vector< Filter *> &filters)
bool publish_initial_state_
CallbackManager< void(bool)> state_callback_
void add_on_state_callback(std::function< void(bool)> &&callback)
Add a callback to be notified of state changes.
std::string get_device_class()
Get the device class for this binary sensor, using the manual override if specified.
optional< std::string > device_class_
Stores the override of the device class.