ESPHome  2021.11.3
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
esphome::number::Number Class Referenceabstract

Base-class for all numbers. More...

#include <number.h>

Inheritance diagram for esphome::number::Number:
esphome::EntityBase esphome::demo::DemoNumber esphome::modbus_controller::ModbusNumber esphome::template_::TemplateNumber

Public Member Functions

void publish_state (float state)
NumberCall make_call ()
void set (float value)
void add_on_state_callback (std::function< void(float)> &&callback)
bool has_state () const
 Return whether this number has gotten a full state yet. More...
- Public Member Functions inherited from esphome::EntityBase
 EntityBase ()
 EntityBase (std::string name)
const std::string & get_name () const
void set_name (const std::string &name)
const std::string & get_object_id ()
uint32_t get_object_id_hash ()
bool is_internal () const
void set_internal (bool internal)
bool is_disabled_by_default () const
void set_disabled_by_default (bool disabled_by_default)
EntityCategory get_entity_category () const
void set_entity_category (EntityCategory entity_category)
const std::string & get_icon () const
void set_icon (const std::string &name)

Data Fields

float state
NumberTraits traits

Protected Member Functions

virtual void control (float value)=0
 Set the value of the number, this is a virtual method that each number integration must implement. More...
uint32_t hash_base () override
- Protected Member Functions inherited from esphome::EntityBase
void calc_object_id_ ()

Protected Attributes

CallbackManager< void(float)> state_callback_
bool has_state_ {false}
- Protected Attributes inherited from esphome::EntityBase
std::string name_
std::string object_id_
std::string icon_
uint32_t object_id_hash_
bool internal_ {false}
bool disabled_by_default_ {false}
EntityCategory entity_category_ {ENTITY_CATEGORY_NONE}

Detailed Description

Base-class for all numbers.

A number can use publish_state to send out a new value.

Definition at line 55 of file number.h.

Member Function Documentation

◆ add_on_state_callback()

void esphome::number::Number::add_on_state_callback ( std::function< void(float)> &&  callback)

Definition at line 40 of file number.cpp.

◆ control()

virtual void esphome::number::Number::control ( float  value)
protectedpure virtual

Set the value of the number, this is a virtual method that each number integration must implement.

This method is called by the NumberCall.

valueThe value as validated by the NumberCall.

Implemented in esphome::modbus_controller::ModbusNumber, esphome::demo::DemoNumber, and esphome::template_::TemplateNumber.

◆ has_state()

bool esphome::number::Number::has_state ( ) const

Return whether this number has gotten a full state yet.

Definition at line 69 of file number.h.

◆ hash_base()

uint32_t esphome::number::Number::hash_base ( )

Implements esphome::EntityBase.

Definition at line 44 of file number.cpp.

◆ make_call()

NumberCall esphome::number::Number::make_call ( )

Definition at line 61 of file number.h.

◆ publish_state()

void esphome::number::Number::publish_state ( float  state)

Definition at line 33 of file number.cpp.

◆ set()

void esphome::number::Number::set ( float  value)

Definition at line 62 of file number.h.

Field Documentation

◆ has_state_

bool esphome::number::Number::has_state_ {false}

Definition at line 85 of file number.h.

◆ state

float esphome::number::Number::state

Definition at line 57 of file number.h.

◆ state_callback_

CallbackManager<void(float)> esphome::number::Number::state_callback_

Definition at line 84 of file number.h.

◆ traits

NumberTraits esphome::number::Number::traits

Definition at line 66 of file number.h.

The documentation for this class was generated from the following files: