mirror of https://github.com/sfeakes/AqualinkD.git
Add service mode check
parent
be9af7abe7
commit
0be571f346
|
@ -9,6 +9,8 @@
|
|||
//#define POOL_SETPT_TOPIC "Pool_Heater/setpoint"
|
||||
//#define SPA_SETPT_TOPIC "Spa_Heater/setpoint"
|
||||
|
||||
#define SERVICE_MODE_TOPIC "Service_Mode"
|
||||
|
||||
#define ENABELED_SUBT "/enabled"
|
||||
|
||||
#define SWG_TOPIC "SWG"
|
||||
|
|
|
@ -95,6 +95,7 @@ struct aqualinkdata
|
|||
unsigned char ar_swg_status;
|
||||
int swg_delayed_percent;
|
||||
bool simulate_panel;
|
||||
aqledstate service_mode_state;
|
||||
aqledstate frz_protect_state;
|
||||
//bool last_msg_was_status;
|
||||
//bool ar_swg_connected;
|
||||
|
|
14
aqualinkd.c
14
aqualinkd.c
|
@ -195,6 +195,7 @@ void processMessage(char *message)
|
|||
static bool _initWithRS = false;
|
||||
static bool _gotREV = false;
|
||||
static int freeze_msg_count = 0;
|
||||
static int service_msg_count = 0;
|
||||
// NSF replace message with msg
|
||||
msg = stripwhitespace(message);
|
||||
strcpy(_aqualink_data.last_message, msg);
|
||||
|
@ -215,6 +216,12 @@ void processMessage(char *message)
|
|||
_aqualink_data.last_display_message[0] = '\0';
|
||||
}
|
||||
|
||||
// If we have more than 10 messages without "Service Mode is active" assume it's off.
|
||||
if (_aqualink_data.service_mode_state == ON && service_msg_count++ > 10) {
|
||||
_aqualink_data.service_mode_state = OFF;
|
||||
service_msg_count = 0;
|
||||
}
|
||||
|
||||
// If we have more than 10 messages without "FREE PROTECT ACTIVATED" assume it's off.
|
||||
if (_aqualink_data.frz_protect_state == ON && freeze_msg_count++ > 10) {
|
||||
_aqualink_data.frz_protect_state = ENABLE;
|
||||
|
@ -302,6 +309,12 @@ void processMessage(char *message)
|
|||
logMessage(LOG_NOTICE, "AqualinkD set to 'Pool OR Spa Only' mode\n");
|
||||
}
|
||||
}
|
||||
else if (stristr(msg, LNG_MSG_SERVICE_ACTIVE) != NULL) {
|
||||
if (_aqualink_data.service_mode_state == OFF)
|
||||
logMessage(LOG_NOTICE, "AqualinkD set to Service Mode\n");
|
||||
_aqualink_data.service_mode_state = ON;
|
||||
service_msg_count = 0;
|
||||
}
|
||||
else if (stristr(msg, LNG_MSG_FREEZE_PROTECTION_ACTIVATED) != NULL) {
|
||||
_aqualink_data.frz_protect_state = ON;
|
||||
freeze_msg_count = 0;
|
||||
|
@ -925,6 +938,7 @@ void main_loop() {
|
|||
_aqualink_data.swg_delayed_percent = TEMP_UNKNOWN;
|
||||
_aqualink_data.temp_units = UNKNOWN;
|
||||
_aqualink_data.single_device = false;
|
||||
_aqualink_data.service_mode_state = OFF;
|
||||
_aqualink_data.frz_protect_state = OFF;
|
||||
_aqualink_data.battery = OK;
|
||||
|
||||
|
|
|
@ -186,6 +186,9 @@ void send_mqtt_state_msg(struct mg_connection *nc, char *dev_name, aqledstate st
|
|||
{
|
||||
static char mqtt_pub_topic[250];
|
||||
|
||||
sprintf(mqtt_pub_topic, "%s/%s/delay",_aqualink_config->mqtt_aq_topic, dev_name);
|
||||
send_mqtt(nc, mqtt_pub_topic, (state==FLASH?MQTT_ON:MQTT_OFF));
|
||||
|
||||
sprintf(mqtt_pub_topic, "%s/%s",_aqualink_config->mqtt_aq_topic, dev_name);
|
||||
send_mqtt(nc, mqtt_pub_topic, (state==OFF?MQTT_OFF:MQTT_ON));
|
||||
}
|
||||
|
@ -361,6 +364,11 @@ void mqtt_broadcast_aqualinkstate(struct mg_connection *nc)
|
|||
send_mqtt_setpoint_msg(nc, BTN_SPA_HTR, _aqualink_data->spa_htr_set_point);
|
||||
}
|
||||
|
||||
if (_aqualink_data->service_mode_state != _last_mqtt_aqualinkdata.service_mode_state) {
|
||||
_last_mqtt_aqualinkdata.service_mode_state = _aqualink_data->service_mode_state;
|
||||
send_mqtt_string_msg(nc, SERVICE_MODE_TOPIC, _aqualink_data->service_mode_state==ON?MQTT_ON:MQTT_OFF);
|
||||
}
|
||||
|
||||
if (_aqualink_data->frz_protect_set_point != TEMP_UNKNOWN && _aqualink_data->frz_protect_set_point != _last_mqtt_aqualinkdata.frz_protect_set_point) {
|
||||
_last_mqtt_aqualinkdata.frz_protect_set_point = _aqualink_data->frz_protect_set_point;
|
||||
send_mqtt_setpoint_msg(nc, FREEZE_PROTECT, _aqualink_data->frz_protect_set_point);
|
||||
|
|
Loading…
Reference in New Issue