ESPHome  2024.11.0
automation.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace modbus_controller {
9 
10 class ModbusCommandSentTrigger : public Trigger<int, int> {
11  public:
13  a_modbuscontroller->add_on_command_sent_callback(
14  [this](int function_code, int address) { this->trigger(function_code, address); });
15  }
16 };
17 
18 class ModbusOnlineTrigger : public Trigger<int, int> {
19  public:
20  ModbusOnlineTrigger(ModbusController *a_modbuscontroller) {
21  a_modbuscontroller->add_on_online_callback(
22  [this](int function_code, int address) { this->trigger(function_code, address); });
23  }
24 };
25 
26 class ModbusOfflineTrigger : public Trigger<int, int> {
27  public:
28  ModbusOfflineTrigger(ModbusController *a_modbuscontroller) {
29  a_modbuscontroller->add_on_offline_callback(
30  [this](int function_code, int address) { this->trigger(function_code, address); });
31  }
32 };
33 
34 } // namespace modbus_controller
35 } // namespace esphome
void add_on_offline_callback(std::function< void(int, int)> &&callback)
Set callback for offline changes.
void add_on_online_callback(std::function< void(int, int)> &&callback)
Set callback for online changes.
ModbusCommandSentTrigger(ModbusController *a_modbuscontroller)
Definition: automation.h:12
ModbusOnlineTrigger(ModbusController *a_modbuscontroller)
Definition: automation.h:20
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
Definition: automation.h:95
void add_on_command_sent_callback(std::function< void(int, int)> &&callback)
Set callback for commands.
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
ModbusOfflineTrigger(ModbusController *a_modbuscontroller)
Definition: automation.h:28
uint8_t address
Definition: bl0906.h:211