mirror of
https://github.com/esphome/esphome.git
synced 2025-11-20 08:46:01 +00:00
Add valve component (#6447)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
41
esphome/components/mqtt/mqtt_valve.h
Normal file
41
esphome/components/mqtt/mqtt_valve.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
#include "mqtt_component.h"
|
||||
|
||||
#ifdef USE_MQTT
|
||||
#ifdef USE_VALVE
|
||||
|
||||
#include "esphome/components/valve/valve.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
|
||||
class MQTTValveComponent : public mqtt::MQTTComponent {
|
||||
public:
|
||||
explicit MQTTValveComponent(valve::Valve *valve);
|
||||
|
||||
void setup() override;
|
||||
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override;
|
||||
|
||||
MQTT_COMPONENT_CUSTOM_TOPIC(position, command)
|
||||
MQTT_COMPONENT_CUSTOM_TOPIC(position, state)
|
||||
|
||||
bool send_initial_state() override;
|
||||
|
||||
bool publish_state();
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
std::string component_type() const override;
|
||||
const EntityBase *get_entity() const override;
|
||||
|
||||
valve::Valve *valve_;
|
||||
};
|
||||
|
||||
} // namespace mqtt
|
||||
} // namespace esphome
|
||||
|
||||
#endif
|
||||
#endif // USE_MQTT
|
||||
Reference in New Issue
Block a user