mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
Changes for HA
This commit is contained in:
parent
6a24cd39c1
commit
eb3d3ba9b9
@ -231,9 +231,12 @@ void webHandleRoot()
|
|||||||
httpMessage += httpGetNodename();
|
httpMessage += httpGetNodename();
|
||||||
httpMessage += F("</h1><hr>");
|
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 +=
|
httpMessage +=
|
||||||
F("<p><form method='get' action='screenshot'><button type='submit'>Screenshot</button></form></p>");
|
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 +=
|
httpMessage +=
|
||||||
F("<p><form method='get' action='config'><button type='submit'>Configuration</button></form></p>");
|
F("<p><form method='get' action='config'><button type='submit'>Configuration</button></form></p>");
|
||||||
|
|
||||||
@ -972,8 +975,9 @@ void webHandleConfig()
|
|||||||
httpMessage +=
|
httpMessage +=
|
||||||
F("<p><form method='get' action='/config/gui'><button type='submit'>Display Settings</button></form></p>");
|
F("<p><form method='get' action='/config/gui'><button type='submit'>Display Settings</button></form></p>");
|
||||||
|
|
||||||
httpMessage +=
|
// httpMessage +=
|
||||||
F("<p><form method='get' action='/config/hasp'><button type='submit'>HASP Settings</button></form></p>");
|
// F("<p><form method='get' action='/config/hasp'><button type='submit'>HASP
|
||||||
|
// Settings</button></form></p>");
|
||||||
|
|
||||||
#if HASP_USE_GPIO > 0
|
#if HASP_USE_GPIO > 0
|
||||||
httpMessage +=
|
httpMessage +=
|
||||||
|
@ -56,7 +56,8 @@ String mqttCommandTopic; // MQTT topic for incoming panel commands
|
|||||||
// String mqttGroupTopic((char *)0);
|
// String mqttGroupTopic((char *)0);
|
||||||
char mqttNodeTopic[24];
|
char mqttNodeTopic[24];
|
||||||
char mqttGroupTopic[24];
|
char mqttGroupTopic[24];
|
||||||
bool mqttEnabled;
|
bool mqttEnabled = false;
|
||||||
|
bool mqttHAautodiscover = false;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// These defaults may be overwritten with values saved by the web interface
|
// 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);
|
// data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mqtt_ha_send_config()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Receive incoming messages
|
// Receive incoming messages
|
||||||
static void mqtt_message_cb(char * topic, byte * payload, unsigned int length)
|
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);
|
dispatch_topic_payload(topic, (const char *)payload);
|
||||||
return;
|
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 {
|
} else {
|
||||||
// Other topic
|
// Other topic
|
||||||
Log.error(TAG_MQTT, F("Message received with invalid topic"));
|
Log.error(TAG_MQTT, F("Message received with invalid topic"));
|
||||||
@ -332,6 +344,9 @@ void mqttStart()
|
|||||||
mqttSubscribeTo(PSTR("%sbrightness/#"), mqttNodeTopic);
|
mqttSubscribeTo(PSTR("%sbrightness/#"), mqttNodeTopic);
|
||||||
mqttSubscribeTo(PSTR("%sLWT"), 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
|
// 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,
|
// make sure we get a full panel refresh at power on. Sending offline,
|
||||||
// "online" will be sent by the mqttStatusTopic subscription action.
|
// "online" will be sent by the mqttStatusTopic subscription action.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user