mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-21 09:46:31 +00:00
Add script support to Energy Modbus
This commit is contained in:
parent
82ed5f0d06
commit
481cc63bf4
@ -6,7 +6,9 @@ Modbus JSON configuration data for use with generic Energy Modbus driver.
|
|||||||
|
|
||||||
1. Rule driven - copy the required JSON content to any rule buffer preceded with ``rule3 on file#modbus do `` and
|
1. Rule driven - copy the required JSON content to any rule buffer preceded with ``rule3 on file#modbus do `` and
|
||||||
followed with `` endon``.
|
followed with `` endon``.
|
||||||
2. File system driven - if a file system is present (every ESP32) create a file called ``modbus.json`` and copy the required JSON
|
2. Script driven - copy the required JSON content to a script preceded with ``>y`` and
|
||||||
|
followed with ``#``.
|
||||||
|
3. File system driven - if a file system is present (every ESP32) create a file called ``modbus.json`` and copy the required JSON
|
||||||
content to it.
|
content to it.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
* - Supports single three phase device or three single phase devices of same model on bus.
|
* - Supports single three phase device or three single phase devices of same model on bus.
|
||||||
* - For easy configuration of modbus energy monitor device(s) use:
|
* - For easy configuration of modbus energy monitor device(s) use:
|
||||||
* - a rule file called modbus
|
* - a rule file called modbus
|
||||||
|
* - a script using >y
|
||||||
* - a filesystem file called modbus.json
|
* - a filesystem file called modbus.json
|
||||||
*
|
*
|
||||||
* See files configurations.md and value_pair_description.md in folder energy_modbus_configs
|
* See files configurations.md and value_pair_description.md in folder energy_modbus_configs
|
||||||
@ -481,10 +482,9 @@ bool EnergyModbusReadRegisters(void) {
|
|||||||
String modbus = "";
|
String modbus = "";
|
||||||
|
|
||||||
#ifdef USE_UFILESYS
|
#ifdef USE_UFILESYS
|
||||||
const size_t file_size = ENERGY_MODBUS_MAX_FSIZE;
|
char *modbus_file = (char*)calloc(ENERGY_MODBUS_MAX_FSIZE, 1);
|
||||||
char *modbus_file = (char*)calloc(file_size, 1);
|
|
||||||
if (modbus_file) {
|
if (modbus_file) {
|
||||||
if (TfsLoadFile(ENERGY_MODBUS_FILE, (uint8_t*)modbus_file, file_size -1)) {
|
if (TfsLoadFile(ENERGY_MODBUS_FILE, (uint8_t*)modbus_file, ENERGY_MODBUS_MAX_FSIZE -1)) {
|
||||||
if (strlen(modbus_file) < ENERGY_MODBUS_MAX_FSIZE) {
|
if (strlen(modbus_file) < ENERGY_MODBUS_MAX_FSIZE) {
|
||||||
modbus = modbus_file;
|
modbus = modbus_file;
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Loaded from File"));
|
AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Loaded from File"));
|
||||||
@ -504,7 +504,7 @@ bool EnergyModbusReadRegisters(void) {
|
|||||||
#ifdef USE_SCRIPT
|
#ifdef USE_SCRIPT
|
||||||
if (!modbus.length()) {
|
if (!modbus.length()) {
|
||||||
modbus = ScriptLoadSection(">y");
|
modbus = ScriptLoadSection(">y");
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Loaded from script"));
|
AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Loaded from Script"));
|
||||||
}
|
}
|
||||||
#endif // USE_SCRIPT
|
#endif // USE_SCRIPT
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user