mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +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());
|
||||
dispatchPrintln(F("DIM"), strDimLevel);
|
||||
char buffer[8];
|
||||
|
||||
#if HASP_USE_MQTT > 0
|
||||
#if defined(HASP_USE_MQTT) || defined(HASP_USE_TASMOTA_SLAVE)
|
||||
itoa(guiGetDim(), buffer, DEC);
|
||||
#if HASP_USE_MQTT > 0
|
||||
mqtt_send_state(F("dim"), buffer);
|
||||
#endif
|
||||
#if HASP_USE_TASMOTA_SLAVE > 0
|
||||
itoa(guiGetDim(), buffer, DEC);
|
||||
slave_send_state(F("dim"), buffer);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void dispatchBacklight(String strPayload)
|
||||
@ -276,12 +276,15 @@ void dispatchJsonl(char * payload)
|
||||
|
||||
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
|
||||
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);
|
||||
#else
|
||||
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)
|
||||
{
|
||||
#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
|
||||
mqtt_send_input(id, event);
|
||||
#else
|
||||
Log.notice(F("OUT: input%d = %s"), id, event);
|
||||
#endif
|
||||
#if HASP_USE_TASMOTA_SLAVE>0
|
||||
slave_send_input(id, event);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
#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
|
||||
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);
|
||||
#else
|
||||
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) {
|
||||
settings.remove(F("pass")); // hide password in output
|
||||
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
|
||||
mqtt_send_state(F("config"), buffer);
|
||||
#elif HASP_USE_TASMOTA > 0
|
||||
#endif
|
||||
#if HASP_USE_TASMOTA > 0
|
||||
slave_send_state(F("config"), buffer);
|
||||
#else
|
||||
Log.notice(F("OUT: config %s = %s"),topic,buffer);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user