forked from platypush/platypush
More robust attribute checking before conversion, as the object can actually be either a ZWaveNode or a ZWaveController
This commit is contained in:
parent
98ced4b4e4
commit
1b47615100
1 changed files with 33 additions and 32 deletions
|
@ -206,45 +206,46 @@ class ZwavePlugin(Plugin):
|
|||
'node_id': node.node_id,
|
||||
'home_id': node.home_id,
|
||||
'capabilities': list(node.capabilities),
|
||||
'command_classes': [node.get_command_class_as_string(cc) for cc in node.command_classes],
|
||||
'device_type': node.device_type,
|
||||
'command_classes': [node.get_command_class_as_string(cc) for cc in node.command_classes]
|
||||
if hasattr(node, 'command_classes') else [],
|
||||
'device_type': node.device_type if hasattr(node, 'device_type') else '',
|
||||
'groups': {
|
||||
group_id: cls.group_to_dict(group)
|
||||
for group_id, group in node.groups.items()
|
||||
},
|
||||
'is_awake': node.is_awake,
|
||||
'is_failed': node.is_failed,
|
||||
'is_beaming_device': node.is_beaming_device,
|
||||
'is_frequent_listening_device': node.is_frequent_listening_device,
|
||||
'is_info_received': node.is_info_received,
|
||||
'is_listening_device': node.is_listening_device,
|
||||
'is_locked': node.is_locked,
|
||||
'is_ready': node.is_ready,
|
||||
'is_routing_device': node.is_routing_device,
|
||||
'is_security_device': node.is_security_device,
|
||||
'is_sleeping': node.is_sleeping,
|
||||
'last_update': node.last_update,
|
||||
'location': node.location,
|
||||
'manufacturer_id': node.manufacturer_id,
|
||||
'manufacturer_name': node.manufacturer_name,
|
||||
'max_baud_rate': node.max_baud_rate,
|
||||
'neighbours': [node_id for node_id in node.neighbors],
|
||||
'name': node.name,
|
||||
'outdated': node.outdated,
|
||||
'product_id': node.product_id,
|
||||
'product_name': node.product_name,
|
||||
'product_type': node.product_type,
|
||||
'query_stage': node.query_stage,
|
||||
'role': node.role,
|
||||
'security': node.security,
|
||||
'specific': node.specific,
|
||||
'type': node.type,
|
||||
'use_cache': node.use_cache,
|
||||
'version': node.version,
|
||||
'is_awake': node.is_awake if hasattr(node, 'is_awake') else False,
|
||||
'is_failed': node.is_failed if hasattr(node, 'is_failed') else False,
|
||||
'is_beaming_device': node.is_beaming_device if hasattr(node, 'is_beaming_device') else False,
|
||||
'is_frequent_listening_device': node.is_frequent_listening_device if hasattr(node, 'is_frequent_listening_device') else False,
|
||||
'is_info_received': node.is_info_received if hasattr(node, 'is_info_received') else False,
|
||||
'is_listening_device': node.is_listening_device if hasattr(node, 'is_listening_device') else False,
|
||||
'is_locked': node.is_locked if hasattr(node, 'is_locked') else False,
|
||||
'is_ready': node.is_ready if hasattr(node, 'is_ready') else False,
|
||||
'is_routing_device': node.is_routing_device if hasattr(node, 'is_routing_device') else False,
|
||||
'is_security_device': node.is_security_device if hasattr(node, 'is_security_device') else False,
|
||||
'is_sleeping': node.is_sleeping if hasattr(node, 'is_sleeping') else False,
|
||||
'last_update': node.last_update if hasattr(node, 'last_update') else None,
|
||||
'location': node.location if hasattr(node, 'location') else None,
|
||||
'manufacturer_id': node.manufacturer_id if hasattr(node, 'manufacturer_id') else None,
|
||||
'manufacturer_name': node.manufacturer_name if hasattr(node, 'manufacturer_name') else None,
|
||||
'max_baud_rate': node.max_baud_rate if hasattr(node, 'max_baud_rate') else None,
|
||||
'neighbours': [node_id for node_id in node.neighbors] if hasattr(node, 'neighbours') else [],
|
||||
'name': node.name if hasattr(node, 'name') else None,
|
||||
'outdated': node.outdated if hasattr(node, 'outdated') else False,
|
||||
'product_id': node.product_id if hasattr(node, 'product_id') else None,
|
||||
'product_name': node.product_name if hasattr(node, 'product_name') else None,
|
||||
'product_type': node.product_type if hasattr(node, 'product_type') else None,
|
||||
'query_stage': node.query_stage if hasattr(node, 'query_stage') else None,
|
||||
'role': node.role if hasattr(node, 'role') else None,
|
||||
'security': node.security if hasattr(node, 'security') else None,
|
||||
'specific': node.specific if hasattr(node, 'specific') else None,
|
||||
'type': node.type if hasattr(node, 'type') else None,
|
||||
'use_cache': node.use_cache if hasattr(node, 'use_cache') else False,
|
||||
'version': node.version if hasattr(node, 'version') else None,
|
||||
'values': {
|
||||
value.id_on_network: cls.value_to_dict(value)
|
||||
for value_id, value in (node.values or {}).items()
|
||||
},
|
||||
} if hasattr(node, 'values') else {},
|
||||
}
|
||||
|
||||
def _get_node(self, node_id: Optional[int] = None, node_name: Optional[str] = None) -> ZWaveNode:
|
||||
|
|
Loading…
Reference in a new issue