mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 21:26:43 +00:00
Check object already exists
This commit is contained in:
parent
c0f6d7b02e
commit
8e90420d54
@ -1432,7 +1432,12 @@ void haspNewObject(const JsonObject & config)
|
|||||||
uint8_t styleid = config[F("styleid")].as<uint8_t>();
|
uint8_t styleid = config[F("styleid")].as<uint8_t>();
|
||||||
|
|
||||||
/* Define Objects*/
|
/* Define Objects*/
|
||||||
lv_obj_t * obj;
|
lv_obj_t * obj = FindObjFromId(parent_obj, id);
|
||||||
|
if(obj) {
|
||||||
|
warningPrintln(F("HASP: %sObject ID already exists!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
lv_obj_t * label;
|
lv_obj_t * label;
|
||||||
switch(objid) {
|
switch(objid) {
|
||||||
/* ----- Basic Objects ------ */
|
/* ----- Basic Objects ------ */
|
||||||
@ -1613,7 +1618,7 @@ void haspNewObject(const JsonObject & config)
|
|||||||
char msg[127];
|
char msg[127];
|
||||||
lv_obj_type_t list;
|
lv_obj_type_t list;
|
||||||
lv_obj_get_type(obj, &list);
|
lv_obj_get_type(obj, &list);
|
||||||
sprintf_P(msg, PSTR("HASP: * Created %s object p[%u].b[%u]"), list.type[0], pageid, temp);
|
sprintf_P(msg, PSTR("HASP: * p[%u].b[%u] = %s"), pageid, temp, list.type[0]);
|
||||||
debugPrintln(msg);
|
debugPrintln(msg);
|
||||||
|
|
||||||
/* Double-check */
|
/* Double-check */
|
||||||
|
@ -64,7 +64,9 @@ void dispatchAttribute(String & strTopic, const char * payload)
|
|||||||
}
|
}
|
||||||
} else if(strTopic.startsWith(F("output"))) {
|
} else if(strTopic.startsWith(F("output"))) {
|
||||||
uint8_t state = strcmp_P(payload, PSTR("ON")) == 0 ? HIGH : LOW;
|
uint8_t state = strcmp_P(payload, PSTR("ON")) == 0 ? HIGH : LOW;
|
||||||
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
digitalWrite(D1, state);
|
digitalWrite(D1, state);
|
||||||
|
#endif
|
||||||
|
|
||||||
} else if(strTopic == F("page")) {
|
} else if(strTopic == F("page")) {
|
||||||
dispatchPage(payload);
|
dispatchPage(payload);
|
||||||
@ -78,6 +80,9 @@ void dispatchAttribute(String & strTopic, const char * payload)
|
|||||||
} else if(strTopic == F("clearpage")) {
|
} else if(strTopic == F("clearpage")) {
|
||||||
dispatchClearPage(payload);
|
dispatchClearPage(payload);
|
||||||
|
|
||||||
|
} else if(strTopic == F("setupap")) {
|
||||||
|
haspDisplayAP(String(F("HASP-ABC123")).c_str(), String(F("haspadmin")).c_str());
|
||||||
|
|
||||||
} else if(strTopic.length() == 7 && strTopic.startsWith(F("output"))) {
|
} else if(strTopic.length() == 7 && strTopic.startsWith(F("output"))) {
|
||||||
String strTemp((char *)0);
|
String strTemp((char *)0);
|
||||||
strTemp = strTopic.substring(7, strTopic.length());
|
strTemp = strTopic.substring(7, strTopic.length());
|
||||||
|
@ -238,8 +238,6 @@ void mqttCallback(char * topic, byte * payload, unsigned int length)
|
|||||||
dispatchJson((char *)payload); // Send to nextionParseJson()
|
dispatchJson((char *)payload); // Send to nextionParseJson()
|
||||||
} else if(strTopic == F("jsonl")) {
|
} else if(strTopic == F("jsonl")) {
|
||||||
dispatchJsonl((char *)payload);
|
dispatchJsonl((char *)payload);
|
||||||
} else if(strTopic == F("setupap")) {
|
|
||||||
haspDisplayAP("HASP-ABC123", "haspadmin");
|
|
||||||
} else if(length == 0) {
|
} else if(length == 0) {
|
||||||
dispatchCommand(strTopic.c_str());
|
dispatchCommand(strTopic.c_str());
|
||||||
} else { // '[...]/device/command/p[1].b[4].txt' -m '"Lights On"' ==
|
} else { // '[...]/device/command/p[1].b[4].txt' -m '"Lights On"' ==
|
||||||
|
Loading…
x
Reference in New Issue
Block a user