1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-10 23:32:23 +01:00

Add Number entities (from Home Assistant) (#1971)

Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
This commit is contained in:
Jesse Hills
2021-07-13 07:20:12 +12:00
committed by GitHub
parent 1f5c79bd17
commit dd37a4e04c
36 changed files with 1206 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
#pragma once
#include "esphome/core/defines.h"
#ifdef USE_NUMBER
#include "esphome/components/number/number.h"
#include "mqtt_component.h"
namespace esphome {
namespace mqtt {
class MQTTNumberComponent : public mqtt::MQTTComponent {
public:
/** Construct this MQTTNumberComponent instance with the provided friendly_name and number
*
* @param number The number.
*/
explicit MQTTNumberComponent(number::Number *number);
// ========== 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(float value);
protected:
/// Override for MQTTComponent, returns "number".
std::string component_type() const override;
std::string friendly_name() const override;
number::Number *number_;
};
} // namespace mqtt
} // namespace esphome
#endif