forked from platypush/platypush
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:
parent
080b21ab70
commit
16c24d799d
2 changed files with 11 additions and 33 deletions
|
@ -215,7 +215,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
dev_entities.append(
|
dev_entities.append(
|
||||||
Light(
|
Light(
|
||||||
id=f'{dev["ieee_address"]}:light',
|
id=f'{dev["ieee_address"]}:light',
|
||||||
name=dev.get('friendly_name'),
|
name='Light',
|
||||||
on=dev.get('state', {}).get('state')
|
on=dev.get('state', {}).get('state')
|
||||||
== switch_info.get('value_on'),
|
== switch_info.get('value_on'),
|
||||||
brightness_min=light_info.get('brightness_min'),
|
brightness_min=light_info.get('brightness_min'),
|
||||||
|
@ -264,7 +264,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
dev_entities.append(
|
dev_entities.append(
|
||||||
Switch(
|
Switch(
|
||||||
id=f'{dev["ieee_address"]}:switch',
|
id=f'{dev["ieee_address"]}:switch',
|
||||||
name=dev.get('friendly_name'),
|
name='Switch',
|
||||||
state=dev.get('state', {}).get('state')
|
state=dev.get('state', {}).get('state')
|
||||||
== switch_info['value_on'],
|
== switch_info['value_on'],
|
||||||
description=dev_def.get("description"),
|
description=dev_def.get("description"),
|
||||||
|
@ -1566,12 +1566,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
entity_type = None
|
entity_type = None
|
||||||
sensor_args = {
|
sensor_args = {
|
||||||
'id': f'{device_info["ieee_address"]}:{exposed["property"]}',
|
'id': f'{device_info["ieee_address"]}:{exposed["property"]}',
|
||||||
'name': (
|
'name': exposed.get('description', ''),
|
||||||
device_info.get('friendly_name', '[Unnamed device]')
|
|
||||||
+ ' ['
|
|
||||||
+ exposed.get('description', '')
|
|
||||||
+ ']'
|
|
||||||
),
|
|
||||||
'value': device_info.get('state', {}).get(exposed['property']),
|
'value': device_info.get('state', {}).get(exposed['property']),
|
||||||
'description': exposed.get('description'),
|
'description': exposed.get('description'),
|
||||||
'is_read_only': cls._is_read_only(exposed),
|
'is_read_only': cls._is_read_only(exposed),
|
||||||
|
@ -1626,12 +1621,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
return [
|
return [
|
||||||
Dimmer(
|
Dimmer(
|
||||||
id=f'{device_info["ieee_address"]}:{exposed["property"]}',
|
id=f'{device_info["ieee_address"]}:{exposed["property"]}',
|
||||||
name=(
|
name=exposed.get('description', ''),
|
||||||
device_info.get('friendly_name', '[Unnamed device]')
|
|
||||||
+ ' ['
|
|
||||||
+ exposed.get('description', '')
|
|
||||||
+ ']'
|
|
||||||
),
|
|
||||||
value=device_info.get('state', {}).get(exposed['property']),
|
value=device_info.get('state', {}).get(exposed['property']),
|
||||||
min=exposed.get('value_min'),
|
min=exposed.get('value_min'),
|
||||||
max=exposed.get('value_max'),
|
max=exposed.get('value_max'),
|
||||||
|
@ -1656,12 +1646,7 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
|
||||||
return [
|
return [
|
||||||
EnumSwitch(
|
EnumSwitch(
|
||||||
id=f'{device_info["ieee_address"]}:{exposed["property"]}',
|
id=f'{device_info["ieee_address"]}:{exposed["property"]}',
|
||||||
name=(
|
name=exposed.get('description', ''),
|
||||||
device_info.get('friendly_name', '[Unnamed device]')
|
|
||||||
+ ' ['
|
|
||||||
+ exposed.get('description', '')
|
|
||||||
+ ']'
|
|
||||||
),
|
|
||||||
value=device_info.get(exposed['property']),
|
value=device_info.get(exposed['property']),
|
||||||
values=exposed.get('values', []),
|
values=exposed.get('values', []),
|
||||||
description=exposed.get('description'),
|
description=exposed.get('description'),
|
||||||
|
|
|
@ -600,31 +600,21 @@ class ZwaveMqttPlugin(MqttPlugin, ZwaveBasePlugin):
|
||||||
value = {
|
value = {
|
||||||
**value,
|
**value,
|
||||||
'id': current_value_id,
|
'id': current_value_id,
|
||||||
'label': 'Current Value',
|
'label': 'Value',
|
||||||
'is_read_only': False,
|
'is_read_only': False,
|
||||||
'is_write_only': False,
|
'is_write_only': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
'id': value['id'],
|
'id': value['id'],
|
||||||
'name': '{node_name} [{value_name}]'.format(
|
'name': value.get('label'),
|
||||||
node_name=self._nodes_cache['by_id'][value['node_id']].get(
|
|
||||||
'name', f'[Node {value["node_id"]}]'
|
|
||||||
),
|
|
||||||
value_name=value.get('label'),
|
|
||||||
),
|
|
||||||
'description': value.get('help'),
|
'description': value.get('help'),
|
||||||
'is_read_only': value.get('is_read_only'),
|
'is_read_only': value.get('is_read_only'),
|
||||||
'is_write_only': value.get('is_write_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'):
|
if value.get('last_update'):
|
||||||
args['updated_at'] = value['last_update']
|
args['updated_at'] = value['last_update']
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def transform_entities(self, values: Iterable[Mapping]):
|
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}
|
entities_by_id: Dict[str, Entity] = {str(e.id): e for e in entities}
|
||||||
|
|
||||||
for value in values:
|
for value in values:
|
||||||
|
if not (value and value.get('id')):
|
||||||
|
continue
|
||||||
|
|
||||||
entity = entities_by_id.get(value['id'])
|
entity = entities_by_id.get(value['id'])
|
||||||
if not entity:
|
if not entity:
|
||||||
continue
|
continue
|
||||||
|
@ -733,7 +726,7 @@ class ZwaveMqttPlugin(MqttPlugin, ZwaveBasePlugin):
|
||||||
)
|
)
|
||||||
value['id'] = value['value_id'] = value['id_on_network'] = value_id
|
value['id'] = value['value_id'] = value['id_on_network'] = value_id
|
||||||
value['is_read_only'] = value['is_write_only'] = False
|
value['is_read_only'] = value['is_write_only'] = False
|
||||||
value['label'] = 'Current Value'
|
value['label'] = 'Value'
|
||||||
value['property_id'] = 'currentValue'
|
value['property_id'] = 'currentValue'
|
||||||
value['last_update'] = (
|
value['last_update'] = (
|
||||||
max(
|
max(
|
||||||
|
|
Loading…
Reference in a new issue