mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-09-01 16:48:31 +00:00
Revert "Capitalize entity name in Home Assistant (#16702)"
This reverts commit f5cceb1719.
This commit is contained in:
@@ -1192,16 +1192,13 @@ export default class HomeAssistant extends Extension {
|
||||
|
||||
const devicePayload = this.getDevicePayload(entity);
|
||||
|
||||
// Set (unique) name, separate and change case according to name of the device.
|
||||
// Set (unique) name, separate by space if device name contains space.
|
||||
const nameSeparator = devicePayload.name.includes('_') ? '_' : ' ';
|
||||
const isNameCapitalize = devicePayload.name[0] === devicePayload.name[0].toUpperCase();
|
||||
payload.name = devicePayload.name;
|
||||
if (config.object_id.startsWith(config.type) && config.object_id.includes('_')) {
|
||||
const name = config.object_id.split(/_(.+)/)[1];
|
||||
payload.name += `${nameSeparator}${isNameCapitalize ? utils.capitalize(name) : name}`;
|
||||
payload.name += `${nameSeparator}${config.object_id.split(/_(.+)/)[1]}`;
|
||||
} else if (!config.object_id.startsWith(config.type)) {
|
||||
const name = config.object_id.replace(/_/g, nameSeparator);
|
||||
payload.name += `${nameSeparator}${isNameCapitalize ? utils.capitalize(name) : name}`;
|
||||
payload.name += `${nameSeparator}${config.object_id.replace(/_/g, nameSeparator)}`;
|
||||
}
|
||||
|
||||
// Set unique_id
|
||||
|
||||
@@ -584,7 +584,7 @@ describe('HomeAssistant extension', () => {
|
||||
'value_template': '{{ value_json.temperature }}',
|
||||
'state_topic': 'zigbee2mqtt/weather_sensor',
|
||||
'json_attributes_topic': 'zigbee2mqtt/weather_sensor',
|
||||
'name': 'Weather Sensor Temperature',
|
||||
'name': 'Weather Sensor temperature',
|
||||
'unique_id': '0x0017880104e45522_temperature_zigbee2mqtt',
|
||||
'device': {
|
||||
'identifiers': ['zigbee2mqtt_0x0017880104e45522'],
|
||||
@@ -611,7 +611,7 @@ describe('HomeAssistant extension', () => {
|
||||
'value_template': '{{ value_json.humidity }}',
|
||||
'state_topic': 'zigbee2mqtt/weather_sensor',
|
||||
'json_attributes_topic': 'zigbee2mqtt/weather_sensor',
|
||||
'name': 'Weather Sensor Humidity',
|
||||
'name': 'Weather Sensor humidity',
|
||||
'unique_id': '0x0017880104e45522_humidity_zigbee2mqtt',
|
||||
'enabled_by_default': true,
|
||||
'device': {
|
||||
|
||||
Reference in New Issue
Block a user