add lock state reporting

This commit is contained in:
Siwat Sirichai 2023-10-03 02:21:27 +07:00
parent 1e8e5664a2
commit b06f65c0fc
2 changed files with 6 additions and 1 deletions

View File

@ -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, &lt_bt);
fan_bt.attachPop(fan_btn_cb, &fan_bt);
puri_bt.attachPop(puri_btn_cb, &puri_bt);
@ -293,3 +292,8 @@ void pwm_update_lcd() {
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();
}

View File

@ -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);