Skip to content

Commit

Permalink
fix(home-assistant): retain state updates
Browse files Browse the repository at this point in the history
The state is now retained on MQTT, so that Home Assistant can pick up a
state even after restarting.
  • Loading branch information
mKeRix committed Jan 31, 2020
1 parent fadd9be commit 382deed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Expand Up @@ -240,7 +240,11 @@ describe('HomeAssistantService', () => {

expect(mockMqttClient.publish).toHaveBeenCalledWith(
'room-assistant/sensor/test-instance-test/state',
'2'
'2',
{
qos: 0,
retain: true
}
);
});

Expand Down
5 changes: 4 additions & 1 deletion src/integrations/home-assistant/home-assistant.service.ts
Expand Up @@ -149,7 +149,10 @@ export class HomeAssistantService
return;
}

this.mqttClient.publish(config.stateTopic, String(state));
this.mqttClient.publish(config.stateTopic, String(state), {
qos: 0,
retain: true
});
}

/**
Expand Down

0 comments on commit 382deed

Please sign in to comment.