diff --git a/src/user_code.cpp b/src/user_code.cpp index c719717..f1fc3a8 100644 --- a/src/user_code.cpp +++ b/src/user_code.cpp @@ -63,7 +63,6 @@ void user_init() elcd.print("dashboard.pic="); elcd.print(ac_lock ? "2" : "1"); elcd_sendstop(); - mqtt.subscribe(AC_LOCK_TOPIC, ac_lock_callback); lt_bt.attachPop(lt_btn_cb, <_bt); fan_bt.attachPop(fan_btn_cb, &fan_bt); puri_bt.attachPop(puri_btn_cb, &puri_bt); @@ -292,4 +291,9 @@ void pwm_update_lcd() { elcd.print("puri_bt.pic="); elcd.print(pwm_get_state(AIR_PURIFIER_PIN)?8:7); elcd_sendstop(); +} + +void mqtt_connected_user_callback() { + mqtt.subscribe(AC_LOCK_TOPIC, ac_lock_callback); + ac_lock_report(); } \ No newline at end of file diff --git a/src/user_code.hpp b/src/user_code.hpp index db96e76..201ed80 100644 --- a/src/user_code.hpp +++ b/src/user_code.hpp @@ -70,6 +70,7 @@ void ac_lock_callback(String topic, String payload); void elcd_sendstop(); void ac_update_lcd(); void pwm_update_lcd(); +void mqtt_connected_user_callback(); // ESPMega IoT Core Build-in Functions extern void pwm_set_state(int id, int state);