try bool values instead of string for binary_sensor

This commit is contained in:
Michael Woods 2020-12-28 14:21:09 -05:00
parent c1efc71f54
commit 56e077d2e5
2 changed files with 9 additions and 9 deletions

View File

@ -149,8 +149,8 @@ class MQTT {
availability_topic: this.getAvailabilityTopic(),
payload_available: 'true',
payload_not_available: 'false',
payload_on: 'true',
payload_off: 'false',
payload_on: true,
payload_off: false,
state_topic: this.getStateTopic(diag),
unit_of_measurement: diagEl.unit,
value_template: `{{ value_json.${MQTT.convertName(diagEl.name)} }}`,

View File

@ -37,7 +37,7 @@ describe('MQTT', () => {
assert.strictEqual(mqtt.getConfigTopic(d), 'homeassistant/sensor/XXX/ambient_air_temperature/config');
});
it('should generate state topics', () => {
assert.strictEqual(mqtt.getStateTopic(d, d.diagnosticElements[0]), 'homeassistant/sensor/XXX/ambient_air_temperature/state');
assert.strictEqual(mqtt.getStateTopic(d), 'homeassistant/sensor/XXX/ambient_air_temperature/state');
});
});
@ -72,8 +72,8 @@ describe('MQTT', () => {
name: 'Ambient Air Temperature',
payload_available: 'true',
payload_not_available: 'false',
payload_off: 'false',
payload_on: 'true',
payload_off: false,
payload_on: true,
state_topic: 'homeassistant/sensor/XXX/ambient_air_temperature/state',
unit_of_measurement: '°C',
value_template: '{{ value_json.ambient_air_temperature }}'
@ -104,8 +104,8 @@ describe('MQTT', () => {
name: 'Priority Charge Indicator',
payload_available: 'true',
payload_not_available: 'false',
payload_off: 'false',
payload_on: 'true',
payload_off: false,
payload_on: true,
state_topic: 'homeassistant/binary_sensor/XXX/ev_charge_state/state',
unit_of_measurement: undefined,
value_template: '{{ value_json.priority_charge_indicator }}'
@ -138,8 +138,8 @@ describe('MQTT', () => {
name: 'Tire Pressure: Left Front',
payload_available: 'true',
payload_not_available: 'false',
payload_off: 'false',
payload_on: 'true',
payload_off: false,
payload_on: true,
state_topic: 'homeassistant/sensor/XXX/tire_pressure/state',
unit_of_measurement: 'kPa',
value_template: '{{ value_json.tire_pressure_lf }}'