mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-27 21:20:03 +00:00
Separate Home Assisant name by space instead of _ when friendlyName contains space. #4048
This commit is contained in:
@@ -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}`;
|
||||
|
||||
@@ -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
@@ -109,7 +109,7 @@ function writeDefaultConfiguration() {
|
||||
},
|
||||
'0x0017880104e45551': {
|
||||
retain: false,
|
||||
friendly_name: 'smart_vent'
|
||||
friendly_name: 'smart vent'
|
||||
},
|
||||
'0x0017880104e45552': {
|
||||
retain: false,
|
||||
|
||||
Reference in New Issue
Block a user