ESPHome
2023.11.6
|
Internal class that helps us create multiple sensors for one Dallas hub. More...
#include <dallas_component.h>
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 |
![]() | |
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) |
![]() | |
const StringRef & | get_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) |
![]() | |
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... | |
![]() | |
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 | |
DallasComponent * | parent_ |
uint64_t | address_ |
optional< uint8_t > | index_ |
uint8_t | resolution_ |
std::string | address_name_ |
uint8_t | scratch_pad_ [9] |
![]() | |
CallbackManager< void(float)> | raw_callback_ |
Storage for raw state callbacks. More... | |
CallbackManager< void(float)> | callback_ |
Storage for filtered state callbacks. More... | |
Filter * | filter_list_ {nullptr} |
Store all active filters. More... | |
optional< int8_t > | accuracy_decimals_ |
Accuracy in decimals override. More... | |
optional< StateClass > | state_class_ {STATE_CLASS_NONE} |
State class override. More... | |
bool | force_update_ {false} |
Force update mode. More... | |
bool | has_state_ {false} |
![]() | |
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} |
![]() | |
const char * | device_class_ {nullptr} |
Device class override. More... | |
![]() | |
const char * | unit_of_measurement_ {nullptr} |
Unit of measurement override. More... | |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
virtual uint32_t | hash_base () |
The hash_base() function has been deprecated. More... | |
void | calc_object_id_ () |
Internal class that helps us create multiple sensors for one Dallas hub.
Definition at line 35 of file dallas_component.h.
bool esphome::dallas::DallasTemperatureSensor::check_scratch_pad | ( | ) |
Definition at line 242 of file dallas_component.cpp.
uint8_t * esphome::dallas::DallasTemperatureSensor::get_address8 | ( | ) |
Helper to get a pointer to the address as uint8_t.
Definition at line 154 of file dallas_component.cpp.
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 155 of file dallas_component.cpp.
optional< uint8_t > esphome::dallas::DallasTemperatureSensor::get_index | ( | ) | const |
Get the index of this sensor. (0 if using address.)
Definition at line 152 of file dallas_component.cpp.
uint8_t esphome::dallas::DallasTemperatureSensor::get_resolution | ( | ) | const |
Get the set resolution for this sensor.
Definition at line 150 of file dallas_component.cpp.
float esphome::dallas::DallasTemperatureSensor::get_temp_c | ( | ) |
Definition at line 267 of file dallas_component.cpp.
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.
bool IRAM_ATTR esphome::dallas::DallasTemperatureSensor::read_scratch_pad | ( | ) |
Definition at line 162 of file dallas_component.cpp.
void esphome::dallas::DallasTemperatureSensor::set_address | ( | uint64_t | address | ) |
Set the 64-bit unsigned address for this sensor.
Definition at line 149 of file dallas_component.cpp.
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 153 of file dallas_component.cpp.
|
inline |
Definition at line 37 of file dallas_component.h.
void esphome::dallas::DallasTemperatureSensor::set_resolution | ( | uint8_t | resolution | ) |
Set the resolution for this sensor.
Definition at line 151 of file dallas_component.cpp.
bool esphome::dallas::DallasTemperatureSensor::setup_sensor | ( | ) |
Definition at line 186 of file dallas_component.cpp.
|
overridevirtual |
Reimplemented from esphome::sensor::Sensor.
Definition at line 276 of file dallas_component.cpp.
|
protected |
Definition at line 67 of file dallas_component.h.
|
protected |
Definition at line 71 of file dallas_component.h.
|
protected |
Definition at line 68 of file dallas_component.h.
|
protected |
Definition at line 66 of file dallas_component.h.
|
protected |
Definition at line 70 of file dallas_component.h.
|
protected |
Definition at line 72 of file dallas_component.h.