forked from letscontrolit/ESPEasy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request letscontrolit#5010 from tonhuisman/feature/P029-C0…
…02-Add-invert-on-off-value-option [P029][C002] Add option Invert On/Off value
- Loading branch information
Showing
4 changed files
with
99 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,93 @@ | ||
#include "_Plugin_Helper.h" | ||
#ifdef USES_P029 | ||
//####################################################################################################### | ||
//#################################### Plugin 029: Output ############################################### | ||
//####################################################################################################### | ||
|
||
// ####################################################################################################### | ||
// #################################### Plugin 029: Output ############################################### | ||
// ####################################################################################################### | ||
|
||
/** Changelog: | ||
* 2024-03-24 tonhuisman: Reformat source (Uncrustify), add option 'Invert On/Off value' | ||
* 2024-03-24 tonhuisman: Start Changelog (newest on top) | ||
*/ | ||
|
||
# define PLUGIN_029 | ||
# define PLUGIN_ID_029 29 | ||
# define PLUGIN_NAME_029 "Output - Domoticz MQTT Helper" | ||
# define PLUGIN_VALUENAME1_029 "Output" | ||
|
||
# define P029_INVERTED PCONFIG(0) | ||
|
||
#define PLUGIN_029 | ||
#define PLUGIN_ID_029 29 | ||
#define PLUGIN_NAME_029 "Output - Domoticz MQTT Helper" | ||
#define PLUGIN_VALUENAME1_029 "Output" | ||
boolean Plugin_029(uint8_t function, struct EventStruct *event, String& string) | ||
{ | ||
boolean success = false; | ||
|
||
switch (function) | ||
{ | ||
|
||
case PLUGIN_DEVICE_ADD: | ||
{ | ||
Device[++deviceCount].Number = PLUGIN_ID_029; | ||
Device[deviceCount].Type = DEVICE_TYPE_SINGLE; // FIXME TD-er: Does this need a pin? Seems not to be used | ||
Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_SWITCH; | ||
Device[deviceCount].Ports = 0; | ||
Device[deviceCount].PullUpOption = false; | ||
Device[deviceCount].InverseLogicOption = false; | ||
Device[deviceCount].FormulaOption = false; | ||
Device[deviceCount].ValueCount = 1; | ||
Device[deviceCount].SendDataOption = false; | ||
break; | ||
} | ||
{ | ||
Device[++deviceCount].Number = PLUGIN_ID_029; | ||
Device[deviceCount].Type = DEVICE_TYPE_SINGLE; | ||
Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_SWITCH; | ||
Device[deviceCount].Ports = 0; | ||
Device[deviceCount].PullUpOption = false; | ||
Device[deviceCount].InverseLogicOption = false; | ||
Device[deviceCount].FormulaOption = false; | ||
Device[deviceCount].ValueCount = 1; | ||
Device[deviceCount].SendDataOption = false; | ||
break; | ||
} | ||
|
||
case PLUGIN_GET_DEVICENAME: | ||
{ | ||
string = F(PLUGIN_NAME_029); | ||
break; | ||
} | ||
{ | ||
string = F(PLUGIN_NAME_029); | ||
break; | ||
} | ||
|
||
case PLUGIN_GET_DEVICEVALUENAMES: | ||
{ | ||
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_029)); | ||
ExtraTaskSettings.TaskDeviceValueDecimals[0] = 0; | ||
break; | ||
} | ||
{ | ||
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_029)); | ||
ExtraTaskSettings.TaskDeviceValueDecimals[0] = 0; | ||
break; | ||
} | ||
|
||
case PLUGIN_WEBFORM_LOAD: | ||
{ | ||
// We need the index of the controller we are: 0-CONTROLLER_MAX | ||
uint8_t controllerNr = 0; | ||
for (controllerIndex_t i=0; i < CONTROLLER_MAX; i++) | ||
{ | ||
// if (Settings.Protocol[i] == CPLUGIN_ID_002) { controllerNr = i; } -> error: 'CPLUGIN_ID_002' was not declared in this scope | ||
if (Settings.Protocol[i] == 2) { controllerNr = i; } | ||
} | ||
{ | ||
// We need the index of the controller we are: 0-CONTROLLER_MAX | ||
uint8_t controllerNr = 0; | ||
|
||
addRowLabel(F("IDX")); | ||
addNumericBox( | ||
concat(F("TDID"), controllerNr + 1), //="taskdeviceid" | ||
Settings.TaskDeviceID[controllerNr][event->TaskIndex], | ||
0, | ||
DOMOTICZ_MAX_IDX); | ||
success = true; | ||
break; | ||
for (controllerIndex_t i = 0; i < CONTROLLER_MAX; i++) | ||
{ | ||
// if (Settings.Protocol[i] == CPLUGIN_ID_002) { controllerNr = i; } -> error: 'CPLUGIN_ID_002' was not declared in | ||
// this scope | ||
if (Settings.Protocol[i] == 2) { controllerNr = i; } | ||
} | ||
|
||
addRowLabel(F("IDX")); | ||
addNumericBox( | ||
concat(F("TDID"), controllerNr + 1), // ="taskdeviceid" | ||
Settings.TaskDeviceID[controllerNr][event->TaskIndex], | ||
0, | ||
DOMOTICZ_MAX_IDX); | ||
|
||
addFormCheckBox(F("Invert On/Off value"), F("inverted"), P029_INVERTED == 1); | ||
|
||
success = true; | ||
break; | ||
} | ||
|
||
case PLUGIN_WEBFORM_SAVE: | ||
{ | ||
P029_INVERTED = isFormItemChecked(F("inverted")) ? 1 : 0; | ||
success = true; | ||
break; | ||
} | ||
case PLUGIN_INIT: | ||
{ | ||
success = true; | ||
break; | ||
} | ||
{ | ||
success = true; | ||
break; | ||
} | ||
} | ||
return success; | ||
} | ||
|
||
#endif // USES_P029 |