add option to publish initial state of binary sensors (#3636)

Co-authored-by: Samuel Sieb <samuel@sieb.net>
This commit is contained in:
Samuel Sieb
2022-07-24 20:55:32 -07:00
committed by GitHub
parent 04f4dd8a22
commit 6a4e0cf667
4 changed files with 9 additions and 1 deletions

View File

@@ -58,6 +58,8 @@ class BinarySensor : public EntityBase {
void add_filter(Filter *filter);
void add_filters(const std::vector<Filter *> &filters);
void set_publish_initial_state(bool publish_initial_state) { this->publish_initial_state_ = publish_initial_state; }
// ========== INTERNAL METHODS ==========
// (In most use cases you won't need these)
void send_state_internal(bool state, bool is_initial);
@@ -80,6 +82,7 @@ class BinarySensor : public EntityBase {
optional<std::string> device_class_{}; ///< Stores the override of the device class
Filter *filter_list_{nullptr};
bool has_state_{false};
bool publish_initial_state_{false};
Deduplicator<bool> publish_dedup_;
};