Skip to content

Commit

Permalink
Retain discovery message
Browse files Browse the repository at this point in the history
  • Loading branch information
DoomHammer committed Jun 13, 2024
1 parent 9748a1e commit 85df453
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/odessa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,14 @@ void sendHassDiscoveryMessage() {
doc["device_class"] = "switch";
doc["state_topic"] = switchStateTopic;
doc["command_topic"] = switchSetTopic;
doc["availability_topic"] = availabilityTopic;
doc["device"]["name"] = "Tramwajomat";
doc["unique_id"] = client_id;

serializeJson(doc, serialized_json);

client.publish(homeassistant_discovery_topic, serialized_json);
client.publish(homeassistant_discovery_topic, (const uint8_t*)serialized_json, strlen(serialized_json), true);
client.publish(availabilityTopic, "online");
}

void sendGratuitiousMessages() {
Expand Down
1 change: 1 addition & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ const char *MQTT_PASSWORD = "password";
const char *feedTopic = "feed/public_transport";
const char *switchSetTopic = "area/room/odessa/switch/set";
const char *switchStateTopic = "homeassistant/switch/odessa/state";
const char *availabilityTopic = "homeassistant/switch/odessa/available";
const char *client_id = "odessa";

0 comments on commit 85df453

Please sign in to comment.