ESPHome  2022.1.2
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

Public Member Functions

void set_parent (DallasComponent *parent)
 
uint8_t * get_address8 ()
 Helper to get a pointer to the address as uint8_t. More...
 
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 ()
 
 Sensor (const std::string &name)
 
std::string get_unit_of_measurement ()
 Get the unit of measurement, using the manual override if set. More...
 
void set_unit_of_measurement (const std::string &unit_of_measurement)
 Manually set the unit of measurement. More...
 
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...
 
std::string get_device_class ()
 Get the device class, using the manual override if set. More...
 
void set_device_class (const std::string &device_class)
 Manually set the device class. 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
 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)
 

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...
 
bool has_state_ {false}
 
Filterfilter_list_ {nullptr}
 Store all active filters. More...
 
optional< std::string > unit_of_measurement_
 Unit of measurement override. More...
 
optional< int8_t > accuracy_decimals_
 Accuracy in decimals override. More...
 
optional< std::string > device_class_
 Device class override. More...
 
optional< StateClassstate_class_ {STATE_CLASS_NONE}
 State class override. More...
 
bool force_update_ {false}
 Force update mode. More...
 
- 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}
 

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::sensor::Sensor
virtual std::string unit_of_measurement ()
 Override this to set the default unit of measurement. More...
 
virtual int8_t accuracy_decimals ()
 Override this to set the default accuracy in decimals. More...
 
virtual std::string device_class ()
 Override this to set the default device class. More...
 
virtual StateClass state_class ()
 Override this to set the default state class. More...
 
uint32_t hash_base () override
 
- Protected Member Functions inherited from esphome::EntityBase
void calc_object_id_ ()
 

Detailed Description

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

Definition at line 33 of file dallas_component.h.

Member Function Documentation

◆ check_scratch_pad()

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

Definition at line 220 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 145 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 146 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 143 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 141 of file dallas_component.cpp.

◆ get_temp_c()

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

Definition at line 229 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 153 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 140 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 144 of file dallas_component.cpp.

◆ set_parent()

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

Definition at line 35 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 142 of file dallas_component.cpp.

◆ setup_sensor()

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

Definition at line 167 of file dallas_component.cpp.

◆ unique_id()

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

Reimplemented from esphome::sensor::Sensor.

Definition at line 238 of file dallas_component.cpp.

Field Documentation

◆ address_

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

Definition at line 65 of file dallas_component.h.

◆ address_name_

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

Definition at line 69 of file dallas_component.h.

◆ index_

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

Definition at line 66 of file dallas_component.h.

◆ parent_

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

Definition at line 64 of file dallas_component.h.

◆ resolution_

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

Definition at line 68 of file dallas_component.h.

◆ scratch_pad_

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

Definition at line 70 of file dallas_component.h.


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