[P180] Process I2C commands synchronous when called from rules and other internal sources

This commit is contained in:
Ton Huisman
2026-04-18 17:15:03 +02:00
parent dbc6c2112c
commit 17cda47d17
2 changed files with 13 additions and 5 deletions
+4 -3
View File
@@ -6,6 +6,7 @@
// #######################################################################################################
/** Changelog:
* 2026-04-18 tonhuisman: Process I2C commands synchronously when triggered from an internal source, like rules.
* 2026-02-14 tonhuisman: Set default Cache-name when empty, for improved plugin runtime performance.
* 2025-12-06 tonhuisman: Enable CustomVTypeVar and MQTTStateClass device options, as any type of sensor can be connected
* 2025-06-04 tonhuisman: Add [<taskname>#log] to Get Config to fetch the current Parsing and execution log setting
@@ -52,9 +53,9 @@
* <cmd>[.<fmt>[.<len>]][.<register>][.<data>];...[|(1ps|10ps|50ps)|<cmd_sequences>]
*
* get.<fmt>[.<len>]
* put.<fmt>.<data>[.<data>...]
* read.<fmt>[.<len>].<reg>
* write.<fmt>.<reg>.<data>[.<data>...]
* put.<fmt>.<data>[.<data>...] Data can be from global <var>, except for b and w format
* read.<fmt>[.<len>].<reg> Register can be from global <var>
* write.<fmt>.<reg>.<data>[.<data>...] Data can be from global <var>, except for b and w format
* eval
* value.<valueIndex> (1..4)
* calc.<calculation> Like Rules, extra available vars: %value%, %pvalue%, %h%, %b0%..%b<n>%, %bx0%..%bx<n>%, %w0%..%w<n>%, %wx0%..%wx<n>%
+9 -2
View File
@@ -165,9 +165,15 @@ bool P180_data_struct::plugin_write(struct EventStruct *event,
busCmd_Helper->setCommands(cmds,
taskVar,
0,
1, // Process single entry
1, // Process single entry
BusCmd_CommandState_e::Processing);
Scheduler.schedule_task_device_timer(_taskIndex, millis() + 5);
if (EventValueSource::isExternalSource(event->Source)) { // Execute on next occasion
Scheduler.schedule_task_device_timer(_taskIndex, millis() + 5);
} else { // Execute immediately
busCmd_Helper->setCommandSource(BusCmd_CommandSource_e::PluginWrite);
busCmd_Helper->processCommands(event);
}
success = true;
}
@@ -180,6 +186,7 @@ bool P180_data_struct::plugin_write(struct EventStruct *event,
* Handle get config value retrieval processing
********************************************************************************************/
# ifndef LIMIT_BUILD_SIZE
bool P180_data_struct::plugin_get_config(struct EventStruct *event,
String & string) {
bool success = false;