mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-05 04:18:29 +02:00
Add select entities and implement template select (#2067)
Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
|
||||
#ifdef USE_SELECT
|
||||
|
||||
#include "esphome/components/select/select.h"
|
||||
#include "mqtt_component.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
class MQTTSelectComponent : public mqtt::MQTTComponent {
|
||||
public:
|
||||
/** Construct this MQTTSelectComponent instance with the provided friendly_name and select
|
||||
*
|
||||
* @param select The select.
|
||||
*/
|
||||
explicit MQTTSelectComponent(select::Select *select);
|
||||
|
||||
// ========== INTERNAL METHODS ==========
|
||||
// (In most use cases you won't need these)
|
||||
/// Override setup.
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
|
||||
void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override;
|
||||
|
||||
bool send_initial_state() override;
|
||||
bool is_internal() override;
|
||||
|
||||
bool publish_state(const std::string &value);
|
||||
|
||||
protected:
|
||||
/// Override for MQTTComponent, returns "select".
|
||||
std::string component_type() const override;
|
||||
|
||||
std::string friendly_name() const override;
|
||||
|
||||
select::Select *select_;
|
||||
};
|
||||
|
||||
} // namespace mqtt
|
||||
} // namespace esphome
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user