mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-24 23:07:17 +00:00
Add command source information
5.14.0b * Add source information to command execution to be shown with logging option 3 (#2843)
This commit is contained in:
parent
41496acdee
commit
ed56322f12
@ -2,6 +2,7 @@
|
||||
* Add two rule sets of 511 characters using commands rule1, rule2 and rule3
|
||||
* Add rule support for IrReceive and RfReceive (#2758)
|
||||
* Add command WebSend [<host>(:<port>,<user>:<password>)] <command> (#2821)
|
||||
* Add source information to command execution to be shown with logging option 3 (#2843)
|
||||
* Fix some Pow R2 and S31 checksum errors (#1907)
|
||||
*
|
||||
* 5.14.0a
|
||||
|
@ -192,6 +192,10 @@ enum XsnsFunctions {FUNC_INIT, FUNC_LOOP, FUNC_EVERY_50_MSECOND, FUNC_EVERY_SECO
|
||||
|
||||
const uint8_t kDefaultRfCode[9] PROGMEM = { 0x21, 0x16, 0x01, 0x0E, 0x03, 0x48, 0x2E, 0x1A, 0x00 };
|
||||
|
||||
enum CommandSource { SRC_IGNORE, SRC_MQTT, SRC_RESTART, SRC_BUTTON, SRC_SWITCH, SRC_BACKLOG, SRC_SERIAL, SRC_WEBGUI, SRC_WEBCOMMAND, SRC_WEBCONSOLE, SRC_PULSETIMER,
|
||||
SRC_TIMER, SRC_RULE, SRC_MAXPOWER, SRC_MAXENERGY, SRC_LIGHT, SRC_KNX, SRC_DISPLAY, SRC_WEMO, SRC_HUE, SRC_MAX };
|
||||
const char kCommandSource[] PROGMEM = "I|MQTT|Restart|Button|Switch|Backlog|Serial|WebGui|WebCommand|WebConsole|PulseTimer|Timer|Rule|MaxPower|MaxEnergy|Light|Knx|Display|Wemo|Hue";
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Extern global variables
|
||||
\*********************************************************************************************/
|
||||
|
@ -304,10 +304,12 @@ void SetLatchingRelay(power_t power, uint8_t state)
|
||||
}
|
||||
}
|
||||
|
||||
void SetDevicePower(power_t rpower)
|
||||
void SetDevicePower(power_t rpower, int source)
|
||||
{
|
||||
uint8_t state;
|
||||
|
||||
ShowSource(source);
|
||||
|
||||
if (POWER_ALL_ALWAYS_ON == Settings.poweronstate) { // All on and stay on
|
||||
power = (1 << devices_present) -1;
|
||||
rpower = power;
|
||||
@ -396,6 +398,8 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||
memcpy(dataBuf, data +i, sizeof(dataBuf));
|
||||
dataBuf[sizeof(dataBuf)-1] = 0;
|
||||
|
||||
if (topicBuf[0] != '/') { ShowSource(SRC_MQTT); }
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_RESULT D_RECEIVED_TOPIC " %s, " D_DATA_SIZE " %d, " D_DATA " %s"),
|
||||
topicBuf, data_len, dataBuf);
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE);
|
||||
@ -490,7 +494,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||
else if ((CMND_POWER == command_code) && (index > 0) && (index <= devices_present)) {
|
||||
if ((payload < 0) || (payload > 4)) payload = 9;
|
||||
// Settings.flag.device_index_enable = user_append_index;
|
||||
ExecuteCommandPower(index, payload);
|
||||
ExecuteCommandPower(index, payload, SRC_IGNORE);
|
||||
fallback_topic_flag = 0;
|
||||
return;
|
||||
}
|
||||
@ -516,7 +520,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||
Settings.poweronstate = payload;
|
||||
if (POWER_ALL_ALWAYS_ON == Settings.poweronstate) {
|
||||
for (byte i = 1; i <= devices_present; i++) {
|
||||
ExecuteCommandPower(i, POWER_ON);
|
||||
ExecuteCommandPower(i, POWER_ON, SRC_IGNORE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1155,7 +1159,7 @@ boolean SendKey(byte key, byte device, byte state)
|
||||
return result;
|
||||
}
|
||||
|
||||
void ExecuteCommandPower(byte device, byte state)
|
||||
void ExecuteCommandPower(byte device, byte state, int source)
|
||||
{
|
||||
// device = Relay number 1 and up
|
||||
// state 0 = Relay Off
|
||||
@ -1167,6 +1171,8 @@ void ExecuteCommandPower(byte device, byte state)
|
||||
// state 7 = Relay On and no publishPowerState
|
||||
// state 9 = Show power state
|
||||
|
||||
// ShowSource(source);
|
||||
|
||||
uint8_t publish_power = 1;
|
||||
if ((POWER_OFF_NO_STATE == state) || (POWER_ON_NO_STATE == state)) {
|
||||
state &= 1;
|
||||
@ -1184,7 +1190,7 @@ void ExecuteCommandPower(byte device, byte state)
|
||||
interlock_mutex = 1;
|
||||
for (byte i = 0; i < devices_present; i++) {
|
||||
power_t imask = 1 << i;
|
||||
if ((power & imask) && (mask != imask)) ExecuteCommandPower(i +1, POWER_OFF);
|
||||
if ((power & imask) && (mask != imask)) ExecuteCommandPower(i +1, POWER_OFF, SRC_IGNORE);
|
||||
}
|
||||
interlock_mutex = 0;
|
||||
}
|
||||
@ -1198,7 +1204,7 @@ void ExecuteCommandPower(byte device, byte state)
|
||||
case POWER_TOGGLE:
|
||||
power ^= mask;
|
||||
}
|
||||
SetDevicePower(power);
|
||||
SetDevicePower(power, source);
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzUpdatePowerState(device);
|
||||
#endif // USE_DOMOTICZ
|
||||
@ -1225,7 +1231,7 @@ void ExecuteCommandPower(byte device, byte state)
|
||||
byte flag = (blink_mask & mask);
|
||||
blink_mask &= (POWER_MASK ^ mask); // Clear device mask
|
||||
MqttPublishPowerBlinkState(device);
|
||||
if (flag) ExecuteCommandPower(device, (blink_powersave >> (device -1))&1); // Restore state
|
||||
if (flag) ExecuteCommandPower(device, (blink_powersave >> (device -1))&1, SRC_IGNORE); // Restore state
|
||||
return;
|
||||
}
|
||||
if (publish_power) MqttPublishPowerState(device);
|
||||
@ -1240,18 +1246,20 @@ void StopAllPowerBlink()
|
||||
if (blink_mask & mask) {
|
||||
blink_mask &= (POWER_MASK ^ mask); // Clear device mask
|
||||
MqttPublishPowerBlinkState(i);
|
||||
ExecuteCommandPower(i, (blink_powersave >> (i -1))&1); // Restore state
|
||||
ExecuteCommandPower(i, (blink_powersave >> (i -1))&1, SRC_IGNORE); // Restore state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExecuteCommand(char *cmnd)
|
||||
void ExecuteCommand(char *cmnd, int source)
|
||||
{
|
||||
char stopic[CMDSZ];
|
||||
char svalue[INPUT_BUFFER_SIZE];
|
||||
char *start;
|
||||
char *token;
|
||||
|
||||
ShowSource(source);
|
||||
|
||||
token = strtok(cmnd, " ");
|
||||
if (token != NULL) {
|
||||
start = strrchr(token, '/'); // Skip possible cmnd/sonoff/ preamble
|
||||
@ -1550,7 +1558,7 @@ void ButtonHandler()
|
||||
}
|
||||
if (button_pressed) {
|
||||
if (!SendKey(0, button_index +1, POWER_TOGGLE)) { // Execute Toggle command via MQTT if ButtonTopic is set
|
||||
ExecuteCommandPower(button_index +1, POWER_TOGGLE); // Execute Toggle command internally
|
||||
ExecuteCommandPower(button_index +1, POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1559,7 +1567,7 @@ void ButtonHandler()
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_IMMEDIATE), button_index +1);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
if (!SendKey(0, button_index +1, POWER_TOGGLE)) { // Execute Toggle command via MQTT if ButtonTopic is set
|
||||
ExecuteCommandPower(button_index +1, POWER_TOGGLE); // Execute Toggle command internally
|
||||
ExecuteCommandPower(button_index +1, POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally
|
||||
}
|
||||
} else {
|
||||
multipress[button_index] = (multiwindow[button_index]) ? multipress[button_index] +1 : 1;
|
||||
@ -1578,7 +1586,7 @@ void ButtonHandler()
|
||||
if (holdbutton[button_index] == Settings.param[P_HOLD_TIME] * (STATES / 10) * hold_time_extent) { // Button held for factor times longer
|
||||
// Settings.flag.button_single = 0;
|
||||
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_SETOPTION "13 0")); // Disable single press only
|
||||
ExecuteCommand(scmnd);
|
||||
ExecuteCommand(scmnd, SRC_BUTTON);
|
||||
}
|
||||
} else {
|
||||
if (Settings.flag.button_restrict) { // Button restriction
|
||||
@ -1590,7 +1598,7 @@ void ButtonHandler()
|
||||
if (holdbutton[button_index] == (Settings.param[P_HOLD_TIME] * (STATES / 10)) * hold_time_extent) { // Button held for factor times longer
|
||||
multipress[button_index] = 0;
|
||||
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_RESET " 1"));
|
||||
ExecuteCommand(scmnd);
|
||||
ExecuteCommand(scmnd, SRC_BUTTON);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1617,12 +1625,12 @@ void ButtonHandler()
|
||||
if (WifiState()) { // WPSconfig, Smartconfig or Wifimanager active
|
||||
restart_flag = 1;
|
||||
} else {
|
||||
ExecuteCommandPower(button_index + multipress[button_index], POWER_TOGGLE); // Execute Toggle command internally
|
||||
ExecuteCommandPower(button_index + multipress[button_index], POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally
|
||||
}
|
||||
} else { // 3 - 7 press
|
||||
if (!Settings.flag.button_restrict) {
|
||||
snprintf_P(scmnd, sizeof(scmnd), kCommands[multipress[button_index] -3]);
|
||||
ExecuteCommand(scmnd);
|
||||
ExecuteCommand(scmnd, SRC_BUTTON);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1705,7 +1713,7 @@ void SwitchHandler()
|
||||
|
||||
if (switchflag < 3) {
|
||||
if (!SendKey(1, i +1, switchflag)) { // Execute command via MQTT
|
||||
ExecuteCommandPower(i +1, switchflag); // Execute command internally (if i < devices_present)
|
||||
ExecuteCommandPower(i +1, switchflag, SRC_SWITCH); // Execute command internally (if i < devices_present)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1752,8 +1760,8 @@ void StateLoop()
|
||||
if ((pulse_timer[i] > 0) && (pulse_timer[i] < 112)) {
|
||||
pulse_timer[i]--;
|
||||
if (!pulse_timer[i]) {
|
||||
// ExecuteCommandPower(i +1, POWER_OFF);
|
||||
ExecuteCommandPower(i +1, (POWER_ALL_OFF_PULSETIME_ON == Settings.poweronstate) ? POWER_ON : POWER_OFF);
|
||||
// ExecuteCommandPower(i +1, POWER_OFF, SRC_PULSETIMER);
|
||||
ExecuteCommandPower(i +1, (POWER_ALL_OFF_PULSETIME_ON == Settings.poweronstate) ? POWER_ON : POWER_OFF, SRC_PULSETIMER);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1768,7 +1776,7 @@ void StateLoop()
|
||||
} else {
|
||||
blink_power ^= 1;
|
||||
power_now = (power & (POWER_MASK ^ blink_mask)) | ((blink_power) ? blink_mask : 0);
|
||||
SetDevicePower(power_now);
|
||||
SetDevicePower(power_now, SRC_IGNORE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1777,7 +1785,7 @@ void StateLoop()
|
||||
if (backlog_delay) backlog_delay--;
|
||||
if ((backlog_pointer != backlog_index) && !backlog_delay && !backlog_mutex) {
|
||||
backlog_mutex = 1;
|
||||
ExecuteCommand((char*)backlog[backlog_pointer].c_str());
|
||||
ExecuteCommand((char*)backlog[backlog_pointer].c_str(), SRC_BACKLOG);
|
||||
backlog_mutex = 0;
|
||||
backlog_pointer++;
|
||||
if (backlog_pointer >= MAX_BACKLOG) backlog_pointer = 0;
|
||||
@ -2122,7 +2130,7 @@ void SerialInput()
|
||||
seriallog_level = (Settings.seriallog_level < LOG_LEVEL_INFO) ? (byte)LOG_LEVEL_INFO : Settings.seriallog_level;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_COMMAND "%s"), serial_in_buffer);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
ExecuteCommand(serial_in_buffer);
|
||||
ExecuteCommand(serial_in_buffer, SRC_SERIAL);
|
||||
serial_in_byte_counter = 0;
|
||||
serial_polling_window = 0;
|
||||
Serial.flush();
|
||||
@ -2379,36 +2387,36 @@ void setup()
|
||||
|
||||
if (MOTOR == Settings.module) Settings.poweronstate = POWER_ALL_ON; // Needs always on else in limbo!
|
||||
if (POWER_ALL_ALWAYS_ON == Settings.poweronstate) {
|
||||
SetDevicePower(1);
|
||||
SetDevicePower(1, SRC_RESTART);
|
||||
} else {
|
||||
if ((resetInfo.reason == REASON_DEFAULT_RST) || (resetInfo.reason == REASON_EXT_SYS_RST)) {
|
||||
switch (Settings.poweronstate) {
|
||||
case POWER_ALL_OFF:
|
||||
case POWER_ALL_OFF_PULSETIME_ON:
|
||||
power = 0;
|
||||
SetDevicePower(power);
|
||||
SetDevicePower(power, SRC_RESTART);
|
||||
break;
|
||||
case POWER_ALL_ON: // All on
|
||||
power = (1 << devices_present) -1;
|
||||
SetDevicePower(power);
|
||||
SetDevicePower(power, SRC_RESTART);
|
||||
break;
|
||||
case POWER_ALL_SAVED_TOGGLE:
|
||||
power = (Settings.power & ((1 << devices_present) -1)) ^ POWER_MASK;
|
||||
if (Settings.flag.save_state) {
|
||||
SetDevicePower(power);
|
||||
SetDevicePower(power, SRC_RESTART);
|
||||
}
|
||||
break;
|
||||
case POWER_ALL_SAVED:
|
||||
power = Settings.power & ((1 << devices_present) -1);
|
||||
if (Settings.flag.save_state) {
|
||||
SetDevicePower(power);
|
||||
SetDevicePower(power, SRC_RESTART);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
power = Settings.power & ((1 << devices_present) -1);
|
||||
if (Settings.flag.save_state) {
|
||||
SetDevicePower(power);
|
||||
SetDevicePower(power, SRC_RESTART);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -606,6 +606,15 @@ uint32_t GetHash(const char *buffer, size_t size)
|
||||
return hash;
|
||||
}
|
||||
|
||||
void ShowSource(int source)
|
||||
{
|
||||
if ((source > 0) && (source < SRC_MAX)) {
|
||||
char stemp1[20];
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("SRC: %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Fill feature list
|
||||
\*********************************************************************************************/
|
||||
|
@ -337,6 +337,21 @@ static void WebGetArg(const char* arg, char* out, size_t max)
|
||||
out[max-1] = '\0'; // Ensure terminating NUL
|
||||
}
|
||||
|
||||
void ShowWebSource(int source)
|
||||
{
|
||||
if ((source > 0) && (source < SRC_MAX)) {
|
||||
char stemp1[20];
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("SRC: %s from %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource), WebServer->client().remoteIP().toString().c_str());
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
void ExecuteWebCommand(char* svalue, int source)
|
||||
{
|
||||
ShowWebSource(source);
|
||||
ExecuteCommand(svalue, SRC_IGNORE);
|
||||
}
|
||||
|
||||
void StartWebserver(int type, IPAddress ipweb)
|
||||
{
|
||||
if (!webserver_state) {
|
||||
@ -567,22 +582,23 @@ void HandleAjaxStatusRefresh()
|
||||
|
||||
WebGetArg("o", tmp, sizeof(tmp));
|
||||
if (strlen(tmp)) {
|
||||
ExecuteCommandPower(atoi(tmp), POWER_TOGGLE);
|
||||
ShowWebSource(SRC_WEBGUI);
|
||||
ExecuteCommandPower(atoi(tmp), POWER_TOGGLE, SRC_IGNORE);
|
||||
}
|
||||
WebGetArg("d", tmp, sizeof(tmp));
|
||||
if (strlen(tmp)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_DIMMER " %s"), tmp);
|
||||
ExecuteCommand(svalue);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
WebGetArg("t", tmp, sizeof(tmp));
|
||||
if (strlen(tmp)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_COLORTEMPERATURE " %s"), tmp);
|
||||
ExecuteCommand(svalue);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
WebGetArg("k", tmp, sizeof(tmp));
|
||||
if (strlen(tmp)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_RFKEY "%s"), tmp);
|
||||
ExecuteCommand(svalue);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{t}"));
|
||||
@ -1106,6 +1122,7 @@ void HandleSaveSettings()
|
||||
}
|
||||
ShowPage(page);
|
||||
|
||||
ShowWebSource(SRC_WEBGUI);
|
||||
restart_flag = 2;
|
||||
} else {
|
||||
HandleConfiguration();
|
||||
@ -1129,7 +1146,7 @@ void HandleResetConfiguration()
|
||||
ShowPage(page);
|
||||
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_RESET " 1"));
|
||||
ExecuteCommand(svalue);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
|
||||
void HandleRestoreConfiguration()
|
||||
@ -1181,7 +1198,7 @@ void HandleUpgradeFirmwareStart()
|
||||
WebGetArg("o", tmp, sizeof(tmp));
|
||||
if (strlen(tmp)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_OTAURL " %s"), tmp);
|
||||
ExecuteCommand(svalue);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
@ -1193,7 +1210,7 @@ void HandleUpgradeFirmwareStart()
|
||||
ShowPage(page);
|
||||
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_UPGRADE " 1"));
|
||||
ExecuteCommand(svalue);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
|
||||
void HandleUploadDone()
|
||||
@ -1233,6 +1250,8 @@ void HandleUploadDone()
|
||||
} else {
|
||||
page += F("green'>" D_SUCCESSFUL "</font></b><br/>");
|
||||
page += FPSTR(HTTP_MSG_RSTRT);
|
||||
|
||||
ShowWebSource(SRC_WEBGUI);
|
||||
restart_flag = 2;
|
||||
}
|
||||
SettingsBufferFree();
|
||||
@ -1381,16 +1400,16 @@ void HandleHttpCommand()
|
||||
WebGetArg("user", tmp1, sizeof(tmp1));
|
||||
char tmp2[100];
|
||||
WebGetArg("password", tmp2, sizeof(tmp2));
|
||||
if (!(!strcmp(tmp1, WEB_USERNAME) && !strcmp(tmp2, Settings.web_password))) {
|
||||
valid = 0;
|
||||
}
|
||||
if (!(!strcmp(tmp1, WEB_USERNAME) && !strcmp(tmp2, Settings.web_password))) { valid = 0; }
|
||||
}
|
||||
|
||||
String message = F("{\"" D_RSLT_WARNING "\":\"");
|
||||
if (valid) {
|
||||
byte curridx = web_log_index;
|
||||
WebGetArg("cmnd", svalue, sizeof(svalue));
|
||||
if (strlen(svalue)) { ExecuteCommand(svalue); }
|
||||
if (strlen(svalue)) {
|
||||
ExecuteWebCommand(svalue, SRC_WEBCOMMAND);
|
||||
}
|
||||
|
||||
if (web_log_index != curridx) {
|
||||
byte counter = curridx;
|
||||
@ -1449,7 +1468,7 @@ void HandleAjaxConsoleRefresh()
|
||||
if (strlen(svalue)) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_COMMAND "%s"), svalue);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
ExecuteCommand(svalue);
|
||||
ExecuteWebCommand(svalue, SRC_WEBCONSOLE);
|
||||
}
|
||||
|
||||
WebGetArg("c2", svalue, sizeof(svalue));
|
||||
@ -1624,6 +1643,7 @@ void HandleRestart()
|
||||
}
|
||||
ShowPage(page);
|
||||
|
||||
ShowWebSource(SRC_WEBGUI);
|
||||
restart_flag = 2;
|
||||
}
|
||||
|
||||
|
@ -726,7 +726,7 @@ void EnergyMarginCheck()
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_MAXPOWERREACHED "\":\"%d%s\"}"), energy_power_u, (Settings.flag.value_units) ? " " D_UNIT_WATT : "");
|
||||
MqttPublishPrefixTopic_P(STAT, S_RSLT_WARNING);
|
||||
EnergyMqttShow();
|
||||
ExecuteCommandPower(1, POWER_OFF);
|
||||
ExecuteCommandPower(1, POWER_OFF, SRC_MAXPOWER);
|
||||
if (!energy_mplr_counter) {
|
||||
energy_mplr_counter = Settings.param[P_MAX_POWER_RETRY] +1;
|
||||
}
|
||||
@ -748,7 +748,7 @@ void EnergyMarginCheck()
|
||||
if (energy_mplr_counter) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_POWERMONITOR "\":\"%s\"}"), GetStateText(1));
|
||||
MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_JSON_POWERMONITOR));
|
||||
ExecuteCommandPower(1, POWER_ON);
|
||||
ExecuteCommandPower(1, POWER_ON, SRC_MAXPOWER);
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_MAXPOWERREACHEDRETRY "\":\"%s\"}"), GetStateText(0));
|
||||
MqttPublishPrefixTopic_P(STAT, S_RSLT_WARNING);
|
||||
@ -766,7 +766,7 @@ void EnergyMarginCheck()
|
||||
energy_max_energy_state = 1;
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_ENERGYMONITOR "\":\"%s\"}"), GetStateText(1));
|
||||
MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_JSON_ENERGYMONITOR));
|
||||
ExecuteCommandPower(1, POWER_ON);
|
||||
ExecuteCommandPower(1, POWER_ON, SRC_MAXENERGY);
|
||||
}
|
||||
else if ((1 == energy_max_energy_state) && (energy_daily_u >= Settings.energy_max_energy)) {
|
||||
energy_max_energy_state = 2;
|
||||
@ -774,7 +774,7 @@ void EnergyMarginCheck()
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_MAXENERGYREACHED "\":\"%s%s\"}"), mqtt_data, (Settings.flag.value_units) ? " " D_UNIT_KILOWATTHOUR : "");
|
||||
MqttPublishPrefixTopic_P(STAT, S_RSLT_WARNING);
|
||||
EnergyMqttShow();
|
||||
ExecuteCommandPower(1, POWER_OFF);
|
||||
ExecuteCommandPower(1, POWER_OFF, SRC_MAXENERGY);
|
||||
}
|
||||
}
|
||||
#endif // FEATURE_POWER_LIMIT
|
||||
|
@ -230,7 +230,7 @@ void AriluxRfHandler()
|
||||
}
|
||||
}
|
||||
if (strlen(command)) {
|
||||
ExecuteCommand(command);
|
||||
ExecuteCommand(command, SRC_LIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -529,7 +529,7 @@ char* LightGetColor(uint8_t type, char* scolor)
|
||||
void LightPowerOn()
|
||||
{
|
||||
if (Settings.light_dimmer && !(light_power)) {
|
||||
ExecuteCommandPower(light_device, POWER_ON);
|
||||
ExecuteCommandPower(light_device, POWER_ON, SRC_LIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -585,11 +585,11 @@ void LightPreparePower()
|
||||
{
|
||||
if (Settings.light_dimmer && !(light_power)) {
|
||||
if (!Settings.flag.not_power_linked) {
|
||||
ExecuteCommandPower(light_device, POWER_ON_NO_STATE);
|
||||
ExecuteCommandPower(light_device, POWER_ON_NO_STATE, SRC_LIGHT);
|
||||
}
|
||||
}
|
||||
else if (!Settings.light_dimmer && light_power) {
|
||||
ExecuteCommandPower(light_device, POWER_OFF_NO_STATE);
|
||||
ExecuteCommandPower(light_device, POWER_OFF_NO_STATE, SRC_LIGHT);
|
||||
}
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzUpdatePowerState(light_device);
|
||||
|
@ -290,7 +290,7 @@ void TimerEverySecond()
|
||||
XdrvRulesProcess();
|
||||
} else
|
||||
#endif // USE_RULES
|
||||
if (devices_present) { ExecuteCommandPower(xtimer.device +1, xtimer.power); }
|
||||
if (devices_present) { ExecuteCommandPower(xtimer.device +1, xtimer.power, SRC_TIMER); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ bool RuleSetProcess(byte rule_set, String &event_saved)
|
||||
// snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, D_CMND_RULE, D_JSON_INITIATED);
|
||||
// MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_CMND_RULE));
|
||||
|
||||
ExecuteCommand(command);
|
||||
ExecuteCommand(command, SRC_RULE);
|
||||
serviced = true;
|
||||
}
|
||||
rules_trigger_count[rule_set]++;
|
||||
|
@ -494,12 +494,12 @@ void KNX_CB_Action(message_t const &msg, void *arg)
|
||||
case KNX_CT_WRITE:
|
||||
if (chan->type < 9) // Set Relays
|
||||
{
|
||||
ExecuteCommandPower(chan->type, msg.data[0]);
|
||||
ExecuteCommandPower(chan->type, msg.data[0], SRC_KNX);
|
||||
}
|
||||
else if (chan->type < 17) // Toggle Relays
|
||||
{
|
||||
if (!toggle_inhibit) {
|
||||
ExecuteCommandPower((chan->type) -8, 2);
|
||||
ExecuteCommandPower((chan->type) -8, 2, SRC_KNX);
|
||||
if (Settings.flag.knx_enable_enhancement) {
|
||||
toggle_inhibit = TOGGLE_INHIBIT_TIME;
|
||||
}
|
||||
|
@ -387,10 +387,10 @@ void HandleUpnpEvent()
|
||||
//differentiate get and set state
|
||||
if (request.indexOf(F("SetBinaryState")) > 0) {
|
||||
if (request.indexOf(F("State>1</Binary")) > 0) {
|
||||
ExecuteCommandPower(devices_present, POWER_ON);
|
||||
ExecuteCommandPower(devices_present, POWER_ON, SRC_WEMO);
|
||||
}
|
||||
else if (request.indexOf(F("State>0</Binary")) > 0) {
|
||||
ExecuteCommandPower(devices_present, POWER_OFF);
|
||||
ExecuteCommandPower(devices_present, POWER_OFF, SRC_WEMO);
|
||||
}
|
||||
}
|
||||
else if(request.indexOf(F("GetBinaryState")) > 0){
|
||||
@ -660,10 +660,10 @@ void HueLights(String *path)
|
||||
on = hue_json["on"];
|
||||
switch(on)
|
||||
{
|
||||
case false : ExecuteCommandPower(device, POWER_OFF);
|
||||
case false : ExecuteCommandPower(device, POWER_OFF, SRC_HUE);
|
||||
response.replace("{re", "false");
|
||||
break;
|
||||
case true : ExecuteCommandPower(device, POWER_ON);
|
||||
case true : ExecuteCommandPower(device, POWER_ON, SRC_HUE);
|
||||
response.replace("{re", "true");
|
||||
break;
|
||||
default : response.replace("{re", (power & (1 << (device-1))) ? "true" : "false");
|
||||
|
Loading…
x
Reference in New Issue
Block a user