ESPHome 2026.11.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

 ESPHOME_LOG_TAG (TAG, "modbus_controller.binary_sensor")
 
 ESPHOME_LOG_TAG (TAG, "modbus_controller")
 
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
 
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
 
 ESPHOME_LOG_TAG (TAG, "modbus.number")
 
 ESPHOME_LOG_TAG (TAG, "modbus_controller.output")
 
 ESPHOME_LOG_TAG (TAG, "modbus_controller.select")
 
 ESPHOME_LOG_TAG (TAG, "modbus_controller.sensor")
 
 ESPHOME_LOG_TAG (TAG, "modbus_controller.switch")
 
 ESPHOME_LOG_TAG (TAG, "modbus_controller.text_sensor")
 

Variables

const std::vector< uint8_t > & data
 

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 63 of file modbus_controller.h.

◆ RawEncoding

Enumerator
NONE 
HEXBYTES 
COMMA 
ANSI 

Definition at line 11 of file modbus_textsensor.h.

Function Documentation

◆ ESPDEPRECATED() [1/4]

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 633 of file modbus_controller.h.

◆ ESPDEPRECATED() [2/4]

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

◆ ESPDEPRECATED() [3/4]

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

◆ ESPDEPRECATED() [4/4]

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

Definition at line 42 of file modbus_controller.h.

◆ ESPHOME_LOG_TAG() [1/8]

esphome::modbus_controller::ESPHOME_LOG_TAG ( TAG ,
"modbus.number"  )

◆ ESPHOME_LOG_TAG() [2/8]

esphome::modbus_controller::ESPHOME_LOG_TAG ( TAG ,
"modbus_controller"  )

◆ ESPHOME_LOG_TAG() [3/8]

esphome::modbus_controller::ESPHOME_LOG_TAG ( TAG ,
"modbus_controller.binary_sensor"  )

◆ ESPHOME_LOG_TAG() [4/8]

esphome::modbus_controller::ESPHOME_LOG_TAG ( TAG ,
"modbus_controller.output"  )

◆ ESPHOME_LOG_TAG() [5/8]

esphome::modbus_controller::ESPHOME_LOG_TAG ( TAG ,
"modbus_controller.select"  )

◆ ESPHOME_LOG_TAG() [6/8]

esphome::modbus_controller::ESPHOME_LOG_TAG ( TAG ,
"modbus_controller.sensor"  )

◆ ESPHOME_LOG_TAG() [7/8]

esphome::modbus_controller::ESPHOME_LOG_TAG ( TAG ,
"modbus_controller.switch"  )

◆ ESPHOME_LOG_TAG() [8/8]

esphome::modbus_controller::ESPHOME_LOG_TAG ( TAG ,
"modbus_controller.text_sensor"  )

◆ 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 484 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 617 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 49 of file modbus_controller.h.