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