Separate Home Assisant name by space instead of _ when friendlyName contains space. #4048

This commit is contained in:
Koen Kanters
2020-08-08 13:54:39 +02:00
parent fbecb7e0d2
commit ff2fe2b358
3 changed files with 10 additions and 9 deletions
+3 -2
View File
@@ -2095,8 +2095,9 @@ class HomeAssistant extends Extension {
payload.json_attributes_topic = stateTopic;
// Set (unique) name
payload.name = `${friendlyName}_${config.object_id}`;
// Set (unique) name, separate by space if friendlyName contains space.
const nameSeparator = friendlyName.includes(' ') ? ' ' : '_';
payload.name = `${friendlyName}${nameSeparator}${config.object_id}`;
// Set unique_id
payload.unique_id = `${deviceSettings.ID}_${config.object_id}_${settings.get().mqtt.base_topic}`;
+6 -6
View File
@@ -433,18 +433,18 @@ describe('HomeAssistant extension', () => {
await flushPromises();
payload = {
command_topic: 'zigbee2mqtt/smart_vent/set',
position_topic: 'zigbee2mqtt/smart_vent',
set_position_topic: 'zigbee2mqtt/smart_vent/set',
command_topic: 'zigbee2mqtt/smart vent/set',
position_topic: 'zigbee2mqtt/smart vent',
set_position_topic: 'zigbee2mqtt/smart vent/set',
set_position_template: '{ "position": {{ position }} }',
value_template: '{{ value_json.position }}',
json_attributes_topic: 'zigbee2mqtt/smart_vent',
name: 'smart_vent_cover',
json_attributes_topic: 'zigbee2mqtt/smart vent',
name: 'smart vent cover',
unique_id: '0x0017880104e45551_cover_zigbee2mqtt',
device:
{
identifiers: [ 'zigbee2mqtt_0x0017880104e45551' ],
name: 'smart_vent',
name: 'smart vent',
sw_version: this.version,
model: 'Smart vent (SV01)',
manufacturer: 'Keen Home'
+1 -1
View File
@@ -109,7 +109,7 @@ function writeDefaultConfiguration() {
},
'0x0017880104e45551': {
retain: false,
friendly_name: 'smart_vent'
friendly_name: 'smart vent'
},
'0x0017880104e45552': {
retain: false,