Removed custom formatting for child zigbee/zwave entity names

The parent->child relationship is now modelled on the database itself,
so we no longer need value names specifically formatted as
`[DeviceName] ValueName` - the UI will take care of it.
This commit is contained in:
Fabio Manganiello 2022-11-30 01:02:25 +01:00
parent 080b21ab70
commit 16c24d799d
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 11 additions and 33 deletions

View file

@ -215,7 +215,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
dev_entities.append(
Light(
id=f'{dev["ieee_address"]}:light',
name=dev.get('friendly_name'),
name='Light',
on=dev.get('state', {}).get('state')
== switch_info.get('value_on'),
brightness_min=light_info.get('brightness_min'),
@ -264,7 +264,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
dev_entities.append(
Switch(
id=f'{dev["ieee_address"]}:switch',
name=dev.get('friendly_name'),
name='Switch',
state=dev.get('state', {}).get('state')
== switch_info['value_on'],
description=dev_def.get("description"),
@ -1566,12 +1566,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
entity_type = None
sensor_args = {
'id': f'{device_info["ieee_address"]}:{exposed["property"]}',
'name': (
device_info.get('friendly_name', '[Unnamed device]')
+ ' ['
+ exposed.get('description', '')
+ ']'
),
'name': exposed.get('description', ''),
'value': device_info.get('state', {}).get(exposed['property']),
'description': exposed.get('description'),
'is_read_only': cls._is_read_only(exposed),
@ -1626,12 +1621,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
return [
Dimmer(
id=f'{device_info["ieee_address"]}:{exposed["property"]}',
name=(
device_info.get('friendly_name', '[Unnamed device]')
+ ' ['
+ exposed.get('description', '')
+ ']'
),
name=exposed.get('description', ''),
value=device_info.get('state', {}).get(exposed['property']),
min=exposed.get('value_min'),
max=exposed.get('value_max'),
@ -1656,12 +1646,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
return [
EnumSwitch(
id=f'{device_info["ieee_address"]}:{exposed["property"]}',
name=(
device_info.get('friendly_name', '[Unnamed device]')
+ ' ['
+ exposed.get('description', '')
+ ']'
),
name=exposed.get('description', ''),
value=device_info.get(exposed['property']),
values=exposed.get('values', []),
description=exposed.get('description'),

View file

@ -600,31 +600,21 @@ class ZwaveMqttPlugin(MqttPlugin, ZwaveBasePlugin):
value = {
**value,
'id': current_value_id,
'label': 'Current Value',
'label': 'Value',
'is_read_only': False,
'is_write_only': False,
}
args = {
'id': value['id'],
'name': '{node_name} [{value_name}]'.format(
node_name=self._nodes_cache['by_id'][value['node_id']].get(
'name', f'[Node {value["node_id"]}]'
),
value_name=value.get('label'),
),
'name': value.get('label'),
'description': value.get('help'),
'is_read_only': value.get('is_read_only'),
'is_write_only': value.get('is_write_only'),
'data': {
'label': value.get('label'),
'node_id': value.get('node_id'),
},
}
if value.get('last_update'):
args['updated_at'] = value['last_update']
return args
def transform_entities(self, values: Iterable[Mapping]):
@ -675,6 +665,9 @@ class ZwaveMqttPlugin(MqttPlugin, ZwaveBasePlugin):
entities_by_id: Dict[str, Entity] = {str(e.id): e for e in entities}
for value in values:
if not (value and value.get('id')):
continue
entity = entities_by_id.get(value['id'])
if not entity:
continue
@ -733,7 +726,7 @@ class ZwaveMqttPlugin(MqttPlugin, ZwaveBasePlugin):
)
value['id'] = value['value_id'] = value['id_on_network'] = value_id
value['is_read_only'] = value['is_write_only'] = False
value['label'] = 'Current Value'
value['label'] = 'Value'
value['property_id'] = 'currentValue'
value['last_update'] = (
max(