ESPHome  2024.4.0
Public Member Functions | Protected Attributes
esphome::dallas::DallasTemperatureSensor Class Reference

Internal class that helps us create multiple sensors for one Dallas hub. More...

#include <dallas_component.h>

Inheritance diagram for esphome::dallas::DallasTemperatureSensor:
esphome::sensor::Sensor esphome::EntityBase esphome::EntityBase_DeviceClass esphome::EntityBase_UnitOfMeasurement

Public Member Functions

void set_parent (DallasComponent *parent)
 
uint8_t * get_address8 ()
 Helper to get a pointer to the address as uint8_t. More...
 
uint64_t get_address ()
 
const std::string & get_address_name ()
 Helper to create (and cache) the name for this sensor. For example "0xfe0000031f1eaf29". More...
 
void set_address (uint64_t address)
 Set the 64-bit unsigned address for this sensor. More...
 
optional< uint8_t > get_index () const
 Get the index of this sensor. (0 if using address.) More...
 
void set_index (uint8_t index)
 Set the index of this sensor. If using index, address will be set after setup. More...
 
uint8_t get_resolution () const
 Get the set resolution for this sensor. More...
 
void set_resolution (uint8_t resolution)
 Set the resolution for this sensor. More...
 
uint16_t millis_to_wait_for_conversion () const
 Get the number of milliseconds we have to wait for the conversion phase. More...
 
bool setup_sensor ()
 
bool read_scratch_pad ()
 
bool check_scratch_pad ()
 
float get_temp_c ()
 
std::string unique_id () override
 
- Public Member Functions inherited from esphome::sensor::Sensor
 Sensor ()
 
int8_t get_accuracy_decimals ()
 Get the accuracy in decimals, using the manual override if set. More...
 
void set_accuracy_decimals (int8_t accuracy_decimals)
 Manually set the accuracy in decimals. More...
 
StateClass get_state_class ()
 Get the state class, using the manual override if set. More...
 
void set_state_class (StateClass state_class)
 Manually set the state class. More...
 
bool get_force_update () const
 Get whether force update mode is enabled. More...
 
void set_force_update (bool force_update)
 Set force update mode. More...
 
void add_filter (Filter *filter)
 Add a filter to the filter chain. Will be appended to the back. More...
 
void add_filters (const std::vector< Filter *> &filters)
 Add a list of vectors to the back of the filter chain. More...
 
void set_filters (const std::vector< Filter *> &filters)
 Clear the filters and replace them by filters. More...
 
void clear_filters ()
 Clear the entire filter chain. More...
 
float get_state () const
 Getter-syntax for .state. More...
 
float get_raw_state () const
 Getter-syntax for .raw_state. More...
 
void publish_state (float state)
 Publish a new state to the front-end. More...
 
void add_on_state_callback (std::function< void(float)> &&callback)
 Add a callback that will be called every time a filtered value arrives. More...
 
void add_on_raw_state_callback (std::function< void(float)> &&callback)
 Add a callback that will be called every time the sensor sends a raw value. More...
 
bool has_state () const
 Return whether this sensor has gotten a full state (that passed through all filters) yet. More...
 
void internal_send_state_to_frontend (float state)
 
- Public Member Functions inherited from esphome::EntityBase
const StringRefget_name () const
 
void set_name (const char *name)
 
bool has_own_name () const
 
std::string get_object_id () const
 
void set_object_id (const char *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)
 
std::string get_icon () const
 
void set_icon (const char *icon)
 
- Public Member Functions inherited from esphome::EntityBase_DeviceClass
std::string get_device_class ()
 Get the device class, using the manual override if set. More...
 
void set_device_class (const char *device_class)
 Manually set the device class. More...
 
- Public Member Functions inherited from esphome::EntityBase_UnitOfMeasurement
std::string get_unit_of_measurement ()
 Get the unit of measurement, using the manual override if set. More...
 
void set_unit_of_measurement (const char *unit_of_measurement)
 Manually set the unit of measurement. More...
 

Protected Attributes

DallasComponentparent_
 
uint64_t address_
 
optional< uint8_t > index_
 
uint8_t resolution_
 
std::string address_name_
 
uint8_t scratch_pad_ [9]
 
- Protected Attributes inherited from esphome::sensor::Sensor
CallbackManager< void(float)> raw_callback_
 Storage for raw state callbacks. More...
 
CallbackManager< void(float)> callback_
 Storage for filtered state callbacks. More...
 
Filterfilter_list_ {nullptr}
 Store all active filters. More...
 
optional< int8_t > accuracy_decimals_
 Accuracy in decimals override. More...
 
optional< StateClassstate_class_ {STATE_CLASS_NONE}
 State class override. More...
 
bool force_update_ {false}
 Force update mode. More...
 
bool has_state_ {false}
 
- Protected Attributes inherited from esphome::EntityBase
StringRef name_
 
const char * object_id_c_str_ {nullptr}
 
const char * icon_c_str_ {nullptr}
 
uint32_t object_id_hash_
 
bool has_own_name_ {false}
 
