mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
Add HASP_USE_HA
This commit is contained in:
parent
7dd98b263f
commit
d4f5bea65c
@ -148,12 +148,14 @@ static void mqtt_message_cb(char* topic, char* payload, unsigned int length)
|
||||
dispatch_mtx.unlock();
|
||||
return;
|
||||
|
||||
#ifdef HASP_USE_HA
|
||||
} else if(topic == strstr_P(topic, PSTR("homeassistant/status"))) { // HA discovery topic
|
||||
if(mqttHAautodiscover && !strcasecmp_P((char*)payload, PSTR("online"))) {
|
||||
dispatch_current_state();
|
||||
mqtt_ha_register_auto_discovery();
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
|
||||
} else {
|
||||
// Other topic
|
||||
|
@ -143,12 +143,14 @@ static void mqtt_message_cb(char* topic, char* payload, unsigned int length)
|
||||
dispatch_topic_payload(topic, (const char*)payload);
|
||||
return;
|
||||
|
||||
#ifdef HASP_USE_HA
|
||||
} else if(topic == strstr_P(topic, PSTR("homeassistant/status"))) { // HA discovery topic
|
||||
if(mqttHAautodiscover && !strcasecmp_P((char*)payload, PSTR("online"))) {
|
||||
dispatch_current_state();
|
||||
mqtt_ha_register_auto_discovery();
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
|
||||
} else {
|
||||
// Other topic
|
||||
@ -272,7 +274,9 @@ static void onConnect(void* context)
|
||||
mqtt_subscribe(mqtt_client, "hass/status");
|
||||
|
||||
/* Home Assistant auto-configuration */
|
||||
#ifdef HASP_USE_HA
|
||||
if(mqttHAautodiscover) mqtt_subscribe(mqtt_client, "homeassistant/status");
|
||||
#endif
|
||||
|
||||
mqttPublish(TOPIC LWT_TOPIC, "online", 6, false);
|
||||
|
||||
|
@ -167,12 +167,14 @@ static void mqtt_message_cb(char* topic, byte* payload, unsigned int length)
|
||||
dispatch_topic_payload(topic, (const char*)payload);
|
||||
return;
|
||||
|
||||
#ifdef HASP_USE_HA
|
||||
} else if(topic == strstr_P(topic, PSTR("homeassistant/status"))) { // HA discovery topic
|
||||
if(mqttHAautodiscover && !strcasecmp_P((char*)payload, PSTR("online"))) {
|
||||
mqtt_ha_register_auto_discovery(); // auto-discovery first
|
||||
dispatch_current_state(); // send the data
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
|
||||
} else {
|
||||
// Other topic
|
||||
@ -299,7 +301,9 @@ void mqttStart()
|
||||
mqttSubscribeTo(F("hass/status"), mqttClientId);
|
||||
|
||||
/* Home Assistant auto-configuration */
|
||||
#ifdef HASP_USE_HA
|
||||
if(mqttHAautodiscover) mqttSubscribeTo(F("homeassistant/status"), mqttClientId);
|
||||
#endif
|
||||
|
||||
// Force any subscribed clients to toggle offline/online when we first connect to
|
||||
// make sure we get a full panel refresh at power on. Sending offline,
|
||||
|
Loading…
x
Reference in New Issue
Block a user