mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
Push 0.0.7
This commit is contained in:
parent
a7e8484815
commit
95aa10aa4f
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#define HASP_VERSION_MAJOR 0
|
#define HASP_VERSION_MAJOR 0
|
||||||
#define HASP_VERSION_MINOR 0
|
#define HASP_VERSION_MINOR 0
|
||||||
#define HASP_VERSION_REVISION 6
|
#define HASP_VERSION_REVISION 7
|
||||||
|
|
||||||
#define HASP_USE_APP 1
|
#define HASP_USE_APP 1
|
||||||
|
|
||||||
|
@ -71,35 +71,25 @@ void IRAM_ATTR dispatchCommand(String cmnd)
|
|||||||
if(cmnd.startsWith(F("page ")) || cmnd.startsWith(F("page="))) {
|
if(cmnd.startsWith(F("page ")) || cmnd.startsWith(F("page="))) {
|
||||||
cmnd = cmnd.substring(5, cmnd.length());
|
cmnd = cmnd.substring(5, cmnd.length());
|
||||||
dispatchPage(cmnd);
|
dispatchPage(cmnd);
|
||||||
return;
|
} else if(cmnd == F("calibrate")) {
|
||||||
}
|
|
||||||
|
|
||||||
if(cmnd == F("calibrate")) {
|
|
||||||
guiCalibrate();
|
guiCalibrate();
|
||||||
return;
|
} else if(cmnd == F("wakeup")) {
|
||||||
}
|
haspWakeUp();
|
||||||
|
} else if(cmnd == F("screenshot")) {
|
||||||
if(cmnd == F("screenshot")) {
|
|
||||||
guiTakeScreenshot("/screenhot.bmp");
|
guiTakeScreenshot("/screenhot.bmp");
|
||||||
return;
|
} else if(cmnd == F("reboot") || cmnd == F("restart")) {
|
||||||
}
|
|
||||||
|
|
||||||
if(cmnd == F("reboot") || cmnd == F("restart")) {
|
|
||||||
dispatchReboot(true);
|
dispatchReboot(true);
|
||||||
return;
|
} else if(cmnd == "" || cmnd == F("statusupdate")) {
|
||||||
}
|
|
||||||
|
|
||||||
if(cmnd == "" || cmnd == F("statusupdate")) {
|
|
||||||
mqttStatusUpdate();
|
mqttStatusUpdate();
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
int pos = cmnd.indexOf("=");
|
int pos = cmnd.indexOf("=");
|
||||||
if(pos > 0) {
|
if(pos > 0) {
|
||||||
String strTopic = cmnd.substring(0, pos);
|
String strTopic = cmnd.substring(0, pos);
|
||||||
String strPayload = cmnd.substring(pos + 1, cmnd.length());
|
String strPayload = cmnd.substring(pos + 1, cmnd.length());
|
||||||
// debugPrintln("CMND: '" + strTopic + "'='" + strPayload + "'");
|
// debugPrintln("CMND: '" + strTopic + "'='" + strPayload + "'");
|
||||||
dispatchAttribute(strTopic, strPayload.c_str());
|
dispatchAttribute(strTopic, strPayload.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,9 @@ const String mqttLightBrightSubscription = "hasp/" + String(haspGetNodename())
|
|||||||
WiFiClient wifiClient;
|
WiFiClient wifiClient;
|
||||||
PubSubClient mqttClient(wifiClient);
|
PubSubClient mqttClient(wifiClient);
|
||||||
|
|
||||||
|
static char mqttTopic[127];
|
||||||
|
static char mqttPayload[254];
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Send changed values OUT
|
// Send changed values OUT
|
||||||
|
|
||||||
@ -88,18 +91,15 @@ void IRAM_ATTR mqttSendState(const char * subtopic, const char * payload)
|
|||||||
// light = 0/1
|
// light = 0/1
|
||||||
// brightness = 100
|
// brightness = 100
|
||||||
|
|
||||||
char topic[127];
|
snprintf_P(mqttTopic, sizeof(mqttTopic), PSTR("%sstate/%s"), mqttNodeTopic.c_str(), subtopic);
|
||||||
char value[254];
|
mqttClient.publish(mqttTopic, payload);
|
||||||
|
debugPrintln(String(F("MQTT OUT: ")) + String(mqttTopic) + " = " + String(payload));
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("%sstate/%s"), mqttNodeTopic.c_str(), subtopic);
|
|
||||||
mqttClient.publish(topic, payload);
|
|
||||||
debugPrintln(String(F("MQTT OUT: ")) + String(topic) + " = " + String(payload));
|
|
||||||
|
|
||||||
// as json
|
// as json
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("%sstate/json"), mqttNodeTopic.c_str());
|
snprintf_P(mqttTopic, sizeof(mqttTopic), PSTR("%sstate/json"), mqttNodeTopic.c_str());
|
||||||
snprintf_P(value, sizeof(value), PSTR("{\"%s\":\"%s\"}"), subtopic, payload);
|
snprintf_P(mqttPayload, sizeof(mqttPayload), PSTR("{\"%s\":\"%s\"}"), subtopic, payload);
|
||||||
mqttClient.publish(topic, value);
|
mqttClient.publish(mqttTopic, mqttPayload);
|
||||||
debugPrintln(String(F("MQTT OUT: ")) + String(topic) + " = " + String(value));
|
debugPrintln(String(F("MQTT OUT: ")) + String(mqttTopic) + " = " + String(mqttPayload));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR mqttSendNewValue(uint8_t pageid, uint8_t btnid, const char * attribute, String txt)
|
void IRAM_ATTR mqttSendNewValue(uint8_t pageid, uint8_t btnid, const char * attribute, String txt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user