mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
Changes for HA
This commit is contained in:
parent
6a24cd39c1
commit
eb3d3ba9b9
@ -231,9 +231,12 @@ void webHandleRoot()
|
||||
httpMessage += httpGetNodename();
|
||||
httpMessage += F("</h1><hr>");
|
||||
|
||||
httpMessage += F("<p><form method='get' action='info'><button type='submit'>Information</button></form></p>");
|
||||
httpMessage +=
|
||||
F("<p><form method='get' action='/config/hasp'><button type='submit'>HASP Design</button></form></p>");
|
||||
|
||||
httpMessage +=
|
||||
F("<p><form method='get' action='screenshot'><button type='submit'>Screenshot</button></form></p>");
|
||||
httpMessage += F("<p><form method='get' action='info'><button type='submit'>Information</button></form></p>");
|
||||
httpMessage +=
|
||||
F("<p><form method='get' action='config'><button type='submit'>Configuration</button></form></p>");
|
||||
|
||||
@ -972,8 +975,9 @@ void webHandleConfig()
|
||||
httpMessage +=
|
||||
F("<p><form method='get' action='/config/gui'><button type='submit'>Display Settings</button></form></p>");
|
||||
|
||||
httpMessage +=
|
||||
F("<p><form method='get' action='/config/hasp'><button type='submit'>HASP Settings</button></form></p>");
|
||||
// httpMessage +=
|
||||
// F("<p><form method='get' action='/config/hasp'><button type='submit'>HASP
|
||||
// Settings</button></form></p>");
|
||||
|
||||
#if HASP_USE_GPIO > 0
|
||||
httpMessage +=
|
||||
|
@ -56,7 +56,8 @@ String mqttCommandTopic; // MQTT topic for incoming panel commands
|
||||
// String mqttGroupTopic((char *)0);
|
||||
char mqttNodeTopic[24];
|
||||
char mqttGroupTopic[24];
|
||||
bool mqttEnabled;
|
||||
bool mqttEnabled = false;
|
||||
bool mqttHAautodiscover = false;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// These defaults may be overwritten with values saved by the web interface
|
||||
@ -173,6 +174,11 @@ void IRAM_ATTR mqtt_send_obj_attribute_str(uint8_t pageid, uint8_t btnid, const
|
||||
// data);
|
||||
}
|
||||
|
||||
void mqtt_ha_send_config()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Receive incoming messages
|
||||
static void mqtt_message_cb(char * topic, byte * payload, unsigned int length)
|
||||
@ -198,6 +204,12 @@ static void mqtt_message_cb(char * topic, byte * payload, unsigned int length)
|
||||
dispatch_topic_payload(topic, (const char *)payload);
|
||||
return;
|
||||
|
||||
} else if(mqttHAautodiscover && topic == strstr_P(topic, PSTR("homeassistant/status"))) { // HA discovery topic
|
||||
if(!strcasecmp_P((char *)payload, PSTR("online"))) {
|
||||
mqtt_ha_send_config();
|
||||
}
|
||||
return;
|
||||
|
||||
} else {
|
||||
// Other topic
|
||||
Log.error(TAG_MQTT, F("Message received with invalid topic"));
|
||||
@ -332,6 +344,9 @@ void mqttStart()
|
||||
mqttSubscribeTo(PSTR("%sbrightness/#"), mqttNodeTopic);
|
||||
mqttSubscribeTo(PSTR("%sLWT"), mqttNodeTopic);
|
||||
|
||||
/* Home Assistant auto-configuration */
|
||||
if(mqttHAautodiscover) mqttSubscribeTo(PSTR("homeassistant/status"), mqttClientId);
|
||||
|
||||
// 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,
|
||||
// "online" will be sent by the mqttStatusTopic subscription action.
|
||||
|
Loading…
x
Reference in New Issue
Block a user