ESPHome 2026.10.0-dev
Loading...
Searching...
No Matches
esphome::modbus_controller Namespace Reference

Data Structures

class  ControllerDevice
 The shared feedback half of a controller-owned hub device: online/offline tracking, retry counting and the on_command_sent trigger all route to the controller from here. More...
 
class  ModbusBinaryOutput
 
class  ModbusBinarySensor
 
class  ModbusController
 Modbus controller class. More...
 
class  ModbusFloatOutput
 
class  ModbusNumber
 
class  ModbusSelect
 
class  ModbusSensor
 
class  ModbusSwitch
 
class  ModbusTextSensor
 
class  PollingDevice
 A persistent hub device that polls one register range - the read-side mirror of WriterDevice. More...
 
struct  RegisterRange
 
class  SensorItem
 
class  SensorItemsComparator
 
class  WriterDevice
 The write side of a ControllerDevice, owned by the writer entities through WriterEntity, whose forwarders re-expose exactly the request API a write lambda may use and record every dispatch. More...
 
class  WriterEntity
 Gives a writer entity the write API of the WriterDevice it owns. More...
 

Typedefs

using SensorSet = std::set<SensorItem *, SensorItemsComparator>
 
using value_to_data_t = std::function<float>(float)
 

Enumerations

enum class  RangeReuse : uint8_t { AUTO = 0 , ALWAYS = 1 , NEVER = 2 }
 How an item relates to the register range built just before it (same register type, address order). More...
 
enum class  RawEncoding { NONE = 0 , HEXBYTES = 1 , COMMA = 2 , ANSI = 3 }
 

