Skip to content

Commit

Permalink
Fix add equipment/points expert mode (#1802)
Browse files Browse the repository at this point in the history
Fixes #1775.

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
  • Loading branch information
digitaldan authored Mar 19, 2023
1 parent 6836ce5 commit cb0436b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Points } from '@/assets/semantics'
import utils from '@/js/openhab/utils'

/**
* Generate a textual definition for the items provided by the "add from thing" page,
Expand All @@ -23,13 +24,13 @@ export default (thing, channelTypes, newEquipmentItem, parentGroupsForEquipment,
for (const channel of thing.channels) {
if (channel.kind !== 'STATE') continue
const channelType = channelTypesMap.get(channel.channelTypeUID)
let newItemName = (newEquipmentItem) ? newEquipmentItem.name : this.$oh.utils.normalizeLabel(thing.label)
let newItemName = (newEquipmentItem) ? newEquipmentItem.name : utils.normalizeLabel(thing.label)
newItemName += '_'
let suffix = channel.label || channel.id
if (thing.channels.filter((c) => c.label === suffix || (c.channelTypeUID && channelTypesMap[c.channelTypeUID] && channelTypesMap[c.channelTypeUID].label === suffix)).length > 1) {
suffix = channel.id.replace('#', '_').replace(/(^\w{1})|(_+\w{1})/g, letter => letter.toUpperCase())
}
newItemName += this.$oh.utils.normalizeLabel(suffix)
newItemName += utils.normalizeLabel(suffix)
const defaultTags = (channel.defaultTags.length > 0) ? channel.defaultTags : channelType.tags
const newItem = {
channel: channel,
Expand Down

0 comments on commit cb0436b

Please sign in to comment.