Skip to content

Commit

Permalink
Formatting updates
Browse files Browse the repository at this point in the history
  • Loading branch information
BigThunderSR committed Apr 1, 2024
1 parent 99b7fc1 commit 3f2be8a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ logger.info('!-- Starting OnStar2MQTT Polling --!');
const sensorMessagePayload = mqttHA.createSensorMessageConfigPayload(sensor.name, sensor.component, sensor.icon);
logger.debug('Sensor Message Payload:', sensorMessagePayload);
client.publish(sensorMessagePayload.topic, JSON.stringify(sensorMessagePayload.payload), { retain: true });
}
}
logger.info(`Sensor Message Configs Published!`);
buttonConfigsPublished = 'true';
}
Expand Down
58 changes: 29 additions & 29 deletions test/mqtt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1406,36 +1406,36 @@ describe('MQTT', () => {
assert.deepStrictEqual(result, expected);
});

it('should create sensor message config payload when component is provided', () => {
const sensor = 'oil_life';
const component = undefined;
const icon = 'testIcon';
const expected = {
topic: 'testPrefix/sensor/testInstance/oil_life_message/config',
payload: {
device: {
identifiers: ['1234'],
manufacturer: 'TestMake',
model: '2022 TestModel',
name: 'TestVehicle',
suggested_area: 'TestVehicle',
},
availability: {
topic: mqtt.getAvailabilityTopic(),
payload_available: 'true',
payload_not_available: 'false',
},
unique_id: '1234_oil_life',
name: 'Oil Life Message',
state_topic: 'testPrefix/sensor/testInstance/oil_life/state',
value_template: '{{ value_json.oil_life_message }}',
icon: 'testIcon',
}
};
const result = mqtt.createSensorMessageConfigPayload(sensor, component, icon);
assert.deepStrictEqual(result, expected);
it('should create sensor message config payload when component is provided', () => {
const sensor = 'oil_life';
const component = undefined;
const icon = 'testIcon';
const expected = {
topic: 'testPrefix/sensor/testInstance/oil_life_message/config',
payload: {
device: {
identifiers: ['1234'],
manufacturer: 'TestMake',
model: '2022 TestModel',
name: 'TestVehicle',
suggested_area: 'TestVehicle',
},
availability: {
topic: mqtt.getAvailabilityTopic(),
payload_available: 'true',
payload_not_available: 'false',
},
unique_id: '1234_oil_life',
name: 'Oil Life Message',
state_topic: 'testPrefix/sensor/testInstance/oil_life/state',
value_template: '{{ value_json.oil_life_message }}',
icon: 'testIcon',
}
};
const result = mqtt.createSensorMessageConfigPayload(sensor, component, icon);
assert.deepStrictEqual(result, expected);
});
});
});

});
});

0 comments on commit 3f2be8a

Please sign in to comment.