Skip to content

Commit

Permalink
fix(home-assistant): retain availability messages
Browse files Browse the repository at this point in the history
Without the retain flag Home Assistant will mark the devices as
unavailable on restart, see #102.
  • Loading branch information
mKeRix committed Jan 27, 2020
1 parent cbea490 commit 3093154
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/integrations/home-assistant/home-assistant.service.ts
Expand Up @@ -71,7 +71,11 @@ export class HomeAssistantService
if (config.device.identifiers !== 'room-assistant-distributed') {
this.mqttClient.publish(
config.availabilityTopic,
config.payloadNotAvailable
config.payloadNotAvailable,
{
qos: 0,
retain: true
}
);
}
});
Expand Down Expand Up @@ -112,7 +116,10 @@ export class HomeAssistantService
retain: true
}
);
this.mqttClient.publish(config.availabilityTopic, config.payloadAvailable);
this.mqttClient.publish(config.availabilityTopic, config.payloadAvailable, {
qos: 0,
retain: true
});
}

handleNewState(
Expand Down

0 comments on commit 3093154

Please sign in to comment.