[modbus_controller] Add on_command_sent trigger (#7078)

Co-authored-by: Leo Schelvis <leo.schelvis@gmail.com>
This commit is contained in:
leejoow
2024-07-22 03:33:11 +02:00
committed by GitHub
parent a464e46d4d
commit 0a7d883633
5 changed files with 57 additions and 2 deletions
@@ -0,0 +1,19 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/core/automation.h"
#include "esphome/components/modbus_controller/modbus_controller.h"
namespace esphome {
namespace modbus_controller {
class ModbusCommandSentTrigger : public Trigger<int, int> {
public:
ModbusCommandSentTrigger(ModbusController *a_modbuscontroller) {
a_modbuscontroller->add_on_command_sent_callback(
[this](int function_code, int address) { this->trigger(function_code, address); });
}
};
} // namespace modbus_controller
} // namespace esphome