ESPHome  2023.3.1
number_traits.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "esphome/core/helpers.h"
4 
5 namespace esphome {
6 namespace number {
7 
8 enum NumberMode : uint8_t {
12 };
13 
14 class NumberTraits {
15  public:
16  // Set/get the number value boundaries.
17  void set_min_value(float min_value) { min_value_ = min_value; }
18  float get_min_value() const { return min_value_; }
19  void set_max_value(float max_value) { max_value_ = max_value; }
20  float get_max_value() const { return max_value_; }
21 
22  // Set/get the step size for incrementing or decrementing the number value.
23  void set_step(float step) { step_ = step; }
24  float get_step() const { return step_; }
25 
27  void set_unit_of_measurement(const std::string &unit_of_measurement);
29  std::string get_unit_of_measurement();
30 
31  // Set/get the frontend mode.
32  void set_mode(NumberMode mode) { this->mode_ = mode; }
33  NumberMode get_mode() const { return this->mode_; }
34 
35  // Set/get the device class.
36  void set_device_class(const std::string &device_class);
37  std::string get_device_class();
38 
39  protected:
40  float min_value_ = NAN;
41  float max_value_ = NAN;
42  float step_ = NAN;
46 };
47 
48 } // namespace number
49 } // namespace esphome
std::string get_unit_of_measurement()
Get the unit of measurement, using the manual override if set.
optional< std::string > device_class_
Definition: number_traits.h:45
void set_min_value(float min_value)
Definition: number_traits.h:17
BedjetMode mode
BedJet operating mode.
Definition: bedjet_codec.h:151
void set_unit_of_measurement(const std::string &unit_of_measurement)
Manually set the unit of measurement.
void set_max_value(float max_value)
Definition: number_traits.h:19
Definition: a4988.cpp:4
NumberMode get_mode() const
Definition: number_traits.h:33
void set_mode(NumberMode mode)
Definition: number_traits.h:32
void set_device_class(const std::string &device_class)
optional< std::string > unit_of_measurement_
Unit of measurement override.
Definition: number_traits.h:43