Skip to content

Commit

Permalink
ha: handle homeassistant/status
Browse files Browse the repository at this point in the history
birth message should trigger discovery, enabled by default
ref. #1637

clean-up discovery code to properly re-init when something goes wrong
also restore manual discovery trigger from WebUI
  • Loading branch information
mcspr committed Mar 19, 2024
1 parent e9ab0a8 commit 452cd78
Show file tree
Hide file tree
Showing 5 changed files with 350 additions and 117 deletions.
14 changes: 13 additions & 1 deletion code/espurna/config/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,10 @@
#endif

#ifndef HOMEASSISTANT_ENABLED
#define HOMEASSISTANT_ENABLED 0 // Integration not enabled by default
#define HOMEASSISTANT_ENABLED 0 // Enable automatic discovery messages when
// - if BIRTH topic is empty, when device connects
// - if BIRTH topic is not empty, when device receives specified BIRTH PAYLOAD
// (disabled by default, only manually triggered messages work)
#endif

#ifndef HOMEASSISTANT_PREFIX
Expand All @@ -1263,6 +1266,15 @@
#define HOMEASSISTANT_RETAIN MQTT_RETAIN // Make broker retain the messages
#endif

#ifndef HOMEASSISTANT_BIRTH_TOPIC
#define HOMEASSISTANT_BIRTH_TOPIC "" // HA instance 'birth' message topic
// If not empty, discovery is sent ONLY when the exact PAYLOAD message is received by the device
#endif

#ifndef HOMEASSISTANT_BIRTH_PAYLOAD
#define HOMEASSISTANT_BIRTH_PAYLOAD "online" // Payload for the 'birth' message from HA
#endif

// -----------------------------------------------------------------------------
// INFLUXDB
// -----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 452cd78

Please sign in to comment.