Functions

 ESPDEPRECATED ("Use modbus::helpers::value_type_is_float() instead. Removed in 2026.10.0", "2026.4.0") inline bool value_type_is_float(SensorValueType v)
 
 ESPDEPRECATED ("Use modbus::helpers::modbus_register_read_function() instead. Removed in 2026.10.0", "2026.4.0") inline FunctionCode modbus_register_read_function(modbus
 
 ESPDEPRECATED ("Use modbus::helpers::modbus_register_write_function() instead. Removed in 2026.10.0", "2026.4.0") inline FunctionCode modbus_register_write_function(modbus
 
 ESPDEPRECATED ("Use modbus::helpers::c_to_hex() instead. Removed in 2026.10.0", "2026.4.0") inline uint8_t c_to_hex(char c)
 
 ESPDEPRECATED ("Use modbus::helpers::byte_from_hex_str() instead. Removed in 2026.10.0", "2026.4.0") inline uint8_t byte_from_hex_str(const std
 
 ESPDEPRECATED ("Use modbus::helpers::word_from_hex_str() instead. Removed in 2026.10.0", "2026.4.0") inline uint16_t word_from_hex_str(const std
 
 ESPDEPRECATED ("Use modbus::helpers::dword_from_hex_str() instead. Removed in 2026.10.0", "2026.4.0") inline uint32_t dword_from_hex_str(const std
 
 ESPDEPRECATED ("Use modbus::helpers::qword_from_hex_str() instead. Removed in 2026.10.0", "2026.4.0") inline uint64_t qword_from_hex_str(const std
 
template<typename T >
 ESPDEPRECATED ("Use modbus::helpers::get_data() instead. Removed in 2026.10.0", "2026.4.0") T get_data(const std
 
template<typename T >
 ESPDEPRECATED ("Use modbus::helpers::get_data() instead. Removed in 2027.2.0", "2026.8.0") T get_data(std
 
 ESPDEPRECATED ("Use modbus::helpers::bit_from_packed() instead. Removed in 2027.2.0", "2026.4.0") inline bool coil_from_vector(int coil
 
 ESPDEPRECATED ("Use modbus::helpers::bit_from_packed() instead. Removed in 2027.2.0", "2026.8.0") inline bool coil_from_vector(int coil
 
template<typename N >
 ESPDEPRECATED ("Use modbus::helpers::mask_and_shift_by_rightbit() instead. Removed in 2026.10.0", "2026.4.0") N mask_and_shift_by_rightbit(N data
 
 ESPDEPRECATED ("Use modbus::helpers::number_to_payload() instead. Removed in 2026.10.0", "2026.4.0") inline void number_to_payload(std
 
 ESPDEPRECATED ("Use modbus::helpers::payload_to_number() instead. Removed in 2026.10.0", "2026.4.0") inline int64_t payload_to_number(const std
 
 ESPDEPRECATED ("Use modbus::helpers::float_to_payload() instead. Removed in 2026.10.0", "2026.4.0") inline std
 
class ESPDEPRECATED("One-shot writes go through the entity write helpers (WriterDevice) or the modbus_client actions, and " "polling runs through PollingDevice. Removed in 2027.3.0", "2026.9.0") ModbusCommandItem bool offline_retry_due (uint16_t update_counter, uint16_t module_offline_at, uint16_t offline_skip_updates)
 A single modbus command.
 
float payload_to_float (std::span< const uint8_t > data, const SensorItem &item, uint8_t offset)
 Convert vector<uint8_t> response payload to float.
 
 ESPDEPRECATED ("Pass the offset explicitly: payload_to_float(data, item, item.offset). Removed in 2027.2.0", "2026.8.0") inline float payload_to_float(std
 

Variables

const std::vector< uint8_t > & data
 
uint32_t mask
 

Typedef Documentation

◆ SensorSet

◆ value_to_data_t

using esphome::modbus_controller::value_to_data_t = std::function<float>(float)

Definition at line 11 of file modbus_number.h.

Enumeration Type Documentation

◆ RangeReuse

enum class esphome::modbus_controller::RangeReuse : uint8_t
strong

How an item relates to the register range built just before it (same register type, address order).

The numeric order doubles as the comparator tiebreak for items at the same address (see SensorItemsComparator): AUTO items form the shared range first, so a NEVER item comes last and shares a range it did not start (items on one address must share, see create_polling_commands_()).

Enumerator
AUTO 
ALWAYS 
NEVER 

Definition at line 133 of file modbus_controller.h.

◆ RawEncoding

Enumerator
NONE 
HEXBYTES 
COMMA 
ANSI 

Definition at line 11 of file modbus_textsensor.h.

Function Documentation

◆ ESPDEPRECATED() [1/17]

esphome::modbus_controller::ESPDEPRECATED ( "Pass the offset explicitly: payload_to_float(data, item, item.offset). Removed in 2027.2.0" ,
"2026.8.0"  )

Definition at line 698 of file modbus_controller.h.

◆ ESPDEPRECATED() [2/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::bit_from_packed() instead. Removed in 2027.2.0" ,
"2026.4.0"  )

◆ ESPDEPRECATED() [3/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::bit_from_packed() instead. Removed in 2027.2.0" ,
"2026.8.0"  )

◆ ESPDEPRECATED() [4/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::byte_from_hex_str() instead. Removed in 2026.10.0" ,
"2026.4.0"  ) const

Definition at line 50 of file modbus_controller.h.

◆ ESPDEPRECATED() [5/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::c_to_hex() instead. Removed in 2026.10.0" ,
"2026.4.0"  )

Definition at line 47 of file modbus_controller.h.

◆ ESPDEPRECATED() [6/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::dword_from_hex_str() instead. Removed in 2026.10.0" ,
"2026.4.0"  ) const

Definition at line 60 of file modbus_controller.h.

◆ ESPDEPRECATED() [7/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::float_to_payload() instead. Removed in 2026.10.0" ,
"2026.4.0"  )

Definition at line 120 of file modbus_controller.h.

◆ ESPDEPRECATED() [8/17]

template<typename T >
esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::get_data() instead. Removed in 2026.10.0" ,
"2026.4.0"  ) const

Definition at line 71 of file modbus_controller.h.

◆ ESPDEPRECATED() [9/17]

template<typename T >
esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::get_data() instead. Removed in 2027.2.0" ,
"2026.8.0"  )

Definition at line 85 of file modbus_controller.h.

◆ ESPDEPRECATED() [10/17]

template<typename N >
esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::mask_and_shift_by_rightbit() instead. Removed in 2026.10.0" ,
"2026.4.0"  )

◆ ESPDEPRECATED() [11/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::modbus_register_read_function() instead. Removed in 2026.10.0" ,
"2026.4.0"  )

Definition at line 37 of file modbus_controller.h.

◆ ESPDEPRECATED() [12/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::modbus_register_write_function() instead. Removed in 2026.10.0" ,
"2026.4.0"  )

Definition at line 42 of file modbus_controller.h.

◆ ESPDEPRECATED() [13/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::number_to_payload() instead. Removed in 2026.10.0" ,
"2026.4.0"  )

Definition at line 108 of file modbus_controller.h.

◆ ESPDEPRECATED() [14/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::payload_to_number() instead. Removed in 2026.10.0" ,
"2026.4.0"  ) const

Definition at line 113 of file modbus_controller.h.

◆ ESPDEPRECATED() [15/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::qword_from_hex_str() instead. Removed in 2026.10.0" ,
"2026.4.0"  ) const

Definition at line 65 of file modbus_controller.h.

◆ ESPDEPRECATED() [16/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::value_type_is_float() instead. Removed in 2026.10.0" ,
"2026.4.0"  )

Definition at line 34 of file modbus_controller.h.

◆ ESPDEPRECATED() [17/17]

esphome::modbus_controller::ESPDEPRECATED ( "Use modbus::helpers::word_from_hex_str() instead. Removed in 2026.10.0" ,
"2026.4.0"  ) const

Definition at line 55 of file modbus_controller.h.

◆ offline_retry_due()

class ESPDEPRECATED("One-shot writes go through the entity write helpers (WriterDevice) or the modbus_client actions, and " "polling runs through PollingDevice. Removed in 2027.3.0", "2026.9.0") ModbusCommandItem bool esphome::modbus_controller::offline_retry_due ( uint16_t update_counter,
uint16_t module_offline_at,
uint16_t offline_skip_updates )
inline

A single modbus command.

Each command is its own ModbusClientDevice: it sends its frame to the hub and the hub routes the response back to this object's on_modbus_* callbacks, so the controller no longer has to match responses to a FIFO queue. Whether an offline probe is due this update cycle: every offline_skip_updates + 1 cycles, anchored at the cycle the device went offline. Pure so the cadence (including update_counter wraparound) can be unit tested; used by ModbusController::update().

Definition at line 549 of file modbus_controller.h.

◆ payload_to_float()

float esphome::modbus_controller::payload_to_float ( std::span< const uint8_t > data,
const SensorItem & item,
uint8_t offset )
inline

Convert vector<uint8_t> response payload to float.

Parameters
datapayload with data
itemSensorItem object
Returns
float value of data

Definition at line 682 of file modbus_controller.h.

Variable Documentation

◆ data

std::span< const uint8_t > esphome::modbus_controller::data
Initial value:
{
return modbus::helpers::bit_from_packed(coil, data)

Definition at line 92 of file modbus_controller.h.

◆ mask

uint32_t esphome::modbus_controller::mask
Initial value:
{
return modbus::helpers::mask_and_shift_by_rightbit(data, mask)

Definition at line 104 of file modbus_controller.h.