bool internal_ {false}
 
bool disabled_by_default_ {false}
 
EntityCategory entity_category_ {ENTITY_CATEGORY_NONE}
 
- Protected Attributes inherited from esphome::EntityBase_DeviceClass
const char * device_class_ {nullptr}
 Device class override. More...
 
- Protected Attributes inherited from esphome::EntityBase_UnitOfMeasurement
const char * unit_of_measurement_ {nullptr}
 Unit of measurement override. More...
 

Additional Inherited Members

- Data Fields inherited from esphome::sensor::Sensor
float state
 This member variable stores the last state that has passed through all filters. More...
 
float raw_state
 This member variable stores the current raw state of the sensor, without any filters applied. More...
 
- Protected Member Functions inherited from esphome::EntityBase
virtual uint32_t hash_base ()
 The hash_base() function has been deprecated. More...
 
void calc_object_id_ ()
 

Detailed Description

Internal class that helps us create multiple sensors for one Dallas hub.

Definition at line 35 of file dallas_component.h.

Member Function Documentation

◆ check_scratch_pad()

bool esphome::dallas::DallasTemperatureSensor::check_scratch_pad ( )

Definition at line 250 of file dallas_component.cpp.

◆ get_address()

uint64_t esphome::dallas::DallasTemperatureSensor::get_address ( )

Definition at line 165 of file dallas_component.cpp.

◆ get_address8()

uint8_t * esphome::dallas::DallasTemperatureSensor::get_address8 ( )

Helper to get a pointer to the address as uint8_t.

Definition at line 164 of file dallas_component.cpp.

◆ get_address_name()

const std::string & esphome::dallas::DallasTemperatureSensor::get_address_name ( )

Helper to create (and cache) the name for this sensor. For example "0xfe0000031f1eaf29".

Definition at line 167 of file dallas_component.cpp.

◆ get_index()

optional< uint8_t > esphome::dallas::DallasTemperatureSensor::get_index ( ) const

Get the index of this sensor. (0 if using address.)

Definition at line 162 of file dallas_component.cpp.

◆ get_resolution()

uint8_t esphome::dallas::DallasTemperatureSensor::get_resolution ( ) const

Get the set resolution for this sensor.

Definition at line 160 of file dallas_component.cpp.

◆ get_temp_c()

float esphome::dallas::DallasTemperatureSensor::get_temp_c ( )

Definition at line 275 of file dallas_component.cpp.

◆ millis_to_wait_for_conversion()

uint16_t esphome::dallas::DallasTemperatureSensor::millis_to_wait_for_conversion ( ) const

Get the number of milliseconds we have to wait for the conversion phase.

Definition at line 18 of file dallas_component.cpp.

◆ read_scratch_pad()

bool IRAM_ATTR esphome::dallas::DallasTemperatureSensor::read_scratch_pad ( )

Definition at line 174 of file dallas_component.cpp.

◆ set_address()

void esphome::dallas::DallasTemperatureSensor::set_address ( uint64_t  address)

Set the 64-bit unsigned address for this sensor.

Definition at line 159 of file dallas_component.cpp.

◆ set_index()

void esphome::dallas::DallasTemperatureSensor::set_index ( uint8_t  index)

Set the index of this sensor. If using index, address will be set after setup.

Definition at line 163 of file dallas_component.cpp.

◆ set_parent()

void esphome::dallas::DallasTemperatureSensor::set_parent ( DallasComponent parent)
inline

Definition at line 37 of file dallas_component.h.

◆ set_resolution()

void esphome::dallas::DallasTemperatureSensor::set_resolution ( uint8_t  resolution)

Set the resolution for this sensor.

Definition at line 161 of file dallas_component.cpp.

◆ setup_sensor()

bool esphome::dallas::DallasTemperatureSensor::setup_sensor ( )

Definition at line 194 of file dallas_component.cpp.

◆ unique_id()

std::string esphome::dallas::DallasTemperatureSensor::unique_id ( )
overridevirtual

Reimplemented from esphome::sensor::Sensor.

Definition at line 284 of file dallas_component.cpp.

Field Documentation

◆ address_

uint64_t esphome::dallas::DallasTemperatureSensor::address_
protected

Definition at line 68 of file dallas_component.h.

◆ address_name_

std::string esphome::dallas::DallasTemperatureSensor::address_name_
protected

Definition at line 72 of file dallas_component.h.

◆ index_

optional<uint8_t> esphome::dallas::DallasTemperatureSensor::index_
protected

Definition at line 69 of file dallas_component.h.

◆ parent_

DallasComponent* esphome::dallas::DallasTemperatureSensor::parent_
protected

Definition at line 67 of file dallas_component.h.

◆ resolution_

uint8_t esphome::dallas::DallasTemperatureSensor::resolution_
protected

Definition at line 71 of file dallas_component.h.

◆ scratch_pad_

uint8_t esphome::dallas::DallasTemperatureSensor::scratch_pad_[9]
protected
Initial value:
= {
0,
}

Definition at line 73 of file dallas_component.h.


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