1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-08 06:12:20 +01:00

Publish custom data when modbus number lambda fills vector (#3295)

This commit is contained in:
Jesse Hills
2022-03-29 22:22:11 +13:00
committed by GitHub
parent cf5c640ae4
commit 7f7175b184
3 changed files with 69 additions and 28 deletions

View File

@@ -2,12 +2,12 @@
#include "esphome/core/component.h"
#include "esphome/core/automation.h"
#include "esphome/components/modbus/modbus.h"
#include "esphome/core/automation.h"
#include <list>
#include <set>
#include <queue>
#include <set>
#include <vector>
namespace esphome {
@@ -374,8 +374,8 @@ class ModbusCommandItem {
const std::vector<bool> &values);
/** Create custom modbus command
* @param modbusdevice pointer to the device to execute the command
* @param values byte vector of data to be sent to the device. The compplete payload must be provided with the
* exception of the crc codess
* @param values byte vector of data to be sent to the device. The complete payload must be provided with the
* exception of the crc codes
* @param handler function called when the response is received. Default is just logging a response
* @return ModbusCommandItem with the prepared command
*/
@@ -383,6 +383,18 @@ class ModbusCommandItem {
ModbusController *modbusdevice, const std::vector<uint8_t> &values,
std::function<void(ModbusRegisterType register_type, uint16_t start_address, const std::vector<uint8_t> &data)>
&&handler = nullptr);
/** Create custom modbus command
* @param modbusdevice pointer to the device to execute the command
* @param values word vector of data to be sent to the device. The complete payload must be provided with the
* exception of the crc codes
* @param handler function called when the response is received. Default is just logging a response
* @return ModbusCommandItem with the prepared command
*/
static ModbusCommandItem create_custom_command(
ModbusController *modbusdevice, const std::vector<uint16_t> &values,
std::function<void(ModbusRegisterType register_type, uint16_t start_address, const std::vector<uint8_t> &data)>
&&handler = nullptr);
};
/** Modbus controller class.