mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 05:06:44 +00:00
Allow simultaneous use of MQTT and Tasmotaslave
This commit is contained in:
parent
4d905297cd
commit
10dd8fbce2
@ -162,15 +162,15 @@ void dispatchDim(String strDimLevel)
|
|||||||
if(strDimLevel.length() != 0) guiSetDim(strDimLevel.toInt());
|
if(strDimLevel.length() != 0) guiSetDim(strDimLevel.toInt());
|
||||||
dispatchPrintln(F("DIM"), strDimLevel);
|
dispatchPrintln(F("DIM"), strDimLevel);
|
||||||
char buffer[8];
|
char buffer[8];
|
||||||
|
#if defined(HASP_USE_MQTT) || defined(HASP_USE_TASMOTA_SLAVE)
|
||||||
#if HASP_USE_MQTT > 0
|
|
||||||
itoa(guiGetDim(), buffer, DEC);
|
itoa(guiGetDim(), buffer, DEC);
|
||||||
|
#if HASP_USE_MQTT > 0
|
||||||
mqtt_send_state(F("dim"), buffer);
|
mqtt_send_state(F("dim"), buffer);
|
||||||
#endif
|
#endif
|
||||||
#if HASP_USE_TASMOTA_SLAVE > 0
|
#if HASP_USE_TASMOTA_SLAVE > 0
|
||||||
itoa(guiGetDim(), buffer, DEC);
|
|
||||||
slave_send_state(F("dim"), buffer);
|
slave_send_state(F("dim"), buffer);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispatchBacklight(String strPayload)
|
void dispatchBacklight(String strPayload)
|
||||||
@ -276,12 +276,15 @@ void dispatchJsonl(char * payload)
|
|||||||
|
|
||||||
void dispatchIdle(const char * state)
|
void dispatchIdle(const char * state)
|
||||||
{
|
{
|
||||||
|
#if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE)
|
||||||
|
Log.notice(F("OUT: idle = %s"), state);
|
||||||
|
#else
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
mqtt_send_state(F("idle"), state);
|
mqtt_send_state(F("idle"), state);
|
||||||
#elif HASP_USE_TASMOTA_SLAVE > 0
|
#endif
|
||||||
|
#if HASP_USE_TASMOTA_SLAVE > 0
|
||||||
slave_send_state(F("idle"), state);
|
slave_send_state(F("idle"), state);
|
||||||
#else
|
#endif
|
||||||
Log.notice(F("OUT: idle = %s"), state);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,14 +306,16 @@ void dispatchReboot(bool saveConfig)
|
|||||||
|
|
||||||
void dispatch_button(uint8_t id, const char * event)
|
void dispatch_button(uint8_t id, const char * event)
|
||||||
{
|
{
|
||||||
|
#if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE)
|
||||||
|
Log.notice(F("OUT: input%d = %s"), id, event);
|
||||||
|
#else
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
mqtt_send_input(id, event);
|
mqtt_send_input(id, event);
|
||||||
#else
|
|
||||||
Log.notice(F("OUT: input%d = %s"), id, event);
|
|
||||||
#endif
|
#endif
|
||||||
#if HASP_USE_TASMOTA_SLAVE>0
|
#if HASP_USE_TASMOTA_SLAVE>0
|
||||||
slave_send_input(id, event);
|
slave_send_input(id, event);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispatchWebUpdate(const char * espOtaUrl)
|
void dispatchWebUpdate(const char * espOtaUrl)
|
||||||
@ -323,12 +328,15 @@ void dispatchWebUpdate(const char * espOtaUrl)
|
|||||||
|
|
||||||
void IRAM_ATTR dispatch_obj_attribute_str(uint8_t pageid, uint8_t btnid, const char * attribute, const char * data)
|
void IRAM_ATTR dispatch_obj_attribute_str(uint8_t pageid, uint8_t btnid, const char * attribute, const char * data)
|
||||||
{
|
{
|
||||||
|
#if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE)
|
||||||
|
Log.notice(F("OUT: json = {\"p[%u].b[%u].%s\":\"%s\"}"), pageid, btnid, attribute, data);
|
||||||
|
#else
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
mqtt_send_obj_attribute_str(pageid, btnid, attribute, data);
|
mqtt_send_obj_attribute_str(pageid, btnid, attribute, data);
|
||||||
#elif HASP_USE_TASMOTA_SLAVE > 0
|
#endif
|
||||||
|
#if HASP_USE_TASMOTA_SLAVE > 0
|
||||||
slave_send_obj_attribute_str(pageid, btnid, attribute, data);
|
slave_send_obj_attribute_str(pageid, btnid, attribute, data);
|
||||||
#else
|
#endif
|
||||||
Log.notice(F("OUT: json = {\"p[%u].b[%u].%s\":\"%s\"}"), pageid, btnid, attribute, data);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,12 +424,15 @@ void dispatchConfig(const char * topic, const char * payload)
|
|||||||
if(!update) {
|
if(!update) {
|
||||||
settings.remove(F("pass")); // hide password in output
|
settings.remove(F("pass")); // hide password in output
|
||||||
size_t size = serializeJson(doc, buffer, sizeof(buffer));
|
size_t size = serializeJson(doc, buffer, sizeof(buffer));
|
||||||
|
#if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE)
|
||||||
|
Log.notice(F("OUT: config %s = %s"),topic,buffer);
|
||||||
|
#else
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
mqtt_send_state(F("config"), buffer);
|
mqtt_send_state(F("config"), buffer);
|
||||||
#elif HASP_USE_TASMOTA > 0
|
#endif
|
||||||
|
#if HASP_USE_TASMOTA > 0
|
||||||
slave_send_state(F("config"), buffer);
|
slave_send_state(F("config"), buffer);
|
||||||
#else
|
#endif
|
||||||
Log.notice(F("OUT: config %s = %s"),topic,buffer);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user